@@ -10,19 +10,19 @@ discard block  | 
                                                    ||
| 10 | 10 | ?>  | 
                                                        
| 11 | 11 | <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">  | 
                                                        
| 12 | 12 | <?php  | 
                                                        
| 13 | - if (! empty($no_attendee_message)) : ?>  | 
                                                        |
| 13 | + if (! empty($no_attendee_message)) : ?>  | 
                                                        |
| 14 | 14 | <p class="clearfix">  | 
                                                        
| 15 | 15 | <?php echo $no_attendee_message; ?>  | 
                                                        
| 16 | 16 | </p>  | 
                                                        
| 17 | 17 | </div> <!-- end #admin-side-mbox-primary-registrant-dv -->  | 
                                                        
| 18 | 18 | <?php  | 
                                                        
| 19 | - else : ?>  | 
                                                        |
| 19 | + else : ?>  | 
                                                        |
| 20 | 20 | <p class="clearfix">  | 
                                                        
| 21 | 21 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
| 22 | 22 | <?php esc_html_e(  | 
                                                        
| 23 | - 'Name',  | 
                                                        |
| 24 | - 'event_espresso'  | 
                                                        |
| 25 | - ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>  | 
                                                        |
| 23 | + 'Name',  | 
                                                        |
| 24 | + 'event_espresso'  | 
                                                        |
| 25 | + ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>  | 
                                                        |
| 26 | 26 | </p>  | 
                                                        
| 27 | 27 | <p class="clearfix">  | 
                                                        
| 28 | 28 |          <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a | 
                                                        
@@ -31,9 +31,9 @@ discard block  | 
                                                    ||
| 31 | 31 | <p class="clearfix">  | 
                                                        
| 32 | 32 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
| 33 | 33 | <?php esc_html_e(  | 
                                                        
| 34 | - 'Phone #',  | 
                                                        |
| 35 | - 'event_espresso'  | 
                                                        |
| 36 | - ); ?>  | 
                                                        |
| 34 | + 'Phone #',  | 
                                                        |
| 35 | + 'event_espresso'  | 
                                                        |
| 36 | + ); ?>  | 
                                                        |
| 37 | 37 | </span>  | 
                                                        
| 38 | 38 | <?php if (! empty($prime_reg_phone)) : ?>  | 
                                                        
| 39 | 39 | <a href="tel:<?php echo $phone; ?>">  | 
                                                        
@@ -50,22 +50,22 @@ discard block  | 
                                                    ||
| 50 | 50 | </div> <!-- end #admin-side-mbox-primary-registrant-dv -->  | 
                                                        
| 51 | 51 | |
| 52 | 52 | <?php  | 
                                                        
| 53 | - /** only show if logged in user has access */  | 
                                                        |
| 54 | - if (EE_Registry::instance()->CAP->current_user_can(  | 
                                                        |
| 55 | - 'ee_edit_contact',  | 
                                                        |
| 56 | - 'view_or_edit_contact_button',  | 
                                                        |
| 57 | - $ATT_ID  | 
                                                        |
| 58 | - )  | 
                                                        |
| 59 | - ) : ?>  | 
                                                        |
| 53 | + /** only show if logged in user has access */  | 
                                                        |
| 54 | + if (EE_Registry::instance()->CAP->current_user_can(  | 
                                                        |
| 55 | + 'ee_edit_contact',  | 
                                                        |
| 56 | + 'view_or_edit_contact_button',  | 
                                                        |
| 57 | + $ATT_ID  | 
                                                        |
| 58 | + )  | 
                                                        |
| 59 | + ) : ?>  | 
                                                        |
| 60 | 60 | <p style="text-align:right;">  | 
                                                        
| 61 | 61 | <a class="button button-small" href="<?php echo $edit_attendee_url; ?>"  | 
                                                        
| 62 | 62 |                 title="<?php esc_attr_e('View details for this contact.', 'event_espresso'); ?>"> | 
                                                        
| 63 | 63 | <span class="ee-icon ee-icon-user-edit"></span>  | 
                                                        
| 64 | 64 | <?php _e(  | 
                                                        
| 65 | - 'View / Edit this Contact',  | 
                                                        |
| 66 | - 'event_espresso'  | 
                                                        |
| 67 | - ); ?>  | 
                                                        |
| 65 | + 'View / Edit this Contact',  | 
                                                        |
| 66 | + 'event_espresso'  | 
                                                        |
| 67 | + ); ?>  | 
                                                        |
| 68 | 68 | </a>  | 
                                                        
| 69 | 69 | </p>  | 
                                                        
| 70 | 70 | <?php endif;  | 
                                                        
| 71 | - endif;  | 
                                                        |
| 71 | + endif;  | 
                                                        |
@@ -10,7 +10,7 @@ discard block  | 
                                                    ||
| 10 | 10 | ?>  | 
                                                        
| 11 | 11 | <div id="admin-side-mbox-primary-registrant-dv" class="admin-side-mbox-dv">  | 
                                                        
| 12 | 12 | <?php  | 
                                                        
| 13 | - if (! empty($no_attendee_message)) : ?>  | 
                                                        |
| 13 | + if ( ! empty($no_attendee_message)) : ?>  | 
                                                        |
| 14 | 14 | <p class="clearfix">  | 
                                                        
| 15 | 15 | <?php echo $no_attendee_message; ?>  | 
                                                        
| 16 | 16 | </p>  | 
                                                        
@@ -22,7 +22,7 @@ discard block  | 
                                                    ||
| 22 | 22 | <?php esc_html_e(  | 
                                                        
| 23 | 23 | 'Name',  | 
                                                        
| 24 | 24 | 'event_espresso'  | 
                                                        
| 25 | - ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>  | 
                                                        |
| 25 | + ); ?></span><?php echo $prime_reg_fname.' '.$prime_reg_lname; ?>  | 
                                                        |
| 26 | 26 | </p>  | 
                                                        
| 27 | 27 | <p class="clearfix">  | 
                                                        
| 28 | 28 |          <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a | 
                                                        
@@ -35,7 +35,7 @@ discard block  | 
                                                    ||
| 35 | 35 | 'event_espresso'  | 
                                                        
| 36 | 36 | ); ?>  | 
                                                        
| 37 | 37 | </span>  | 
                                                        
| 38 | - <?php if (! empty($prime_reg_phone)) : ?>  | 
                                                        |
| 38 | + <?php if ( ! empty($prime_reg_phone)) : ?>  | 
                                                        |
| 39 | 39 | <a href="tel:<?php echo $phone; ?>">  | 
                                                        
| 40 | 40 | <?php echo $prime_reg_phone; ?>  | 
                                                        
| 41 | 41 | </a>  | 
                                                        
@@ -16,13 +16,16 @@  | 
                                                    ||
| 16 | 16 | </p>  | 
                                                        
| 17 | 17 | </div> <!-- end #admin-side-mbox-primary-registrant-dv -->  | 
                                                        
| 18 | 18 | <?php  | 
                                                        
| 19 | - else : ?>  | 
                                                        |
| 19 | +    else { | 
                                                        |
| 20 | + : ?>  | 
                                                        |
| 20 | 21 | <p class="clearfix">  | 
                                                        
| 21 | 22 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
| 22 | 23 | <?php esc_html_e(  | 
                                                        
| 23 | 24 | 'Name',  | 
                                                        
| 24 | 25 | 'event_espresso'  | 
                                                        
| 25 | - ); ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>  | 
                                                        |
| 26 | + );  | 
                                                        |
| 27 | + }  | 
                                                        |
| 28 | + ?></span><?php echo $prime_reg_fname . ' ' . $prime_reg_lname; ?>  | 
                                                        |
| 26 | 29 | </p>  | 
                                                        
| 27 | 30 | <p class="clearfix">  | 
                                                        
| 28 | 31 |          <span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php esc_html_e('Email', 'event_espresso'); ?></span><a | 
                                                        
@@ -2,7 +2,7 @@ discard block  | 
                                                    ||
| 2 | 2 | <p class="clearfix">  | 
                                                        
| 3 | 3 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
| 4 | 4 |              <?php esc_html_e('Name', 'event_espresso'); ?> | 
                                                        
| 5 | - </span><?php echo $fname . ' ' . $lname; ?>  | 
                                                        |
| 5 | + </span><?php echo $fname.' '.$lname; ?>  | 
                                                        |
| 6 | 6 | </p>  | 
                                                        
| 7 | 7 | <p class="clearfix">  | 
                                                        
| 8 | 8 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
@@ -16,7 +16,7 @@ discard block  | 
                                                    ||
| 16 | 16 | <span class="admin-side-mbox-label-spn lt-grey-txt float-left">  | 
                                                        
| 17 | 17 |              <?php esc_html_e('Phone #', 'event_espresso'); ?> | 
                                                        
| 18 | 18 | </span>  | 
                                                        
| 19 | - <?php if (! empty($phone)) : ?>  | 
                                                        |
| 19 | + <?php if ( ! empty($phone)) : ?>  | 
                                                        |
| 20 | 20 | <a href="tel:<?php echo $phone; ?>">  | 
                                                        
| 21 | 21 | <?php echo $phone; ?>  | 
                                                        
| 22 | 22 | </a>  | 
                                                        
@@ -46,7 +46,7 @@ discard block  | 
                                                    ||
| 46 | 46 | title="<?php echo esc_attr($att_edit_label); ?>">  | 
                                                        
| 47 | 47 | <span class="ee-icon ee-icon-user-edit"></span><?php echo $att_edit_label; ?>  | 
                                                        
| 48 | 48 | </a>  | 
                                                        
| 49 | - <?php if (! empty($create_link)) : ?>  | 
                                                        |
| 49 | + <?php if ( ! empty($create_link)) : ?>  | 
                                                        |
| 50 | 50 | <a class="button button-small" href="<?php echo $create_link; ?>"  | 
                                                        
| 51 | 51 | title="<?php  | 
                                                        
| 52 | 52 | esc_attr_e(  | 
                                                        
@@ -26,159 +26,159 @@  | 
                                                    ||
| 26 | 26 | |
| 27 | 27 | class EE_DMS_4_1_0_checkins extends EE_Data_Migration_Script_Stage_Table  | 
                                                        
| 28 | 28 |  { | 
                                                        
| 29 | - private $_new_table;  | 
                                                        |
| 30 | - public function __construct()  | 
                                                        |
| 31 | -    { | 
                                                        |
| 32 | - global $wpdb;  | 
                                                        |
| 33 | -        $this->_pretty_name = esc_html__('Checkins', 'event_espresso'); | 
                                                        |
| 34 | - $this->_old_table = $wpdb->prefix."events_attendee";  | 
                                                        |
| 35 | - $this->_extra_where_sql = 'AS att  | 
                                                        |
| 29 | + private $_new_table;  | 
                                                        |
| 30 | + public function __construct()  | 
                                                        |
| 31 | +	{ | 
                                                        |
| 32 | + global $wpdb;  | 
                                                        |
| 33 | +		$this->_pretty_name = esc_html__('Checkins', 'event_espresso'); | 
                                                        |
| 34 | + $this->_old_table = $wpdb->prefix."events_attendee";  | 
                                                        |
| 35 | + $this->_extra_where_sql = 'AS att  | 
                                                        |
| 36 | 36 | INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id  | 
                                                        
| 37 | 37 | WHERE e.event_status!="D"';  | 
                                                        
| 38 | - $this->_new_table = $wpdb->prefix."esp_checkin";  | 
                                                        |
| 39 | - parent::__construct();  | 
                                                        |
| 40 | - }  | 
                                                        |
| 41 | - protected function _migrate_old_row($old_row)  | 
                                                        |
| 42 | -    { | 
                                                        |
| 43 | - global $wpdb;  | 
                                                        |
| 44 | - $new_reg_table = $wpdb->prefix."esp_registration";  | 
                                                        |
| 38 | + $this->_new_table = $wpdb->prefix."esp_checkin";  | 
                                                        |
| 39 | + parent::__construct();  | 
                                                        |
| 40 | + }  | 
                                                        |
| 41 | + protected function _migrate_old_row($old_row)  | 
                                                        |
| 42 | +	{ | 
                                                        |
| 43 | + global $wpdb;  | 
                                                        |
| 44 | + $new_reg_table = $wpdb->prefix."esp_registration";  | 
                                                        |
| 45 | 45 | |
| 46 | - $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;  | 
                                                        |
| 46 | + $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;  | 
                                                        |
| 47 | 47 | |
| 48 | - $new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);  | 
                                                        |
| 49 | -        if (! $new_registrations_for_attendee) { | 
                                                        |
| 50 | - $new_registrations_for_attendee = array();  | 
                                                        |
| 51 | - }  | 
                                                        |
| 52 | - $new_datetime = $this->_try_to_find_datetime($old_row);  | 
                                                        |
| 48 | + $new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);  | 
                                                        |
| 49 | +		if (! $new_registrations_for_attendee) { | 
                                                        |
| 50 | + $new_registrations_for_attendee = array();  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | + $new_datetime = $this->_try_to_find_datetime($old_row);  | 
                                                        |
| 53 | 53 | |
| 54 | - // make sure registrations array is numerically indexed starting at 0 (it probably already is)  | 
                                                        |
| 55 | - $new_registrations_for_attendee = array_values($new_registrations_for_attendee);  | 
                                                        |
| 56 | - $new_checkin_ids = array();  | 
                                                        |
| 57 | -        for ($i = 0; $i<abs($num_to_checkin_at_this_time); $i++) { | 
                                                        |
| 58 | - $new_reg_id = $new_registrations_for_attendee[ $i ];  | 
                                                        |
| 59 | -            if (! $new_reg_id) { | 
                                                        |
| 60 | - $this->add_error(sprintf(  | 
                                                        |
| 61 | - esc_html__(  | 
                                                        |
| 62 | - /* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in  | 
                                                        |
| 54 | + // make sure registrations array is numerically indexed starting at 0 (it probably already is)  | 
                                                        |
| 55 | + $new_registrations_for_attendee = array_values($new_registrations_for_attendee);  | 
                                                        |
| 56 | + $new_checkin_ids = array();  | 
                                                        |
| 57 | +		for ($i = 0; $i<abs($num_to_checkin_at_this_time); $i++) { | 
                                                        |
| 58 | + $new_reg_id = $new_registrations_for_attendee[ $i ];  | 
                                                        |
| 59 | +			if (! $new_reg_id) { | 
                                                        |
| 60 | + $this->add_error(sprintf(  | 
                                                        |
| 61 | + esc_html__(  | 
                                                        |
| 62 | + /* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in  | 
                                                        |
| 63 | 63 | * %3$s number of registrations for the attendee, %4$s new registration rows represented in JSON  | 
                                                        
| 64 | 64 | */  | 
                                                        
| 65 | - // @codingStandardsIgnoreStart  | 
                                                        |
| 66 | - 'It appears we wanted to check-in more registrations than actually exist. The old attendee record (%1$s) indicated we should check-in %2$d registrations, but there are only %3$d registrations for that attendee (%4$s)',  | 
                                                        |
| 67 | - // @codingStandardsIgnoreEnd  | 
                                                        |
| 68 | - 'event_espresso'  | 
                                                        |
| 69 | - ),  | 
                                                        |
| 70 | - $this->_json_encode($old_row),  | 
                                                        |
| 71 | - abs($num_to_checkin_at_this_time),  | 
                                                        |
| 72 | - count($new_registrations_for_attendee),  | 
                                                        |
| 73 | - $this->_json_encode($new_registrations_for_attendee)  | 
                                                        |
| 74 | - ));  | 
                                                        |
| 75 | - break;  | 
                                                        |
| 76 | - }  | 
                                                        |
| 77 | - $existing_checkin_record = $wpdb->get_var(  | 
                                                        |
| 78 | - $wpdb->prepare(  | 
                                                        |
| 79 | - "SELECT CHK_ID FROM $this->_new_table WHERE REG_ID = %d ORDER BY CHK_ID DESC LIMIT 1",  | 
                                                        |
| 80 | - $new_reg_id  | 
                                                        |
| 81 | - )  | 
                                                        |
| 82 | - );  | 
                                                        |
| 83 | -            if (! $existing_checkin_record) { | 
                                                        |
| 84 | - $new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);  | 
                                                        |
| 85 | -                if ($new_id) { | 
                                                        |
| 86 | - $new_checkin_ids[]= $new_id;  | 
                                                        |
| 87 | - }  | 
                                                        |
| 88 | - }  | 
                                                        |
| 89 | - }  | 
                                                        |
| 90 | -        if ($new_checkin_ids) { | 
                                                        |
| 91 | - $this->get_migration_script()->set_mapping(  | 
                                                        |
| 92 | - $this->_old_table,  | 
                                                        |
| 93 | - $old_row['id'],  | 
                                                        |
| 94 | - $this->_new_table,  | 
                                                        |
| 95 | - $new_checkin_ids  | 
                                                        |
| 96 | - );  | 
                                                        |
| 97 | - }  | 
                                                        |
| 98 | - }  | 
                                                        |
| 65 | + // @codingStandardsIgnoreStart  | 
                                                        |
| 66 | + 'It appears we wanted to check-in more registrations than actually exist. The old attendee record (%1$s) indicated we should check-in %2$d registrations, but there are only %3$d registrations for that attendee (%4$s)',  | 
                                                        |
| 67 | + // @codingStandardsIgnoreEnd  | 
                                                        |
| 68 | + 'event_espresso'  | 
                                                        |
| 69 | + ),  | 
                                                        |
| 70 | + $this->_json_encode($old_row),  | 
                                                        |
| 71 | + abs($num_to_checkin_at_this_time),  | 
                                                        |
| 72 | + count($new_registrations_for_attendee),  | 
                                                        |
| 73 | + $this->_json_encode($new_registrations_for_attendee)  | 
                                                        |
| 74 | + ));  | 
                                                        |
| 75 | + break;  | 
                                                        |
| 76 | + }  | 
                                                        |
| 77 | + $existing_checkin_record = $wpdb->get_var(  | 
                                                        |
| 78 | + $wpdb->prepare(  | 
                                                        |
| 79 | + "SELECT CHK_ID FROM $this->_new_table WHERE REG_ID = %d ORDER BY CHK_ID DESC LIMIT 1",  | 
                                                        |
| 80 | + $new_reg_id  | 
                                                        |
| 81 | + )  | 
                                                        |
| 82 | + );  | 
                                                        |
| 83 | +			if (! $existing_checkin_record) { | 
                                                        |
| 84 | + $new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);  | 
                                                        |
| 85 | +				if ($new_id) { | 
                                                        |
| 86 | + $new_checkin_ids[]= $new_id;  | 
                                                        |
| 87 | + }  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | + }  | 
                                                        |
| 90 | +		if ($new_checkin_ids) { | 
                                                        |
| 91 | + $this->get_migration_script()->set_mapping(  | 
                                                        |
| 92 | + $this->_old_table,  | 
                                                        |
| 93 | + $old_row['id'],  | 
                                                        |
| 94 | + $this->_new_table,  | 
                                                        |
| 95 | + $new_checkin_ids  | 
                                                        |
| 96 | + );  | 
                                                        |
| 97 | + }  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | 99 | |
| 100 | 100 | |
| 101 | - /**  | 
                                                        |
| 102 | - * Tries to find the new datetime the Check-in was for, based on the attendee row  | 
                                                        |
| 103 | - * (because we know the attendee was for an event as a specific time, and we know  | 
                                                        |
| 104 | - * the event's OLD ID...)  | 
                                                        |
| 105 | - * @global type $wpdb  | 
                                                        |
| 106 | - * @param array $old_attendee_row  | 
                                                        |
| 107 | - * @return array row of datetime from DB  | 
                                                        |
| 108 | - */  | 
                                                        |
| 109 | - private function _try_to_find_datetime($old_attendee)  | 
                                                        |
| 110 | -    { | 
                                                        |
| 111 | - global $wpdb;  | 
                                                        |
| 101 | + /**  | 
                                                        |
| 102 | + * Tries to find the new datetime the Check-in was for, based on the attendee row  | 
                                                        |
| 103 | + * (because we know the attendee was for an event as a specific time, and we know  | 
                                                        |
| 104 | + * the event's OLD ID...)  | 
                                                        |
| 105 | + * @global type $wpdb  | 
                                                        |
| 106 | + * @param array $old_attendee_row  | 
                                                        |
| 107 | + * @return array row of datetime from DB  | 
                                                        |
| 108 | + */  | 
                                                        |
| 109 | + private function _try_to_find_datetime($old_attendee)  | 
                                                        |
| 110 | +	{ | 
                                                        |
| 111 | + global $wpdb;  | 
                                                        |
| 112 | 112 | |
| 113 | - $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_attendee['event_id'], $wpdb->posts);  | 
                                                        |
| 114 | -        if (! $new_event_id) { | 
                                                        |
| 115 | - $this->add_error(  | 
                                                        |
| 116 | - sprintf(  | 
                                                        |
| 117 | - esc_html__(  | 
                                                        |
| 118 | - /* translators: 1: original event ID, 2: original attendee database row */  | 
                                                        |
| 119 | - // @codingStandardsIgnoreStart  | 
                                                        |
| 120 | - 'Could not find new event ID with old event ID %1$d, on attendee row %2$s; and because of that couldn\'t find the correct datetime for Check-in',  | 
                                                        |
| 121 | - // @codingStandardsIgnoreEnd  | 
                                                        |
| 122 | - 'event_espresso'  | 
                                                        |
| 123 | - ),  | 
                                                        |
| 124 | - $old_attendee['event_id'],  | 
                                                        |
| 125 | - $this->_json_encode($old_attendee)  | 
                                                        |
| 126 | - )  | 
                                                        |
| 127 | - );  | 
                                                        |
| 128 | - return 0;  | 
                                                        |
| 129 | - }  | 
                                                        |
| 130 | - $old_att_start_date = $old_attendee['start_date'];  | 
                                                        |
| 131 | - $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);  | 
                                                        |
| 132 | - $old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");  | 
                                                        |
| 113 | + $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_attendee['event_id'], $wpdb->posts);  | 
                                                        |
| 114 | +		if (! $new_event_id) { | 
                                                        |
| 115 | + $this->add_error(  | 
                                                        |
| 116 | + sprintf(  | 
                                                        |
| 117 | + esc_html__(  | 
                                                        |
| 118 | + /* translators: 1: original event ID, 2: original attendee database row */  | 
                                                        |
| 119 | + // @codingStandardsIgnoreStart  | 
                                                        |
| 120 | + 'Could not find new event ID with old event ID %1$d, on attendee row %2$s; and because of that couldn\'t find the correct datetime for Check-in',  | 
                                                        |
| 121 | + // @codingStandardsIgnoreEnd  | 
                                                        |
| 122 | + 'event_espresso'  | 
                                                        |
| 123 | + ),  | 
                                                        |
| 124 | + $old_attendee['event_id'],  | 
                                                        |
| 125 | + $this->_json_encode($old_attendee)  | 
                                                        |
| 126 | + )  | 
                                                        |
| 127 | + );  | 
                                                        |
| 128 | + return 0;  | 
                                                        |
| 129 | + }  | 
                                                        |
| 130 | + $old_att_start_date = $old_attendee['start_date'];  | 
                                                        |
| 131 | + $old_att_start_time = $this->get_migration_script()->convertTimeFromAMPM($old_attendee['event_time']);  | 
                                                        |
| 132 | + $old_att_datetime = $this->get_migration_script()->convert_date_string_to_utc($this, $old_attendee, "$old_att_start_date $old_att_start_time:00");  | 
                                                        |
| 133 | 133 | |
| 134 | - $datetime_table = $wpdb->prefix."esp_datetime";  | 
                                                        |
| 135 | - // add all conditions to an array from which we can SHIFT conditions off in order to widen our search  | 
                                                        |
| 136 | - // the most important condition should be last, as it will be array_shift'ed off last  | 
                                                        |
| 137 | - $conditions = array(  | 
                                                        |
| 138 | -            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match? | 
                                                        |
| 139 | -            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match? | 
                                                        |
| 140 | - );  | 
                                                        |
| 141 | - // start running queries, widening search each time by removing a condition  | 
                                                        |
| 142 | - $datetime_found = null;  | 
                                                        |
| 143 | -        do { | 
                                                        |
| 144 | -            $full_query = "SELECT * FROM $datetime_table WHERE ".implode(" AND ", $conditions)." LIMIT 1"; | 
                                                        |
| 145 | - $datetime_found = $wpdb->get_row($full_query, ARRAY_A);  | 
                                                        |
| 146 | - array_shift($conditions);  | 
                                                        |
| 147 | - } while (! $datetime_found && $conditions);  | 
                                                        |
| 148 | - return $datetime_found;  | 
                                                        |
| 149 | - }  | 
                                                        |
| 134 | + $datetime_table = $wpdb->prefix."esp_datetime";  | 
                                                        |
| 135 | + // add all conditions to an array from which we can SHIFT conditions off in order to widen our search  | 
                                                        |
| 136 | + // the most important condition should be last, as it will be array_shift'ed off last  | 
                                                        |
| 137 | + $conditions = array(  | 
                                                        |
| 138 | +			$wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match? | 
                                                        |
| 139 | +			$wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match? | 
                                                        |
| 140 | + );  | 
                                                        |
| 141 | + // start running queries, widening search each time by removing a condition  | 
                                                        |
| 142 | + $datetime_found = null;  | 
                                                        |
| 143 | +		do { | 
                                                        |
| 144 | +			$full_query = "SELECT * FROM $datetime_table WHERE ".implode(" AND ", $conditions)." LIMIT 1"; | 
                                                        |
| 145 | + $datetime_found = $wpdb->get_row($full_query, ARRAY_A);  | 
                                                        |
| 146 | + array_shift($conditions);  | 
                                                        |
| 147 | + } while (! $datetime_found && $conditions);  | 
                                                        |
| 148 | + return $datetime_found;  | 
                                                        |
| 149 | + }  | 
                                                        |
| 150 | 150 | |
| 151 | - /**  | 
                                                        |
| 152 | - * Adds a new Check-in/checkout record according for $new_reg_id,$new_datetime_id,$checking_in, and $timestmap  | 
                                                        |
| 153 | - * @param int $new_reg_id  | 
                                                        |
| 154 | - * @param int $new_datetime_id  | 
                                                        |
| 155 | - * @param string $timestamp mysql datetime  | 
                                                        |
| 156 | - * @return int new Check-in id  | 
                                                        |
| 157 | - */  | 
                                                        |
| 158 | - private function _insert_checkin_record($new_reg_id, $new_datetime)  | 
                                                        |
| 159 | -    { | 
                                                        |
| 160 | - global $wpdb;  | 
                                                        |
| 151 | + /**  | 
                                                        |
| 152 | + * Adds a new Check-in/checkout record according for $new_reg_id,$new_datetime_id,$checking_in, and $timestmap  | 
                                                        |
| 153 | + * @param int $new_reg_id  | 
                                                        |
| 154 | + * @param int $new_datetime_id  | 
                                                        |
| 155 | + * @param string $timestamp mysql datetime  | 
                                                        |
| 156 | + * @return int new Check-in id  | 
                                                        |
| 157 | + */  | 
                                                        |
| 158 | + private function _insert_checkin_record($new_reg_id, $new_datetime)  | 
                                                        |
| 159 | +	{ | 
                                                        |
| 160 | + global $wpdb;  | 
                                                        |
| 161 | 161 | |
| 162 | 162 | |
| 163 | - // ok we can actually do what we set out to do: add a checkin/checkout record  | 
                                                        |
| 164 | - $cols_n_values = array(  | 
                                                        |
| 165 | - 'REG_ID'=>$new_reg_id,  | 
                                                        |
| 166 | - 'DTT_ID'=>$new_datetime['DTT_ID'],  | 
                                                        |
| 167 | - 'CHK_in'=>true,  | 
                                                        |
| 168 | - 'CHK_timestamp'=>$new_datetime['DTT_EVT_start']  | 
                                                        |
| 169 | - );  | 
                                                        |
| 170 | - $datatypes = array(  | 
                                                        |
| 171 | - '%d',// REG_ID  | 
                                                        |
| 172 | - '%d',// DTT_ID  | 
                                                        |
| 173 | - '%d',// CHK_in  | 
                                                        |
| 174 | - '%s',// CHK_timestamp  | 
                                                        |
| 175 | - );  | 
                                                        |
| 176 | - $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);  | 
                                                        |
| 177 | -        if (! $success) { | 
                                                        |
| 178 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));  | 
                                                        |
| 179 | - return 0;  | 
                                                        |
| 180 | - }  | 
                                                        |
| 181 | - $new_id = $wpdb->insert_id;  | 
                                                        |
| 182 | - return $new_id;  | 
                                                        |
| 183 | - }  | 
                                                        |
| 163 | + // ok we can actually do what we set out to do: add a checkin/checkout record  | 
                                                        |
| 164 | + $cols_n_values = array(  | 
                                                        |
| 165 | + 'REG_ID'=>$new_reg_id,  | 
                                                        |
| 166 | + 'DTT_ID'=>$new_datetime['DTT_ID'],  | 
                                                        |
| 167 | + 'CHK_in'=>true,  | 
                                                        |
| 168 | + 'CHK_timestamp'=>$new_datetime['DTT_EVT_start']  | 
                                                        |
| 169 | + );  | 
                                                        |
| 170 | + $datatypes = array(  | 
                                                        |
| 171 | + '%d',// REG_ID  | 
                                                        |
| 172 | + '%d',// DTT_ID  | 
                                                        |
| 173 | + '%d',// CHK_in  | 
                                                        |
| 174 | + '%s',// CHK_timestamp  | 
                                                        |
| 175 | + );  | 
                                                        |
| 176 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);  | 
                                                        |
| 177 | +		if (! $success) { | 
                                                        |
| 178 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));  | 
                                                        |
| 179 | + return 0;  | 
                                                        |
| 180 | + }  | 
                                                        |
| 181 | + $new_id = $wpdb->insert_id;  | 
                                                        |
| 182 | + return $new_id;  | 
                                                        |
| 183 | + }  | 
                                                        |
| 184 | 184 | }  | 
                                                        
@@ -33,7 +33,7 @@ discard block  | 
                                                    ||
| 33 | 33 |          $this->_pretty_name = esc_html__('Checkins', 'event_espresso'); | 
                                                        
| 34 | 34 | $this->_old_table = $wpdb->prefix."events_attendee";  | 
                                                        
| 35 | 35 | $this->_extra_where_sql = 'AS att  | 
                                                        
| 36 | - INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id=e.id  | 
                                                        |
| 36 | + INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON att.event_id=e.id  | 
                                                        |
| 37 | 37 | WHERE e.event_status!="D"';  | 
                                                        
| 38 | 38 | $this->_new_table = $wpdb->prefix."esp_checkin";  | 
                                                        
| 39 | 39 | parent::__construct();  | 
                                                        
@@ -43,10 +43,10 @@ discard block  | 
                                                    ||
| 43 | 43 | global $wpdb;  | 
                                                        
| 44 | 44 | $new_reg_table = $wpdb->prefix."esp_registration";  | 
                                                        
| 45 | 45 | |
| 46 | - $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']),intval($old_row['checked_in']))) ;  | 
                                                        |
| 46 | + $num_to_checkin_at_this_time = max(array(intval($old_row['checked_in_quantity']), intval($old_row['checked_in'])));  | 
                                                        |
| 47 | 47 | |
| 48 | 48 | $new_registrations_for_attendee = $this->get_migration_script()->get_mapping_new_pk($this->_old_table, $old_row['id'], $new_reg_table);  | 
                                                        
| 49 | -        if (! $new_registrations_for_attendee) { | 
                                                        |
| 49 | +        if ( ! $new_registrations_for_attendee) { | 
                                                        |
| 50 | 50 | $new_registrations_for_attendee = array();  | 
                                                        
| 51 | 51 | }  | 
                                                        
| 52 | 52 | $new_datetime = $this->_try_to_find_datetime($old_row);  | 
                                                        
@@ -54,9 +54,9 @@ discard block  | 
                                                    ||
| 54 | 54 | // make sure registrations array is numerically indexed starting at 0 (it probably already is)  | 
                                                        
| 55 | 55 | $new_registrations_for_attendee = array_values($new_registrations_for_attendee);  | 
                                                        
| 56 | 56 | $new_checkin_ids = array();  | 
                                                        
| 57 | -        for ($i = 0; $i<abs($num_to_checkin_at_this_time); $i++) { | 
                                                        |
| 58 | - $new_reg_id = $new_registrations_for_attendee[ $i ];  | 
                                                        |
| 59 | -            if (! $new_reg_id) { | 
                                                        |
| 57 | +        for ($i = 0; $i < abs($num_to_checkin_at_this_time); $i++) { | 
                                                        |
| 58 | + $new_reg_id = $new_registrations_for_attendee[$i];  | 
                                                        |
| 59 | +            if ( ! $new_reg_id) { | 
                                                        |
| 60 | 60 | $this->add_error(sprintf(  | 
                                                        
| 61 | 61 | esc_html__(  | 
                                                        
| 62 | 62 | /* translators: %1$s database row represented in JSON, %2$s number of registrations to check-in  | 
                                                        
@@ -80,10 +80,10 @@ discard block  | 
                                                    ||
| 80 | 80 | $new_reg_id  | 
                                                        
| 81 | 81 | )  | 
                                                        
| 82 | 82 | );  | 
                                                        
| 83 | -            if (! $existing_checkin_record) { | 
                                                        |
| 83 | +            if ( ! $existing_checkin_record) { | 
                                                        |
| 84 | 84 | $new_id = $this->_insert_checkin_record($new_reg_id, $new_datetime);  | 
                                                        
| 85 | 85 |                  if ($new_id) { | 
                                                        
| 86 | - $new_checkin_ids[]= $new_id;  | 
                                                        |
| 86 | + $new_checkin_ids[] = $new_id;  | 
                                                        |
| 87 | 87 | }  | 
                                                        
| 88 | 88 | }  | 
                                                        
| 89 | 89 | }  | 
                                                        
@@ -111,7 +111,7 @@ discard block  | 
                                                    ||
| 111 | 111 | global $wpdb;  | 
                                                        
| 112 | 112 | |
| 113 | 113 | $new_event_id = $this->get_migration_script()->get_mapping_new_pk($wpdb->prefix."events_detail", $old_attendee['event_id'], $wpdb->posts);  | 
                                                        
| 114 | -        if (! $new_event_id) { | 
                                                        |
| 114 | +        if ( ! $new_event_id) { | 
                                                        |
| 115 | 115 | $this->add_error(  | 
                                                        
| 116 | 116 | sprintf(  | 
                                                        
| 117 | 117 | esc_html__(  | 
                                                        
@@ -135,8 +135,8 @@ discard block  | 
                                                    ||
| 135 | 135 | // add all conditions to an array from which we can SHIFT conditions off in order to widen our search  | 
                                                        
| 136 | 136 | // the most important condition should be last, as it will be array_shift'ed off last  | 
                                                        
| 137 | 137 | $conditions = array(  | 
                                                        
| 138 | -            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime),// times match? | 
                                                        |
| 139 | -            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id),// events match? | 
                                                        |
| 138 | +            $wpdb->prepare("$datetime_table.DTT_EVT_start = %s", $old_att_datetime), // times match? | 
                                                        |
| 139 | +            $wpdb->prepare("$datetime_table.EVT_ID = %d", $new_event_id), // events match? | 
                                                        |
| 140 | 140 | );  | 
                                                        
| 141 | 141 | // start running queries, widening search each time by removing a condition  | 
                                                        
| 142 | 142 | $datetime_found = null;  | 
                                                        
@@ -144,7 +144,7 @@ discard block  | 
                                                    ||
| 144 | 144 |              $full_query = "SELECT * FROM $datetime_table WHERE ".implode(" AND ", $conditions)." LIMIT 1"; | 
                                                        
| 145 | 145 | $datetime_found = $wpdb->get_row($full_query, ARRAY_A);  | 
                                                        
| 146 | 146 | array_shift($conditions);  | 
                                                        
| 147 | - } while (! $datetime_found && $conditions);  | 
                                                        |
| 147 | + }while ( ! $datetime_found && $conditions);  | 
                                                        |
| 148 | 148 | return $datetime_found;  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 | |
@@ -168,13 +168,13 @@ discard block  | 
                                                    ||
| 168 | 168 | 'CHK_timestamp'=>$new_datetime['DTT_EVT_start']  | 
                                                        
| 169 | 169 | );  | 
                                                        
| 170 | 170 | $datatypes = array(  | 
                                                        
| 171 | - '%d',// REG_ID  | 
                                                        |
| 172 | - '%d',// DTT_ID  | 
                                                        |
| 173 | - '%d',// CHK_in  | 
                                                        |
| 174 | - '%s',// CHK_timestamp  | 
                                                        |
| 171 | + '%d', // REG_ID  | 
                                                        |
| 172 | + '%d', // DTT_ID  | 
                                                        |
| 173 | + '%d', // CHK_in  | 
                                                        |
| 174 | + '%s', // CHK_timestamp  | 
                                                        |
| 175 | 175 | );  | 
                                                        
| 176 | 176 | $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes);  | 
                                                        
| 177 | -        if (! $success) { | 
                                                        |
| 177 | +        if ( ! $success) { | 
                                                        |
| 178 | 178 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_checkin, $this->_new_table, $cols_n_values, $datatypes));  | 
                                                        
| 179 | 179 | return 0;  | 
                                                        
| 180 | 180 | }  | 
                                                        
@@ -20,488 +20,488 @@ discard block  | 
                                                    ||
| 20 | 20 | final class EE_Admin implements InterminableInterface  | 
                                                        
| 21 | 21 |  { | 
                                                        
| 22 | 22 | |
| 23 | - /**  | 
                                                        |
| 24 | - * @var EE_Admin $_instance  | 
                                                        |
| 25 | - */  | 
                                                        |
| 26 | - private static $_instance;  | 
                                                        |
| 27 | -  | 
                                                        |
| 28 | - /**  | 
                                                        |
| 29 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager  | 
                                                        |
| 30 | - */  | 
                                                        |
| 31 | - private $persistent_admin_notice_manager;  | 
                                                        |
| 32 | -  | 
                                                        |
| 33 | - /**  | 
                                                        |
| 34 | - * @var LoaderInterface  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - protected $loader;  | 
                                                        |
| 37 | -  | 
                                                        |
| 38 | - /**  | 
                                                        |
| 39 | - * @singleton method used to instantiate class object  | 
                                                        |
| 40 | - * @return EE_Admin  | 
                                                        |
| 41 | - * @throws EE_Error  | 
                                                        |
| 42 | - */  | 
                                                        |
| 43 | - public static function instance()  | 
                                                        |
| 44 | -    { | 
                                                        |
| 45 | - // check if class object is instantiated  | 
                                                        |
| 46 | -        if (! self::$_instance instanceof EE_Admin) { | 
                                                        |
| 47 | - self::$_instance = new self();  | 
                                                        |
| 48 | - }  | 
                                                        |
| 49 | - return self::$_instance;  | 
                                                        |
| 50 | - }  | 
                                                        |
| 51 | -  | 
                                                        |
| 52 | -  | 
                                                        |
| 53 | - /**  | 
                                                        |
| 54 | - * @return EE_Admin  | 
                                                        |
| 55 | - * @throws EE_Error  | 
                                                        |
| 56 | - */  | 
                                                        |
| 57 | - public static function reset()  | 
                                                        |
| 58 | -    { | 
                                                        |
| 59 | - self::$_instance = null;  | 
                                                        |
| 60 | - return self::instance();  | 
                                                        |
| 61 | - }  | 
                                                        |
| 62 | -  | 
                                                        |
| 63 | -  | 
                                                        |
| 64 | - /**  | 
                                                        |
| 65 | - * class constructor  | 
                                                        |
| 66 | - *  | 
                                                        |
| 67 | - * @throws EE_Error  | 
                                                        |
| 68 | - * @throws InvalidDataTypeException  | 
                                                        |
| 69 | - * @throws InvalidInterfaceException  | 
                                                        |
| 70 | - * @throws InvalidArgumentException  | 
                                                        |
| 71 | - */  | 
                                                        |
| 72 | - protected function __construct()  | 
                                                        |
| 73 | -    { | 
                                                        |
| 74 | - // define global EE_Admin constants  | 
                                                        |
| 75 | - $this->_define_all_constants();  | 
                                                        |
| 76 | - // set autoloaders for our admin page classes based on included path information  | 
                                                        |
| 77 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);  | 
                                                        |
| 78 | - // admin hooks  | 
                                                        |
| 79 | -        add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); | 
                                                        |
| 80 | - // load EE_Request_Handler early  | 
                                                        |
| 81 | -        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); | 
                                                        |
| 82 | -        add_action('AHEE__EE_System__initialize_last', array($this, 'init')); | 
                                                        |
| 83 | -        add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); | 
                                                        |
| 84 | -        add_action('wp_loaded', array($this, 'wp_loaded'), 100); | 
                                                        |
| 85 | -        add_action('admin_init', array($this, 'admin_init'), 100); | 
                                                        |
| 86 | -        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); | 
                                                        |
| 87 | -        add_action('admin_notices', array($this, 'display_admin_notices'), 10); | 
                                                        |
| 88 | -        add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); | 
                                                        |
| 89 | -        add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); | 
                                                        |
| 90 | -        add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); | 
                                                        |
| 91 | -        add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); | 
                                                        |
| 92 | -        add_action('display_post_states', array($this, 'displayStateForCriticalPages'), 10, 2); | 
                                                        |
| 93 | -        add_filter('plugin_row_meta', array($this, 'addLinksToPluginRowMeta'), 10, 2); | 
                                                        |
| 94 | - // reset Environment config (we only do this on admin page loads);  | 
                                                        |
| 95 | - EE_Registry::instance()->CFG->environment->recheck_values();  | 
                                                        |
| 96 | -        do_action('AHEE__EE_Admin__loaded'); | 
                                                        |
| 97 | - }  | 
                                                        |
| 98 | -  | 
                                                        |
| 99 | -  | 
                                                        |
| 100 | - /**  | 
                                                        |
| 101 | - * _define_all_constants  | 
                                                        |
| 102 | - * define constants that are set globally for all admin pages  | 
                                                        |
| 103 | - *  | 
                                                        |
| 104 | - * @return void  | 
                                                        |
| 105 | - */  | 
                                                        |
| 106 | - private function _define_all_constants()  | 
                                                        |
| 107 | -    { | 
                                                        |
| 108 | -        if (! defined('EE_ADMIN_URL')) { | 
                                                        |
| 109 | -            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); | 
                                                        |
| 110 | -            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); | 
                                                        |
| 111 | -            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); | 
                                                        |
| 112 | -            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); | 
                                                        |
| 113 | -            define('WP_AJAX_URL', admin_url('admin-ajax.php')); | 
                                                        |
| 114 | - }  | 
                                                        |
| 115 | - }  | 
                                                        |
| 116 | -  | 
                                                        |
| 117 | -  | 
                                                        |
| 118 | - /**  | 
                                                        |
| 119 | - * filter_plugin_actions - adds links to the Plugins page listing  | 
                                                        |
| 120 | - *  | 
                                                        |
| 121 | - * @param array $links  | 
                                                        |
| 122 | - * @param string $plugin  | 
                                                        |
| 123 | - * @return array  | 
                                                        |
| 124 | - */  | 
                                                        |
| 125 | - public function filter_plugin_actions($links, $plugin)  | 
                                                        |
| 126 | -    { | 
                                                        |
| 127 | - // set $main_file in stone  | 
                                                        |
| 128 | - static $main_file;  | 
                                                        |
| 129 | - // if $main_file is not set yet  | 
                                                        |
| 130 | -        if (! $main_file) { | 
                                                        |
| 131 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);  | 
                                                        |
| 132 | - }  | 
                                                        |
| 133 | -        if ($plugin === $main_file) { | 
                                                        |
| 134 | - // compare current plugin to this one  | 
                                                        |
| 135 | -            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { | 
                                                        |
| 136 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'  | 
                                                        |
| 137 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">'  | 
                                                        |
| 138 | -                                    . esc_html__('Maintenance Mode Active', 'event_espresso') | 
                                                        |
| 139 | - . '</a>';  | 
                                                        |
| 140 | - array_unshift($links, $maintenance_link);  | 
                                                        |
| 141 | -            } else { | 
                                                        |
| 142 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'  | 
                                                        |
| 143 | -                                     . esc_html__('Settings', 'event_espresso') | 
                                                        |
| 144 | - . '</a>';  | 
                                                        |
| 145 | - $events_link = '<a href="admin.php?page=espresso_events">'  | 
                                                        |
| 146 | -                               . esc_html__('Events', 'event_espresso') | 
                                                        |
| 147 | - . '</a>';  | 
                                                        |
| 148 | - // add before other links  | 
                                                        |
| 149 | - array_unshift($links, $org_settings_link, $events_link);  | 
                                                        |
| 150 | - }  | 
                                                        |
| 151 | - }  | 
                                                        |
| 152 | - return $links;  | 
                                                        |
| 153 | - }  | 
                                                        |
| 154 | -  | 
                                                        |
| 155 | -  | 
                                                        |
| 156 | - /**  | 
                                                        |
| 157 | - * _get_request  | 
                                                        |
| 158 | - *  | 
                                                        |
| 159 | - * @return void  | 
                                                        |
| 160 | - * @throws EE_Error  | 
                                                        |
| 161 | - * @throws InvalidArgumentException  | 
                                                        |
| 162 | - * @throws InvalidDataTypeException  | 
                                                        |
| 163 | - * @throws InvalidInterfaceException  | 
                                                        |
| 164 | - * @throws ReflectionException  | 
                                                        |
| 165 | - */  | 
                                                        |
| 166 | - public function get_request()  | 
                                                        |
| 167 | -    { | 
                                                        |
| 168 | -        EE_Registry::instance()->load_core('Request_Handler'); | 
                                                        |
| 169 | - }  | 
                                                        |
| 170 | -  | 
                                                        |
| 171 | -  | 
                                                        |
| 172 | - /**  | 
                                                        |
| 173 | - * hide_admin_pages_except_maintenance_mode  | 
                                                        |
| 174 | - *  | 
                                                        |
| 175 | - * @param array $admin_page_folder_names  | 
                                                        |
| 176 | - * @return array  | 
                                                        |
| 177 | - */  | 
                                                        |
| 178 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())  | 
                                                        |
| 179 | -    { | 
                                                        |
| 180 | - return array(  | 
                                                        |
| 181 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,  | 
                                                        |
| 182 | - 'about' => EE_ADMIN_PAGES . 'about' . DS,  | 
                                                        |
| 183 | - 'support' => EE_ADMIN_PAGES . 'support' . DS,  | 
                                                        |
| 184 | - );  | 
                                                        |
| 185 | - }  | 
                                                        |
| 186 | -  | 
                                                        |
| 187 | -  | 
                                                        |
| 188 | - /**  | 
                                                        |
| 189 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even  | 
                                                        |
| 190 | - * EE_Front_Controller's init phases have run  | 
                                                        |
| 191 | - *  | 
                                                        |
| 192 | - * @return void  | 
                                                        |
| 193 | - * @throws EE_Error  | 
                                                        |
| 194 | - * @throws InvalidArgumentException  | 
                                                        |
| 195 | - * @throws InvalidDataTypeException  | 
                                                        |
| 196 | - * @throws InvalidInterfaceException  | 
                                                        |
| 197 | - * @throws ReflectionException  | 
                                                        |
| 198 | - * @throws ServiceNotFoundException  | 
                                                        |
| 199 | - */  | 
                                                        |
| 200 | - public function init()  | 
                                                        |
| 201 | -    { | 
                                                        |
| 202 | - // only enable most of the EE_Admin IF we're not in full maintenance mode  | 
                                                        |
| 203 | -        if (EE_Maintenance_Mode::instance()->models_can_query()) { | 
                                                        |
| 204 | - $this->initModelsReady();  | 
                                                        |
| 205 | - }  | 
                                                        |
| 206 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request  | 
                                                        |
| 207 | -        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { | 
                                                        |
| 208 | -            try { | 
                                                        |
| 209 | - // this loads the controller for the admin pages which will setup routing etc  | 
                                                        |
| 210 | -                EE_Registry::instance()->load_core('Admin_Page_Loader'); | 
                                                        |
| 211 | -            } catch (EE_Error $e) { | 
                                                        |
| 212 | - $e->get_error();  | 
                                                        |
| 213 | - }  | 
                                                        |
| 214 | - }  | 
                                                        |
| 215 | -        add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); | 
                                                        |
| 216 | - // make sure our CPTs and custom taxonomy metaboxes get shown for first time users  | 
                                                        |
| 217 | -        add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); | 
                                                        |
| 218 | -        add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); | 
                                                        |
| 219 | - // exclude EE critical pages from all nav menus and wp_list_pages  | 
                                                        |
| 220 | -        add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); | 
                                                        |
| 221 | - }  | 
                                                        |
| 222 | -  | 
                                                        |
| 223 | -  | 
                                                        |
| 224 | - /**  | 
                                                        |
| 225 | - * Gets the loader (and if it wasn't previously set, sets it)  | 
                                                        |
| 226 | - * @return LoaderInterface  | 
                                                        |
| 227 | - * @throws InvalidArgumentException  | 
                                                        |
| 228 | - * @throws InvalidDataTypeException  | 
                                                        |
| 229 | - * @throws InvalidInterfaceException  | 
                                                        |
| 230 | - */  | 
                                                        |
| 231 | - protected function getLoader()  | 
                                                        |
| 232 | -    { | 
                                                        |
| 233 | -        if (! $this->loader instanceof LoaderInterface) { | 
                                                        |
| 234 | - $this->loader = LoaderFactory::getLoader();  | 
                                                        |
| 235 | - }  | 
                                                        |
| 236 | - return $this->loader;  | 
                                                        |
| 237 | - }  | 
                                                        |
| 238 | -  | 
                                                        |
| 239 | -  | 
                                                        |
| 240 | - /**  | 
                                                        |
| 241 | - * Method that's fired on admin requests (including admin ajax) but only when the models are usable  | 
                                                        |
| 242 | - * (ie, the site isn't in maintenance mode)  | 
                                                        |
| 243 | - * @since 4.9.63.p  | 
                                                        |
| 244 | - * @return void  | 
                                                        |
| 245 | - */  | 
                                                        |
| 246 | - protected function initModelsReady()  | 
                                                        |
| 247 | -    { | 
                                                        |
| 248 | - // ok so we want to enable the entire admin  | 
                                                        |
| 249 | - $this->persistent_admin_notice_manager = $this->getLoader()->getShared(  | 
                                                        |
| 250 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 251 | - );  | 
                                                        |
| 252 | - $this->persistent_admin_notice_manager->setReturnUrl(  | 
                                                        |
| 253 | - EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 254 | - array(  | 
                                                        |
| 255 | -                    'page'   => EE_Registry::instance()->REQ->get('page', ''), | 
                                                        |
| 256 | -                    'action' => EE_Registry::instance()->REQ->get('action', ''), | 
                                                        |
| 257 | - ),  | 
                                                        |
| 258 | - EE_ADMIN_URL  | 
                                                        |
| 259 | - )  | 
                                                        |
| 260 | - );  | 
                                                        |
| 261 | - $this->maybeSetDatetimeWarningNotice();  | 
                                                        |
| 262 | - // at a glance dashboard widget  | 
                                                        |
| 263 | -        add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); | 
                                                        |
| 264 | - // filter for get_edit_post_link used on comments for custom post types  | 
                                                        |
| 265 | -        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); | 
                                                        |
| 266 | - }  | 
                                                        |
| 267 | -  | 
                                                        |
| 268 | -  | 
                                                        |
| 269 | - /**  | 
                                                        |
| 270 | - * get_persistent_admin_notices  | 
                                                        |
| 271 | - *  | 
                                                        |
| 272 | - * @access public  | 
                                                        |
| 273 | - * @return void  | 
                                                        |
| 274 | - * @throws EE_Error  | 
                                                        |
| 275 | - * @throws InvalidArgumentException  | 
                                                        |
| 276 | - * @throws InvalidDataTypeException  | 
                                                        |
| 277 | - * @throws InvalidInterfaceException  | 
                                                        |
| 278 | - */  | 
                                                        |
| 279 | - public function maybeSetDatetimeWarningNotice()  | 
                                                        |
| 280 | -    { | 
                                                        |
| 281 | - // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set.  | 
                                                        |
| 282 | - // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version  | 
                                                        |
| 283 | - // with this. But after enough time (indeterminate at this point) we can just remove this notice.  | 
                                                        |
| 284 | - // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626  | 
                                                        |
| 285 | -        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) | 
                                                        |
| 286 | -            && ! get_option('timezone_string') | 
                                                        |
| 287 | - && EEM_Event::instance()->count() > 0  | 
                                                        |
| 288 | -        ) { | 
                                                        |
| 289 | - new PersistentAdminNotice(  | 
                                                        |
| 290 | - 'datetime_fix_notice',  | 
                                                        |
| 291 | - sprintf(  | 
                                                        |
| 292 | - esc_html__(  | 
                                                        |
| 293 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',  | 
                                                        |
| 294 | - 'event_espresso'  | 
                                                        |
| 295 | - ),  | 
                                                        |
| 296 | - '<strong>',  | 
                                                        |
| 297 | - '</strong>',  | 
                                                        |
| 298 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',  | 
                                                        |
| 299 | - '</a>',  | 
                                                        |
| 300 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 301 | - array(  | 
                                                        |
| 302 | - 'page' => 'espresso_maintenance_settings',  | 
                                                        |
| 303 | - 'action' => 'datetime_tools',  | 
                                                        |
| 304 | - ),  | 
                                                        |
| 305 | -                        admin_url('admin.php') | 
                                                        |
| 306 | - ) . '">'  | 
                                                        |
| 307 | - ),  | 
                                                        |
| 308 | - false,  | 
                                                        |
| 309 | - 'manage_options',  | 
                                                        |
| 310 | - 'datetime_fix_persistent_notice'  | 
                                                        |
| 311 | - );  | 
                                                        |
| 312 | - }  | 
                                                        |
| 313 | - }  | 
                                                        |
| 314 | -  | 
                                                        |
| 315 | -  | 
                                                        |
| 316 | - /**  | 
                                                        |
| 317 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from  | 
                                                        |
| 318 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in  | 
                                                        |
| 319 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that  | 
                                                        |
| 320 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a  | 
                                                        |
| 321 | - * normal property on the post_type object. It's found ONLY in this particular context.  | 
                                                        |
| 322 | - *  | 
                                                        |
| 323 | - * @param WP_Post $post_type WP post type object  | 
                                                        |
| 324 | - * @return WP_Post  | 
                                                        |
| 325 | - * @throws InvalidArgumentException  | 
                                                        |
| 326 | - * @throws InvalidDataTypeException  | 
                                                        |
| 327 | - * @throws InvalidInterfaceException  | 
                                                        |
| 328 | - */  | 
                                                        |
| 329 | - public function remove_pages_from_nav_menu($post_type)  | 
                                                        |
| 330 | -    { | 
                                                        |
| 331 | - // if this isn't the "pages" post type let's get out  | 
                                                        |
| 332 | -        if ($post_type->name !== 'page') { | 
                                                        |
| 333 | - return $post_type;  | 
                                                        |
| 334 | - }  | 
                                                        |
| 335 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();  | 
                                                        |
| 336 | - $post_type->_default_query = array(  | 
                                                        |
| 337 | - 'post__not_in' => $critical_pages,  | 
                                                        |
| 338 | - );  | 
                                                        |
| 339 | - return $post_type;  | 
                                                        |
| 340 | - }  | 
                                                        |
| 341 | -  | 
                                                        |
| 342 | -  | 
                                                        |
| 343 | - /**  | 
                                                        |
| 344 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our  | 
                                                        |
| 345 | - * metaboxes get shown as well  | 
                                                        |
| 346 | - *  | 
                                                        |
| 347 | - * @return void  | 
                                                        |
| 348 | - */  | 
                                                        |
| 349 | - public function enable_hidden_ee_nav_menu_metaboxes()  | 
                                                        |
| 350 | -    { | 
                                                        |
| 351 | - global $wp_meta_boxes, $pagenow;  | 
                                                        |
| 352 | -        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { | 
                                                        |
| 353 | - return;  | 
                                                        |
| 354 | - }  | 
                                                        |
| 355 | - $user = wp_get_current_user();  | 
                                                        |
| 356 | - // has this been done yet?  | 
                                                        |
| 357 | -        if (get_user_option('ee_nav_menu_initialized', $user->ID)) { | 
                                                        |
| 358 | - return;  | 
                                                        |
| 359 | - }  | 
                                                        |
| 360 | -  | 
                                                        |
| 361 | -        $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); | 
                                                        |
| 362 | - $initial_meta_boxes = apply_filters(  | 
                                                        |
| 363 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',  | 
                                                        |
| 364 | - array(  | 
                                                        |
| 365 | - 'nav-menu-theme-locations',  | 
                                                        |
| 366 | - 'add-page',  | 
                                                        |
| 367 | - 'add-custom-links',  | 
                                                        |
| 368 | - 'add-category',  | 
                                                        |
| 369 | - 'add-espresso_events',  | 
                                                        |
| 370 | - 'add-espresso_venues',  | 
                                                        |
| 371 | - 'add-espresso_event_categories',  | 
                                                        |
| 372 | - 'add-espresso_venue_categories',  | 
                                                        |
| 373 | - 'add-post-type-post',  | 
                                                        |
| 374 | - 'add-post-type-page',  | 
                                                        |
| 375 | - )  | 
                                                        |
| 376 | - );  | 
                                                        |
| 377 | -  | 
                                                        |
| 378 | -        if (is_array($hidden_meta_boxes)) { | 
                                                        |
| 379 | -            foreach ($hidden_meta_boxes as $key => $meta_box_id) { | 
                                                        |
| 380 | -                if (in_array($meta_box_id, $initial_meta_boxes, true)) { | 
                                                        |
| 381 | - unset($hidden_meta_boxes[ $key ]);  | 
                                                        |
| 382 | - }  | 
                                                        |
| 383 | - }  | 
                                                        |
| 384 | - }  | 
                                                        |
| 385 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);  | 
                                                        |
| 386 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);  | 
                                                        |
| 387 | - }  | 
                                                        |
| 388 | -  | 
                                                        |
| 389 | -  | 
                                                        |
| 390 | - /**  | 
                                                        |
| 391 | - * This method simply registers custom nav menu boxes for "nav_menus.php route"  | 
                                                        |
| 392 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes.  | 
                                                        |
| 393 | - *  | 
                                                        |
| 394 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by  | 
                                                        |
| 395 | - * addons etc.  | 
                                                        |
| 396 | - * @return void  | 
                                                        |
| 397 | - */  | 
                                                        |
| 398 | - public function register_custom_nav_menu_boxes()  | 
                                                        |
| 399 | -    { | 
                                                        |
| 400 | - add_meta_box(  | 
                                                        |
| 401 | - 'add-extra-nav-menu-pages',  | 
                                                        |
| 402 | -            esc_html__('Event Espresso Pages', 'event_espresso'), | 
                                                        |
| 403 | - array($this, 'ee_cpt_archive_pages'),  | 
                                                        |
| 404 | - 'nav-menus',  | 
                                                        |
| 405 | - 'side',  | 
                                                        |
| 406 | - 'core'  | 
                                                        |
| 407 | - );  | 
                                                        |
| 408 | - }  | 
                                                        |
| 409 | -  | 
                                                        |
| 410 | -  | 
                                                        |
| 411 | - /**  | 
                                                        |
| 412 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page.  | 
                                                        |
| 413 | - *  | 
                                                        |
| 414 | - * @since 4.3.0  | 
                                                        |
| 415 | - * @param string $link the original link generated by wp  | 
                                                        |
| 416 | - * @param int $id post id  | 
                                                        |
| 417 | - * @return string the (maybe) modified link  | 
                                                        |
| 418 | - */  | 
                                                        |
| 419 | - public function modify_edit_post_link($link, $id)  | 
                                                        |
| 420 | -    { | 
                                                        |
| 421 | -        if (! $post = get_post($id)) { | 
                                                        |
| 422 | - return $link;  | 
                                                        |
| 423 | - }  | 
                                                        |
| 424 | -        if ($post->post_type === 'espresso_attendees') { | 
                                                        |
| 425 | - $query_args = array(  | 
                                                        |
| 426 | - 'action' => 'edit_attendee',  | 
                                                        |
| 427 | - 'post' => $id,  | 
                                                        |
| 428 | - );  | 
                                                        |
| 429 | - return EEH_URL::add_query_args_and_nonce(  | 
                                                        |
| 430 | - $query_args,  | 
                                                        |
| 431 | -                admin_url('admin.php?page=espresso_registrations') | 
                                                        |
| 432 | - );  | 
                                                        |
| 433 | - }  | 
                                                        |
| 434 | - return $link;  | 
                                                        |
| 435 | - }  | 
                                                        |
| 436 | -  | 
                                                        |
| 437 | -  | 
                                                        |
| 438 | - public function ee_cpt_archive_pages()  | 
                                                        |
| 439 | -    { | 
                                                        |
| 440 | - global $nav_menu_selected_id;  | 
                                                        |
| 441 | - $db_fields = false;  | 
                                                        |
| 442 | - $walker = new Walker_Nav_Menu_Checklist($db_fields);  | 
                                                        |
| 443 | - $current_tab = 'event-archives';  | 
                                                        |
| 444 | - $removed_args = array(  | 
                                                        |
| 445 | - 'action',  | 
                                                        |
| 446 | - 'customlink-tab',  | 
                                                        |
| 447 | - 'edit-menu-item',  | 
                                                        |
| 448 | - 'menu-item',  | 
                                                        |
| 449 | - 'page-tab',  | 
                                                        |
| 450 | - '_wpnonce',  | 
                                                        |
| 451 | - );  | 
                                                        |
| 452 | - ?>  | 
                                                        |
| 23 | + /**  | 
                                                        |
| 24 | + * @var EE_Admin $_instance  | 
                                                        |
| 25 | + */  | 
                                                        |
| 26 | + private static $_instance;  | 
                                                        |
| 27 | +  | 
                                                        |
| 28 | + /**  | 
                                                        |
| 29 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager  | 
                                                        |
| 30 | + */  | 
                                                        |
| 31 | + private $persistent_admin_notice_manager;  | 
                                                        |
| 32 | +  | 
                                                        |
| 33 | + /**  | 
                                                        |
| 34 | + * @var LoaderInterface  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + protected $loader;  | 
                                                        |
| 37 | +  | 
                                                        |
| 38 | + /**  | 
                                                        |
| 39 | + * @singleton method used to instantiate class object  | 
                                                        |
| 40 | + * @return EE_Admin  | 
                                                        |
| 41 | + * @throws EE_Error  | 
                                                        |
| 42 | + */  | 
                                                        |
| 43 | + public static function instance()  | 
                                                        |
| 44 | +	{ | 
                                                        |
| 45 | + // check if class object is instantiated  | 
                                                        |
| 46 | +		if (! self::$_instance instanceof EE_Admin) { | 
                                                        |
| 47 | + self::$_instance = new self();  | 
                                                        |
| 48 | + }  | 
                                                        |
| 49 | + return self::$_instance;  | 
                                                        |
| 50 | + }  | 
                                                        |
| 51 | +  | 
                                                        |
| 52 | +  | 
                                                        |
| 53 | + /**  | 
                                                        |
| 54 | + * @return EE_Admin  | 
                                                        |
| 55 | + * @throws EE_Error  | 
                                                        |
| 56 | + */  | 
                                                        |
| 57 | + public static function reset()  | 
                                                        |
| 58 | +	{ | 
                                                        |
| 59 | + self::$_instance = null;  | 
                                                        |
| 60 | + return self::instance();  | 
                                                        |
| 61 | + }  | 
                                                        |
| 62 | +  | 
                                                        |
| 63 | +  | 
                                                        |
| 64 | + /**  | 
                                                        |
| 65 | + * class constructor  | 
                                                        |
| 66 | + *  | 
                                                        |
| 67 | + * @throws EE_Error  | 
                                                        |
| 68 | + * @throws InvalidDataTypeException  | 
                                                        |
| 69 | + * @throws InvalidInterfaceException  | 
                                                        |
| 70 | + * @throws InvalidArgumentException  | 
                                                        |
| 71 | + */  | 
                                                        |
| 72 | + protected function __construct()  | 
                                                        |
| 73 | +	{ | 
                                                        |
| 74 | + // define global EE_Admin constants  | 
                                                        |
| 75 | + $this->_define_all_constants();  | 
                                                        |
| 76 | + // set autoloaders for our admin page classes based on included path information  | 
                                                        |
| 77 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);  | 
                                                        |
| 78 | + // admin hooks  | 
                                                        |
| 79 | +		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2); | 
                                                        |
| 80 | + // load EE_Request_Handler early  | 
                                                        |
| 81 | +		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request')); | 
                                                        |
| 82 | +		add_action('AHEE__EE_System__initialize_last', array($this, 'init')); | 
                                                        |
| 83 | +		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2); | 
                                                        |
| 84 | +		add_action('wp_loaded', array($this, 'wp_loaded'), 100); | 
                                                        |
| 85 | +		add_action('admin_init', array($this, 'admin_init'), 100); | 
                                                        |
| 86 | +		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20); | 
                                                        |
| 87 | +		add_action('admin_notices', array($this, 'display_admin_notices'), 10); | 
                                                        |
| 88 | +		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); | 
                                                        |
| 89 | +		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); | 
                                                        |
| 90 | +		add_filter('admin_footer_text', array($this, 'espresso_admin_footer')); | 
                                                        |
| 91 | +		add_action('load-plugins.php', array($this, 'hookIntoWpPluginsPage')); | 
                                                        |
| 92 | +		add_action('display_post_states', array($this, 'displayStateForCriticalPages'), 10, 2); | 
                                                        |
| 93 | +		add_filter('plugin_row_meta', array($this, 'addLinksToPluginRowMeta'), 10, 2); | 
                                                        |
| 94 | + // reset Environment config (we only do this on admin page loads);  | 
                                                        |
| 95 | + EE_Registry::instance()->CFG->environment->recheck_values();  | 
                                                        |
| 96 | +		do_action('AHEE__EE_Admin__loaded'); | 
                                                        |
| 97 | + }  | 
                                                        |
| 98 | +  | 
                                                        |
| 99 | +  | 
                                                        |
| 100 | + /**  | 
                                                        |
| 101 | + * _define_all_constants  | 
                                                        |
| 102 | + * define constants that are set globally for all admin pages  | 
                                                        |
| 103 | + *  | 
                                                        |
| 104 | + * @return void  | 
                                                        |
| 105 | + */  | 
                                                        |
| 106 | + private function _define_all_constants()  | 
                                                        |
| 107 | +	{ | 
                                                        |
| 108 | +		if (! defined('EE_ADMIN_URL')) { | 
                                                        |
| 109 | +			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); | 
                                                        |
| 110 | +			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); | 
                                                        |
| 111 | +			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS); | 
                                                        |
| 112 | +			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); | 
                                                        |
| 113 | +			define('WP_AJAX_URL', admin_url('admin-ajax.php')); | 
                                                        |
| 114 | + }  | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | +  | 
                                                        |
| 117 | +  | 
                                                        |
| 118 | + /**  | 
                                                        |
| 119 | + * filter_plugin_actions - adds links to the Plugins page listing  | 
                                                        |
| 120 | + *  | 
                                                        |
| 121 | + * @param array $links  | 
                                                        |
| 122 | + * @param string $plugin  | 
                                                        |
| 123 | + * @return array  | 
                                                        |
| 124 | + */  | 
                                                        |
| 125 | + public function filter_plugin_actions($links, $plugin)  | 
                                                        |
| 126 | +	{ | 
                                                        |
| 127 | + // set $main_file in stone  | 
                                                        |
| 128 | + static $main_file;  | 
                                                        |
| 129 | + // if $main_file is not set yet  | 
                                                        |
| 130 | +		if (! $main_file) { | 
                                                        |
| 131 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);  | 
                                                        |
| 132 | + }  | 
                                                        |
| 133 | +		if ($plugin === $main_file) { | 
                                                        |
| 134 | + // compare current plugin to this one  | 
                                                        |
| 135 | +			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { | 
                                                        |
| 136 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'  | 
                                                        |
| 137 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">'  | 
                                                        |
| 138 | +									. esc_html__('Maintenance Mode Active', 'event_espresso') | 
                                                        |
| 139 | + . '</a>';  | 
                                                        |
| 140 | + array_unshift($links, $maintenance_link);  | 
                                                        |
| 141 | +			} else { | 
                                                        |
| 142 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'  | 
                                                        |
| 143 | +									 . esc_html__('Settings', 'event_espresso') | 
                                                        |
| 144 | + . '</a>';  | 
                                                        |
| 145 | + $events_link = '<a href="admin.php?page=espresso_events">'  | 
                                                        |
| 146 | +							   . esc_html__('Events', 'event_espresso') | 
                                                        |
| 147 | + . '</a>';  | 
                                                        |
| 148 | + // add before other links  | 
                                                        |
| 149 | + array_unshift($links, $org_settings_link, $events_link);  | 
                                                        |
| 150 | + }  | 
                                                        |
| 151 | + }  | 
                                                        |
| 152 | + return $links;  | 
                                                        |
| 153 | + }  | 
                                                        |
| 154 | +  | 
                                                        |
| 155 | +  | 
                                                        |
| 156 | + /**  | 
                                                        |
| 157 | + * _get_request  | 
                                                        |
| 158 | + *  | 
                                                        |
| 159 | + * @return void  | 
                                                        |
| 160 | + * @throws EE_Error  | 
                                                        |
| 161 | + * @throws InvalidArgumentException  | 
                                                        |
| 162 | + * @throws InvalidDataTypeException  | 
                                                        |
| 163 | + * @throws InvalidInterfaceException  | 
                                                        |
| 164 | + * @throws ReflectionException  | 
                                                        |
| 165 | + */  | 
                                                        |
| 166 | + public function get_request()  | 
                                                        |
| 167 | +	{ | 
                                                        |
| 168 | +		EE_Registry::instance()->load_core('Request_Handler'); | 
                                                        |
| 169 | + }  | 
                                                        |
| 170 | +  | 
                                                        |
| 171 | +  | 
                                                        |
| 172 | + /**  | 
                                                        |
| 173 | + * hide_admin_pages_except_maintenance_mode  | 
                                                        |
| 174 | + *  | 
                                                        |
| 175 | + * @param array $admin_page_folder_names  | 
                                                        |
| 176 | + * @return array  | 
                                                        |
| 177 | + */  | 
                                                        |
| 178 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array())  | 
                                                        |
| 179 | +	{ | 
                                                        |
| 180 | + return array(  | 
                                                        |
| 181 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,  | 
                                                        |
| 182 | + 'about' => EE_ADMIN_PAGES . 'about' . DS,  | 
                                                        |
| 183 | + 'support' => EE_ADMIN_PAGES . 'support' . DS,  | 
                                                        |
| 184 | + );  | 
                                                        |
| 185 | + }  | 
                                                        |
| 186 | +  | 
                                                        |
| 187 | +  | 
                                                        |
| 188 | + /**  | 
                                                        |
| 189 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even  | 
                                                        |
| 190 | + * EE_Front_Controller's init phases have run  | 
                                                        |
| 191 | + *  | 
                                                        |
| 192 | + * @return void  | 
                                                        |
| 193 | + * @throws EE_Error  | 
                                                        |
| 194 | + * @throws InvalidArgumentException  | 
                                                        |
| 195 | + * @throws InvalidDataTypeException  | 
                                                        |
| 196 | + * @throws InvalidInterfaceException  | 
                                                        |
| 197 | + * @throws ReflectionException  | 
                                                        |
| 198 | + * @throws ServiceNotFoundException  | 
                                                        |
| 199 | + */  | 
                                                        |
| 200 | + public function init()  | 
                                                        |
| 201 | +	{ | 
                                                        |
| 202 | + // only enable most of the EE_Admin IF we're not in full maintenance mode  | 
                                                        |
| 203 | +		if (EE_Maintenance_Mode::instance()->models_can_query()) { | 
                                                        |
| 204 | + $this->initModelsReady();  | 
                                                        |
| 205 | + }  | 
                                                        |
| 206 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request  | 
                                                        |
| 207 | +		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { | 
                                                        |
| 208 | +			try { | 
                                                        |
| 209 | + // this loads the controller for the admin pages which will setup routing etc  | 
                                                        |
| 210 | +				EE_Registry::instance()->load_core('Admin_Page_Loader'); | 
                                                        |
| 211 | +			} catch (EE_Error $e) { | 
                                                        |
| 212 | + $e->get_error();  | 
                                                        |
| 213 | + }  | 
                                                        |
| 214 | + }  | 
                                                        |
| 215 | +		add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); | 
                                                        |
| 216 | + // make sure our CPTs and custom taxonomy metaboxes get shown for first time users  | 
                                                        |
| 217 | +		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10); | 
                                                        |
| 218 | +		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10); | 
                                                        |
| 219 | + // exclude EE critical pages from all nav menus and wp_list_pages  | 
                                                        |
| 220 | +		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10); | 
                                                        |
| 221 | + }  | 
                                                        |
| 222 | +  | 
                                                        |
| 223 | +  | 
                                                        |
| 224 | + /**  | 
                                                        |
| 225 | + * Gets the loader (and if it wasn't previously set, sets it)  | 
                                                        |
| 226 | + * @return LoaderInterface  | 
                                                        |
| 227 | + * @throws InvalidArgumentException  | 
                                                        |
| 228 | + * @throws InvalidDataTypeException  | 
                                                        |
| 229 | + * @throws InvalidInterfaceException  | 
                                                        |
| 230 | + */  | 
                                                        |
| 231 | + protected function getLoader()  | 
                                                        |
| 232 | +	{ | 
                                                        |
| 233 | +		if (! $this->loader instanceof LoaderInterface) { | 
                                                        |
| 234 | + $this->loader = LoaderFactory::getLoader();  | 
                                                        |
| 235 | + }  | 
                                                        |
| 236 | + return $this->loader;  | 
                                                        |
| 237 | + }  | 
                                                        |
| 238 | +  | 
                                                        |
| 239 | +  | 
                                                        |
| 240 | + /**  | 
                                                        |
| 241 | + * Method that's fired on admin requests (including admin ajax) but only when the models are usable  | 
                                                        |
| 242 | + * (ie, the site isn't in maintenance mode)  | 
                                                        |
| 243 | + * @since 4.9.63.p  | 
                                                        |
| 244 | + * @return void  | 
                                                        |
| 245 | + */  | 
                                                        |
| 246 | + protected function initModelsReady()  | 
                                                        |
| 247 | +	{ | 
                                                        |
| 248 | + // ok so we want to enable the entire admin  | 
                                                        |
| 249 | + $this->persistent_admin_notice_manager = $this->getLoader()->getShared(  | 
                                                        |
| 250 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 251 | + );  | 
                                                        |
| 252 | + $this->persistent_admin_notice_manager->setReturnUrl(  | 
                                                        |
| 253 | + EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 254 | + array(  | 
                                                        |
| 255 | +					'page'   => EE_Registry::instance()->REQ->get('page', ''), | 
                                                        |
| 256 | +					'action' => EE_Registry::instance()->REQ->get('action', ''), | 
                                                        |
| 257 | + ),  | 
                                                        |
| 258 | + EE_ADMIN_URL  | 
                                                        |
| 259 | + )  | 
                                                        |
| 260 | + );  | 
                                                        |
| 261 | + $this->maybeSetDatetimeWarningNotice();  | 
                                                        |
| 262 | + // at a glance dashboard widget  | 
                                                        |
| 263 | +		add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); | 
                                                        |
| 264 | + // filter for get_edit_post_link used on comments for custom post types  | 
                                                        |
| 265 | +		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); | 
                                                        |
| 266 | + }  | 
                                                        |
| 267 | +  | 
                                                        |
| 268 | +  | 
                                                        |
| 269 | + /**  | 
                                                        |
| 270 | + * get_persistent_admin_notices  | 
                                                        |
| 271 | + *  | 
                                                        |
| 272 | + * @access public  | 
                                                        |
| 273 | + * @return void  | 
                                                        |
| 274 | + * @throws EE_Error  | 
                                                        |
| 275 | + * @throws InvalidArgumentException  | 
                                                        |
| 276 | + * @throws InvalidDataTypeException  | 
                                                        |
| 277 | + * @throws InvalidInterfaceException  | 
                                                        |
| 278 | + */  | 
                                                        |
| 279 | + public function maybeSetDatetimeWarningNotice()  | 
                                                        |
| 280 | +	{ | 
                                                        |
| 281 | + // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set.  | 
                                                        |
| 282 | + // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version  | 
                                                        |
| 283 | + // with this. But after enough time (indeterminate at this point) we can just remove this notice.  | 
                                                        |
| 284 | + // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626  | 
                                                        |
| 285 | +		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) | 
                                                        |
| 286 | +			&& ! get_option('timezone_string') | 
                                                        |
| 287 | + && EEM_Event::instance()->count() > 0  | 
                                                        |
| 288 | +		) { | 
                                                        |
| 289 | + new PersistentAdminNotice(  | 
                                                        |
| 290 | + 'datetime_fix_notice',  | 
                                                        |
| 291 | + sprintf(  | 
                                                        |
| 292 | + esc_html__(  | 
                                                        |
| 293 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',  | 
                                                        |
| 294 | + 'event_espresso'  | 
                                                        |
| 295 | + ),  | 
                                                        |
| 296 | + '<strong>',  | 
                                                        |
| 297 | + '</strong>',  | 
                                                        |
| 298 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',  | 
                                                        |
| 299 | + '</a>',  | 
                                                        |
| 300 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 301 | + array(  | 
                                                        |
| 302 | + 'page' => 'espresso_maintenance_settings',  | 
                                                        |
| 303 | + 'action' => 'datetime_tools',  | 
                                                        |
| 304 | + ),  | 
                                                        |
| 305 | +						admin_url('admin.php') | 
                                                        |
| 306 | + ) . '">'  | 
                                                        |
| 307 | + ),  | 
                                                        |
| 308 | + false,  | 
                                                        |
| 309 | + 'manage_options',  | 
                                                        |
| 310 | + 'datetime_fix_persistent_notice'  | 
                                                        |
| 311 | + );  | 
                                                        |
| 312 | + }  | 
                                                        |
| 313 | + }  | 
                                                        |
| 314 | +  | 
                                                        |
| 315 | +  | 
                                                        |
| 316 | + /**  | 
                                                        |
| 317 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from  | 
                                                        |
| 318 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in  | 
                                                        |
| 319 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that  | 
                                                        |
| 320 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a  | 
                                                        |
| 321 | + * normal property on the post_type object. It's found ONLY in this particular context.  | 
                                                        |
| 322 | + *  | 
                                                        |
| 323 | + * @param WP_Post $post_type WP post type object  | 
                                                        |
| 324 | + * @return WP_Post  | 
                                                        |
| 325 | + * @throws InvalidArgumentException  | 
                                                        |
| 326 | + * @throws InvalidDataTypeException  | 
                                                        |
| 327 | + * @throws InvalidInterfaceException  | 
                                                        |
| 328 | + */  | 
                                                        |
| 329 | + public function remove_pages_from_nav_menu($post_type)  | 
                                                        |
| 330 | +	{ | 
                                                        |
| 331 | + // if this isn't the "pages" post type let's get out  | 
                                                        |
| 332 | +		if ($post_type->name !== 'page') { | 
                                                        |
| 333 | + return $post_type;  | 
                                                        |
| 334 | + }  | 
                                                        |
| 335 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();  | 
                                                        |
| 336 | + $post_type->_default_query = array(  | 
                                                        |
| 337 | + 'post__not_in' => $critical_pages,  | 
                                                        |
| 338 | + );  | 
                                                        |
| 339 | + return $post_type;  | 
                                                        |
| 340 | + }  | 
                                                        |
| 341 | +  | 
                                                        |
| 342 | +  | 
                                                        |
| 343 | + /**  | 
                                                        |
| 344 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our  | 
                                                        |
| 345 | + * metaboxes get shown as well  | 
                                                        |
| 346 | + *  | 
                                                        |
| 347 | + * @return void  | 
                                                        |
| 348 | + */  | 
                                                        |
| 349 | + public function enable_hidden_ee_nav_menu_metaboxes()  | 
                                                        |
| 350 | +	{ | 
                                                        |
| 351 | + global $wp_meta_boxes, $pagenow;  | 
                                                        |
| 352 | +		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { | 
                                                        |
| 353 | + return;  | 
                                                        |
| 354 | + }  | 
                                                        |
| 355 | + $user = wp_get_current_user();  | 
                                                        |
| 356 | + // has this been done yet?  | 
                                                        |
| 357 | +		if (get_user_option('ee_nav_menu_initialized', $user->ID)) { | 
                                                        |
| 358 | + return;  | 
                                                        |
| 359 | + }  | 
                                                        |
| 360 | +  | 
                                                        |
| 361 | +		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); | 
                                                        |
| 362 | + $initial_meta_boxes = apply_filters(  | 
                                                        |
| 363 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',  | 
                                                        |
| 364 | + array(  | 
                                                        |
| 365 | + 'nav-menu-theme-locations',  | 
                                                        |
| 366 | + 'add-page',  | 
                                                        |
| 367 | + 'add-custom-links',  | 
                                                        |
| 368 | + 'add-category',  | 
                                                        |
| 369 | + 'add-espresso_events',  | 
                                                        |
| 370 | + 'add-espresso_venues',  | 
                                                        |
| 371 | + 'add-espresso_event_categories',  | 
                                                        |
| 372 | + 'add-espresso_venue_categories',  | 
                                                        |
| 373 | + 'add-post-type-post',  | 
                                                        |
| 374 | + 'add-post-type-page',  | 
                                                        |
| 375 | + )  | 
                                                        |
| 376 | + );  | 
                                                        |
| 377 | +  | 
                                                        |
| 378 | +		if (is_array($hidden_meta_boxes)) { | 
                                                        |
| 379 | +			foreach ($hidden_meta_boxes as $key => $meta_box_id) { | 
                                                        |
| 380 | +				if (in_array($meta_box_id, $initial_meta_boxes, true)) { | 
                                                        |
| 381 | + unset($hidden_meta_boxes[ $key ]);  | 
                                                        |
| 382 | + }  | 
                                                        |
| 383 | + }  | 
                                                        |
| 384 | + }  | 
                                                        |
| 385 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);  | 
                                                        |
| 386 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);  | 
                                                        |
| 387 | + }  | 
                                                        |
| 388 | +  | 
                                                        |
| 389 | +  | 
                                                        |
| 390 | + /**  | 
                                                        |
| 391 | + * This method simply registers custom nav menu boxes for "nav_menus.php route"  | 
                                                        |
| 392 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes.  | 
                                                        |
| 393 | + *  | 
                                                        |
| 394 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by  | 
                                                        |
| 395 | + * addons etc.  | 
                                                        |
| 396 | + * @return void  | 
                                                        |
| 397 | + */  | 
                                                        |
| 398 | + public function register_custom_nav_menu_boxes()  | 
                                                        |
| 399 | +	{ | 
                                                        |
| 400 | + add_meta_box(  | 
                                                        |
| 401 | + 'add-extra-nav-menu-pages',  | 
                                                        |
| 402 | +			esc_html__('Event Espresso Pages', 'event_espresso'), | 
                                                        |
| 403 | + array($this, 'ee_cpt_archive_pages'),  | 
                                                        |
| 404 | + 'nav-menus',  | 
                                                        |
| 405 | + 'side',  | 
                                                        |
| 406 | + 'core'  | 
                                                        |
| 407 | + );  | 
                                                        |
| 408 | + }  | 
                                                        |
| 409 | +  | 
                                                        |
| 410 | +  | 
                                                        |
| 411 | + /**  | 
                                                        |
| 412 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page.  | 
                                                        |
| 413 | + *  | 
                                                        |
| 414 | + * @since 4.3.0  | 
                                                        |
| 415 | + * @param string $link the original link generated by wp  | 
                                                        |
| 416 | + * @param int $id post id  | 
                                                        |
| 417 | + * @return string the (maybe) modified link  | 
                                                        |
| 418 | + */  | 
                                                        |
| 419 | + public function modify_edit_post_link($link, $id)  | 
                                                        |
| 420 | +	{ | 
                                                        |
| 421 | +		if (! $post = get_post($id)) { | 
                                                        |
| 422 | + return $link;  | 
                                                        |
| 423 | + }  | 
                                                        |
| 424 | +		if ($post->post_type === 'espresso_attendees') { | 
                                                        |
| 425 | + $query_args = array(  | 
                                                        |
| 426 | + 'action' => 'edit_attendee',  | 
                                                        |
| 427 | + 'post' => $id,  | 
                                                        |
| 428 | + );  | 
                                                        |
| 429 | + return EEH_URL::add_query_args_and_nonce(  | 
                                                        |
| 430 | + $query_args,  | 
                                                        |
| 431 | +				admin_url('admin.php?page=espresso_registrations') | 
                                                        |
| 432 | + );  | 
                                                        |
| 433 | + }  | 
                                                        |
| 434 | + return $link;  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | +  | 
                                                        |
| 437 | +  | 
                                                        |
| 438 | + public function ee_cpt_archive_pages()  | 
                                                        |
| 439 | +	{ | 
                                                        |
| 440 | + global $nav_menu_selected_id;  | 
                                                        |
| 441 | + $db_fields = false;  | 
                                                        |
| 442 | + $walker = new Walker_Nav_Menu_Checklist($db_fields);  | 
                                                        |
| 443 | + $current_tab = 'event-archives';  | 
                                                        |
| 444 | + $removed_args = array(  | 
                                                        |
| 445 | + 'action',  | 
                                                        |
| 446 | + 'customlink-tab',  | 
                                                        |
| 447 | + 'edit-menu-item',  | 
                                                        |
| 448 | + 'menu-item',  | 
                                                        |
| 449 | + 'page-tab',  | 
                                                        |
| 450 | + '_wpnonce',  | 
                                                        |
| 451 | + );  | 
                                                        |
| 452 | + ?>  | 
                                                        |
| 453 | 453 | <div id="posttype-extra-nav-menu-pages" class="posttypediv">  | 
                                                        
| 454 | 454 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">  | 
                                                        
| 455 | 455 |                  <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> | 
                                                        
| 456 | 456 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"  | 
                                                        
| 457 | 457 | href="<?php  | 
                                                        
| 458 | -                        if ($nav_menu_selected_id) { | 
                                                        |
| 459 | - echo esc_url(  | 
                                                        |
| 460 | - add_query_arg(  | 
                                                        |
| 461 | - 'extra-nav-menu-pages-tab',  | 
                                                        |
| 462 | - 'event-archives',  | 
                                                        |
| 463 | - remove_query_arg($removed_args)  | 
                                                        |
| 464 | - )  | 
                                                        |
| 465 | - );  | 
                                                        |
| 466 | - }  | 
                                                        |
| 467 | - ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">  | 
                                                        |
| 458 | +						if ($nav_menu_selected_id) { | 
                                                        |
| 459 | + echo esc_url(  | 
                                                        |
| 460 | + add_query_arg(  | 
                                                        |
| 461 | + 'extra-nav-menu-pages-tab',  | 
                                                        |
| 462 | + 'event-archives',  | 
                                                        |
| 463 | + remove_query_arg($removed_args)  | 
                                                        |
| 464 | + )  | 
                                                        |
| 465 | + );  | 
                                                        |
| 466 | + }  | 
                                                        |
| 467 | + ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">  | 
                                                        |
| 468 | 468 |                          <?php esc_html_e('Event Archive Pages', 'event_espresso'); ?> | 
                                                        
| 469 | 469 | </a>  | 
                                                        
| 470 | 470 | </li>  | 
                                                        
| 471 | 471 | </ul><!-- .posttype-tabs -->  | 
                                                        
| 472 | 472 | |
| 473 | 473 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php  | 
                                                        
| 474 | -            echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); | 
                                                        |
| 475 | - ?>">  | 
                                                        |
| 474 | +			echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); | 
                                                        |
| 475 | + ?>">  | 
                                                        |
| 476 | 476 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">  | 
                                                        
| 477 | 477 | <?php  | 
                                                        
| 478 | - $pages = $this->_get_extra_nav_menu_pages_items();  | 
                                                        |
| 479 | - $args['walker'] = $walker;  | 
                                                        |
| 480 | - echo walk_nav_menu_tree(  | 
                                                        |
| 481 | - array_map(  | 
                                                        |
| 482 | - array($this, '_setup_extra_nav_menu_pages_items'),  | 
                                                        |
| 483 | - $pages  | 
                                                        |
| 484 | - ),  | 
                                                        |
| 485 | - 0,  | 
                                                        |
| 486 | - (object) $args  | 
                                                        |
| 487 | - );  | 
                                                        |
| 488 | - ?>  | 
                                                        |
| 478 | + $pages = $this->_get_extra_nav_menu_pages_items();  | 
                                                        |
| 479 | + $args['walker'] = $walker;  | 
                                                        |
| 480 | + echo walk_nav_menu_tree(  | 
                                                        |
| 481 | + array_map(  | 
                                                        |
| 482 | + array($this, '_setup_extra_nav_menu_pages_items'),  | 
                                                        |
| 483 | + $pages  | 
                                                        |
| 484 | + ),  | 
                                                        |
| 485 | + 0,  | 
                                                        |
| 486 | + (object) $args  | 
                                                        |
| 487 | + );  | 
                                                        |
| 488 | + ?>  | 
                                                        |
| 489 | 489 | </ul>  | 
                                                        
| 490 | 490 | </div><!-- /.tabs-panel -->  | 
                                                        
| 491 | 491 | |
| 492 | 492 | <p class="button-controls">  | 
                                                        
| 493 | 493 | <span class="list-controls">  | 
                                                        
| 494 | 494 | <a href="<?php  | 
                                                        
| 495 | - echo esc_url(  | 
                                                        |
| 496 | - add_query_arg(  | 
                                                        |
| 497 | - array(  | 
                                                        |
| 498 | - 'extra-nav-menu-pages-tab' => 'event-archives',  | 
                                                        |
| 499 | - 'selectall' => 1,  | 
                                                        |
| 500 | - ),  | 
                                                        |
| 501 | - remove_query_arg($removed_args)  | 
                                                        |
| 502 | - )  | 
                                                        |
| 503 | - );  | 
                                                        |
| 504 | -                        ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> | 
                                                        |
| 495 | + echo esc_url(  | 
                                                        |
| 496 | + add_query_arg(  | 
                                                        |
| 497 | + array(  | 
                                                        |
| 498 | + 'extra-nav-menu-pages-tab' => 'event-archives',  | 
                                                        |
| 499 | + 'selectall' => 1,  | 
                                                        |
| 500 | + ),  | 
                                                        |
| 501 | + remove_query_arg($removed_args)  | 
                                                        |
| 502 | + )  | 
                                                        |
| 503 | + );  | 
                                                        |
| 504 | +						?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> | 
                                                        |
| 505 | 505 | </span>  | 
                                                        
| 506 | 506 | <span class="add-to-menu">  | 
                                                        
| 507 | 507 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>  | 
                                                        
@@ -514,566 +514,566 @@ discard block  | 
                                                    ||
| 514 | 514 | |
| 515 | 515 | </div><!-- /.posttypediv -->  | 
                                                        
| 516 | 516 | <?php  | 
                                                        
| 517 | - }  | 
                                                        |
| 518 | -  | 
                                                        |
| 519 | -  | 
                                                        |
| 520 | - /**  | 
                                                        |
| 521 | - * Returns an array of event archive nav items.  | 
                                                        |
| 522 | - *  | 
                                                        |
| 523 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever  | 
                                                        |
| 524 | - * method we use for getting the extra nav menu items  | 
                                                        |
| 525 | - * @return array  | 
                                                        |
| 526 | - */  | 
                                                        |
| 527 | - private function _get_extra_nav_menu_pages_items()  | 
                                                        |
| 528 | -    { | 
                                                        |
| 529 | - $menuitems[] = array(  | 
                                                        |
| 530 | -            'title'       => esc_html__('Event List', 'event_espresso'), | 
                                                        |
| 531 | -            'url'         => get_post_type_archive_link('espresso_events'), | 
                                                        |
| 532 | -            'description' => esc_html__('Archive page for all events.', 'event_espresso'), | 
                                                        |
| 533 | - );  | 
                                                        |
| 534 | -        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); | 
                                                        |
| 535 | - }  | 
                                                        |
| 536 | -  | 
                                                        |
| 537 | -  | 
                                                        |
| 538 | - /**  | 
                                                        |
| 539 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with  | 
                                                        |
| 540 | - * the properties and converts it to the menu item object.  | 
                                                        |
| 541 | - *  | 
                                                        |
| 542 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php  | 
                                                        |
| 543 | - * @param $menu_item_values  | 
                                                        |
| 544 | - * @return stdClass  | 
                                                        |
| 545 | - */  | 
                                                        |
| 546 | - private function _setup_extra_nav_menu_pages_items($menu_item_values)  | 
                                                        |
| 547 | -    { | 
                                                        |
| 548 | - $menu_item = new stdClass();  | 
                                                        |
| 549 | - $keys = array(  | 
                                                        |
| 550 | - 'ID' => 0,  | 
                                                        |
| 551 | - 'db_id' => 0,  | 
                                                        |
| 552 | - 'menu_item_parent' => 0,  | 
                                                        |
| 553 | - 'object_id' => -1,  | 
                                                        |
| 554 | - 'post_parent' => 0,  | 
                                                        |
| 555 | - 'type' => 'custom',  | 
                                                        |
| 556 | - 'object' => '',  | 
                                                        |
| 557 | -            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'), | 
                                                        |
| 558 | - 'title' => '',  | 
                                                        |
| 559 | - 'url' => '',  | 
                                                        |
| 560 | - 'target' => '',  | 
                                                        |
| 561 | - 'attr_title' => '',  | 
                                                        |
| 562 | - 'description' => '',  | 
                                                        |
| 563 | - 'classes' => array(),  | 
                                                        |
| 564 | - 'xfn' => '',  | 
                                                        |
| 565 | - );  | 
                                                        |
| 566 | -  | 
                                                        |
| 567 | -        foreach ($keys as $key => $value) { | 
                                                        |
| 568 | -            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; | 
                                                        |
| 569 | - }  | 
                                                        |
| 570 | - return $menu_item;  | 
                                                        |
| 571 | - }  | 
                                                        |
| 572 | -  | 
                                                        |
| 573 | -  | 
                                                        |
| 574 | - /**  | 
                                                        |
| 575 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an  | 
                                                        |
| 576 | - * EE_Admin_Page route is called.  | 
                                                        |
| 577 | - *  | 
                                                        |
| 578 | - * @return void  | 
                                                        |
| 579 | - */  | 
                                                        |
| 580 | - public function route_admin_request()  | 
                                                        |
| 581 | -    { | 
                                                        |
| 582 | - }  | 
                                                        |
| 583 | -  | 
                                                        |
| 584 | -  | 
                                                        |
| 585 | - /**  | 
                                                        |
| 586 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority.  | 
                                                        |
| 587 | - *  | 
                                                        |
| 588 | - * @return void  | 
                                                        |
| 589 | - */  | 
                                                        |
| 590 | - public function wp_loaded()  | 
                                                        |
| 591 | -    { | 
                                                        |
| 592 | - }  | 
                                                        |
| 593 | -  | 
                                                        |
| 594 | -  | 
                                                        |
| 595 | - /**  | 
                                                        |
| 596 | - * admin_init  | 
                                                        |
| 597 | - *  | 
                                                        |
| 598 | - * @return void  | 
                                                        |
| 599 | - * @throws EE_Error  | 
                                                        |
| 600 | - * @throws InvalidArgumentException  | 
                                                        |
| 601 | - * @throws InvalidDataTypeException  | 
                                                        |
| 602 | - * @throws InvalidInterfaceException  | 
                                                        |
| 603 | - * @throws ReflectionException  | 
                                                        |
| 604 | - */  | 
                                                        |
| 605 | - public function admin_init()  | 
                                                        |
| 606 | -    { | 
                                                        |
| 607 | - /**  | 
                                                        |
| 608 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),  | 
                                                        |
| 609 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code:  | 
                                                        |
| 610 | - * - check if doing post processing.  | 
                                                        |
| 611 | - * - check if doing post processing of one of EE CPTs  | 
                                                        |
| 612 | - * - instantiate the corresponding EE CPT model for the post_type being processed.  | 
                                                        |
| 613 | - */  | 
                                                        |
| 614 | -        if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { | 
                                                        |
| 615 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */  | 
                                                        |
| 616 | - $custom_post_types = $this->getLoader()->getShared(  | 
                                                        |
| 617 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'  | 
                                                        |
| 618 | - );  | 
                                                        |
| 619 | - $custom_post_types->getCustomPostTypeModels($_POST['post_type']);  | 
                                                        |
| 620 | - }  | 
                                                        |
| 621 | -  | 
                                                        |
| 622 | -  | 
                                                        |
| 623 | - /**  | 
                                                        |
| 624 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting  | 
                                                        |
| 625 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical  | 
                                                        |
| 626 | - * Pages" tab in the EE General Settings Admin page.  | 
                                                        |
| 627 | - * This is for user-proofing.  | 
                                                        |
| 628 | - */  | 
                                                        |
| 629 | -        add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); | 
                                                        |
| 630 | -        if (EE_Maintenance_Mode::instance()->models_can_query()) { | 
                                                        |
| 631 | - $this->adminInitModelsReady();  | 
                                                        |
| 632 | - }  | 
                                                        |
| 633 | - }  | 
                                                        |
| 634 | -  | 
                                                        |
| 635 | -  | 
                                                        |
| 636 | - /**  | 
                                                        |
| 637 | - * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)  | 
                                                        |
| 638 | - */  | 
                                                        |
| 639 | - protected function adminInitModelsReady()  | 
                                                        |
| 640 | -    { | 
                                                        |
| 641 | -        if (function_exists('wp_add_privacy_policy_content')) { | 
                                                        |
| 642 | -            $this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); | 
                                                        |
| 643 | - }  | 
                                                        |
| 644 | - }  | 
                                                        |
| 645 | -  | 
                                                        |
| 646 | -  | 
                                                        |
| 647 | - /**  | 
                                                        |
| 648 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.  | 
                                                        |
| 649 | - *  | 
                                                        |
| 650 | - * @param string $output Current output.  | 
                                                        |
| 651 | - * @return string  | 
                                                        |
| 652 | - * @throws InvalidArgumentException  | 
                                                        |
| 653 | - * @throws InvalidDataTypeException  | 
                                                        |
| 654 | - * @throws InvalidInterfaceException  | 
                                                        |
| 655 | - */  | 
                                                        |
| 656 | - public function modify_dropdown_pages($output)  | 
                                                        |
| 657 | -    { | 
                                                        |
| 658 | - // get critical pages  | 
                                                        |
| 659 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();  | 
                                                        |
| 660 | -  | 
                                                        |
| 661 | - // split current output by line break for easier parsing.  | 
                                                        |
| 662 | -        $split_output = explode("\n", $output); | 
                                                        |
| 663 | -  | 
                                                        |
| 664 | - // loop through to remove any critical pages from the array.  | 
                                                        |
| 665 | -        foreach ($critical_pages as $page_id) { | 
                                                        |
| 666 | - $needle = 'value="' . $page_id . '"';  | 
                                                        |
| 667 | -            foreach ($split_output as $key => $haystack) { | 
                                                        |
| 668 | -                if (strpos($haystack, $needle) !== false) { | 
                                                        |
| 669 | - unset($split_output[ $key ]);  | 
                                                        |
| 670 | - }  | 
                                                        |
| 671 | - }  | 
                                                        |
| 672 | - }  | 
                                                        |
| 673 | - // replace output with the new contents  | 
                                                        |
| 674 | -        return implode("\n", $split_output); | 
                                                        |
| 675 | - }  | 
                                                        |
| 676 | -  | 
                                                        |
| 677 | -  | 
                                                        |
| 678 | - /**  | 
                                                        |
| 679 | - * enqueue all admin scripts that need loaded for admin pages  | 
                                                        |
| 680 | - *  | 
                                                        |
| 681 | - * @return void  | 
                                                        |
| 682 | - */  | 
                                                        |
| 683 | - public function enqueue_admin_scripts()  | 
                                                        |
| 684 | -    { | 
                                                        |
| 685 | - // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.  | 
                                                        |
| 686 | - // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script  | 
                                                        |
| 687 | - // calls.  | 
                                                        |
| 688 | - wp_enqueue_script(  | 
                                                        |
| 689 | - 'ee-inject-wp',  | 
                                                        |
| 690 | - EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',  | 
                                                        |
| 691 | -            array('jquery'), | 
                                                        |
| 692 | - EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 693 | - true  | 
                                                        |
| 694 | - );  | 
                                                        |
| 695 | - // register cookie script for future dependencies  | 
                                                        |
| 696 | - wp_register_script(  | 
                                                        |
| 697 | - 'jquery-cookie',  | 
                                                        |
| 698 | - EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',  | 
                                                        |
| 699 | -            array('jquery'), | 
                                                        |
| 700 | - '2.1',  | 
                                                        |
| 701 | - true  | 
                                                        |
| 702 | - );  | 
                                                        |
| 703 | - // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again  | 
                                                        |
| 704 | -        // via: add_filter('FHEE_load_joyride', '__return_true' ); | 
                                                        |
| 705 | -        if (apply_filters('FHEE_load_joyride', false)) { | 
                                                        |
| 706 | - // joyride style  | 
                                                        |
| 707 | -            wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); | 
                                                        |
| 708 | - wp_register_style(  | 
                                                        |
| 709 | - 'ee-joyride-css',  | 
                                                        |
| 710 | - EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',  | 
                                                        |
| 711 | -                array('joyride-css'), | 
                                                        |
| 712 | - EVENT_ESPRESSO_VERSION  | 
                                                        |
| 713 | - );  | 
                                                        |
| 714 | - wp_register_script(  | 
                                                        |
| 715 | - 'joyride-modernizr',  | 
                                                        |
| 716 | - EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',  | 
                                                        |
| 717 | - array(),  | 
                                                        |
| 718 | - '2.1',  | 
                                                        |
| 719 | - true  | 
                                                        |
| 720 | - );  | 
                                                        |
| 721 | - // joyride JS  | 
                                                        |
| 722 | - wp_register_script(  | 
                                                        |
| 723 | - 'jquery-joyride',  | 
                                                        |
| 724 | - EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',  | 
                                                        |
| 725 | -                array('jquery-cookie', 'joyride-modernizr'), | 
                                                        |
| 726 | - '2.1',  | 
                                                        |
| 727 | - true  | 
                                                        |
| 728 | - );  | 
                                                        |
| 729 | - // wanna go for a joyride?  | 
                                                        |
| 730 | -            wp_enqueue_style('ee-joyride-css'); | 
                                                        |
| 731 | -            wp_enqueue_script('jquery-joyride'); | 
                                                        |
| 732 | - }  | 
                                                        |
| 733 | - }  | 
                                                        |
| 734 | -  | 
                                                        |
| 735 | -  | 
                                                        |
| 736 | - /**  | 
                                                        |
| 737 | - * display_admin_notices  | 
                                                        |
| 738 | - *  | 
                                                        |
| 739 | - * @return void  | 
                                                        |
| 740 | - */  | 
                                                        |
| 741 | - public function display_admin_notices()  | 
                                                        |
| 742 | -    { | 
                                                        |
| 743 | - echo EE_Error::get_notices();  | 
                                                        |
| 744 | - }  | 
                                                        |
| 745 | -  | 
                                                        |
| 746 | -  | 
                                                        |
| 747 | - /**  | 
                                                        |
| 748 | - * @param array $elements  | 
                                                        |
| 749 | - * @return array  | 
                                                        |
| 750 | - * @throws EE_Error  | 
                                                        |
| 751 | - * @throws InvalidArgumentException  | 
                                                        |
| 752 | - * @throws InvalidDataTypeException  | 
                                                        |
| 753 | - * @throws InvalidInterfaceException  | 
                                                        |
| 754 | - */  | 
                                                        |
| 755 | - public function dashboard_glance_items($elements)  | 
                                                        |
| 756 | -    { | 
                                                        |
| 757 | - $elements = is_array($elements) ? $elements : array($elements);  | 
                                                        |
| 758 | - $events = EEM_Event::instance()->count();  | 
                                                        |
| 759 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 760 | -            array('page' => 'espresso_events'), | 
                                                        |
| 761 | -            admin_url('admin.php') | 
                                                        |
| 762 | - );  | 
                                                        |
| 763 | - $items['events']['text'] = sprintf(  | 
                                                        |
| 764 | - esc_html(  | 
                                                        |
| 765 | -                _n('%s Event', '%s Events', $events, 'event_espresso') | 
                                                        |
| 766 | - ),  | 
                                                        |
| 767 | - number_format_i18n($events)  | 
                                                        |
| 768 | - );  | 
                                                        |
| 769 | -        $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); | 
                                                        |
| 770 | - $registrations = EEM_Registration::instance()->count(  | 
                                                        |
| 771 | - array(  | 
                                                        |
| 772 | - array(  | 
                                                        |
| 773 | -                    'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), | 
                                                        |
| 774 | - ),  | 
                                                        |
| 775 | - )  | 
                                                        |
| 776 | - );  | 
                                                        |
| 777 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 778 | -            array('page' => 'espresso_registrations'), | 
                                                        |
| 779 | -            admin_url('admin.php') | 
                                                        |
| 780 | - );  | 
                                                        |
| 781 | - $items['registrations']['text'] = sprintf(  | 
                                                        |
| 782 | - esc_html(  | 
                                                        |
| 783 | -                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') | 
                                                        |
| 784 | - ),  | 
                                                        |
| 785 | - number_format_i18n($registrations)  | 
                                                        |
| 786 | - );  | 
                                                        |
| 787 | -        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); | 
                                                        |
| 788 | -  | 
                                                        |
| 789 | -        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); | 
                                                        |
| 790 | -  | 
                                                        |
| 791 | -        foreach ($items as $type => $item_properties) { | 
                                                        |
| 792 | - $elements[] = sprintf(  | 
                                                        |
| 793 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',  | 
                                                        |
| 794 | - $item_properties['url'],  | 
                                                        |
| 795 | - $item_properties['title'],  | 
                                                        |
| 796 | - $item_properties['text']  | 
                                                        |
| 797 | - );  | 
                                                        |
| 798 | - }  | 
                                                        |
| 799 | - return $elements;  | 
                                                        |
| 800 | - }  | 
                                                        |
| 801 | -  | 
                                                        |
| 802 | -  | 
                                                        |
| 803 | - /**  | 
                                                        |
| 804 | - * check_for_invalid_datetime_formats  | 
                                                        |
| 805 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that  | 
                                                        |
| 806 | - * their selected format can be parsed by PHP  | 
                                                        |
| 807 | - *  | 
                                                        |
| 808 | - * @param $value  | 
                                                        |
| 809 | - * @param $option  | 
                                                        |
| 810 | - * @throws EE_Error  | 
                                                        |
| 811 | - * @return string  | 
                                                        |
| 812 | - */  | 
                                                        |
| 813 | - public function check_for_invalid_datetime_formats($value, $option)  | 
                                                        |
| 814 | -    { | 
                                                        |
| 815 | - // check for date_format or time_format  | 
                                                        |
| 816 | -        switch ($option) { | 
                                                        |
| 817 | - case 'date_format':  | 
                                                        |
| 818 | -                $date_time_format = $value . ' ' . get_option('time_format'); | 
                                                        |
| 819 | - break;  | 
                                                        |
| 820 | - case 'time_format':  | 
                                                        |
| 821 | -                $date_time_format = get_option('date_format') . ' ' . $value; | 
                                                        |
| 822 | - break;  | 
                                                        |
| 823 | - default:  | 
                                                        |
| 824 | - $date_time_format = false;  | 
                                                        |
| 825 | - }  | 
                                                        |
| 826 | - // do we have a date_time format to check ?  | 
                                                        |
| 827 | -        if ($date_time_format) { | 
                                                        |
| 828 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);  | 
                                                        |
| 829 | -  | 
                                                        |
| 830 | -            if (is_array($error_msg)) { | 
                                                        |
| 831 | - $msg = '<p>'  | 
                                                        |
| 832 | - . sprintf(  | 
                                                        |
| 833 | - esc_html__(  | 
                                                        |
| 834 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',  | 
                                                        |
| 835 | - 'event_espresso'  | 
                                                        |
| 836 | - ),  | 
                                                        |
| 837 | - date($date_time_format),  | 
                                                        |
| 838 | - $date_time_format  | 
                                                        |
| 839 | - )  | 
                                                        |
| 840 | - . '</p><p><ul>';  | 
                                                        |
| 841 | -  | 
                                                        |
| 842 | -  | 
                                                        |
| 843 | -                foreach ($error_msg as $error) { | 
                                                        |
| 844 | - $msg .= '<li>' . $error . '</li>';  | 
                                                        |
| 845 | - }  | 
                                                        |
| 846 | -  | 
                                                        |
| 847 | - $msg .= '</ul></p><p>'  | 
                                                        |
| 848 | - . sprintf(  | 
                                                        |
| 849 | - esc_html__(  | 
                                                        |
| 850 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',  | 
                                                        |
| 851 | - 'event_espresso'  | 
                                                        |
| 852 | - ),  | 
                                                        |
| 853 | - '<span style="color:#D54E21;">',  | 
                                                        |
| 854 | - '</span>'  | 
                                                        |
| 855 | - )  | 
                                                        |
| 856 | - . '</p>';  | 
                                                        |
| 857 | -  | 
                                                        |
| 858 | - // trigger WP settings error  | 
                                                        |
| 859 | - add_settings_error(  | 
                                                        |
| 860 | - 'date_format',  | 
                                                        |
| 861 | - 'date_format',  | 
                                                        |
| 862 | - $msg  | 
                                                        |
| 863 | - );  | 
                                                        |
| 864 | -  | 
                                                        |
| 865 | - // set format to something valid  | 
                                                        |
| 866 | -                switch ($option) { | 
                                                        |
| 867 | - case 'date_format':  | 
                                                        |
| 868 | - $value = 'F j, Y';  | 
                                                        |
| 869 | - break;  | 
                                                        |
| 870 | - case 'time_format':  | 
                                                        |
| 871 | - $value = 'g:i a';  | 
                                                        |
| 872 | - break;  | 
                                                        |
| 873 | - }  | 
                                                        |
| 874 | - }  | 
                                                        |
| 875 | - }  | 
                                                        |
| 876 | - return $value;  | 
                                                        |
| 877 | - }  | 
                                                        |
| 878 | -  | 
                                                        |
| 879 | -  | 
                                                        |
| 880 | - /**  | 
                                                        |
| 881 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"  | 
                                                        |
| 882 | - *  | 
                                                        |
| 883 | - * @param $content  | 
                                                        |
| 884 | - * @return string  | 
                                                        |
| 885 | - */  | 
                                                        |
| 886 | - public function its_eSpresso($content)  | 
                                                        |
| 887 | -    { | 
                                                        |
| 888 | -        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); | 
                                                        |
| 889 | - }  | 
                                                        |
| 890 | -  | 
                                                        |
| 891 | -  | 
                                                        |
| 892 | - /**  | 
                                                        |
| 893 | - * espresso_admin_footer  | 
                                                        |
| 894 | - *  | 
                                                        |
| 895 | - * @return string  | 
                                                        |
| 896 | - */  | 
                                                        |
| 897 | - public function espresso_admin_footer()  | 
                                                        |
| 898 | -    { | 
                                                        |
| 899 | -        return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); | 
                                                        |
| 900 | - }  | 
                                                        |
| 901 | -  | 
                                                        |
| 902 | -  | 
                                                        |
| 903 | - /**  | 
                                                        |
| 904 | - * static method for registering ee admin page.  | 
                                                        |
| 905 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.  | 
                                                        |
| 906 | - *  | 
                                                        |
| 907 | - * @since 4.3.0  | 
                                                        |
| 908 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead  | 
                                                        |
| 909 | - * @see EE_Register_Admin_Page::register()  | 
                                                        |
| 910 | - * @param $page_basename  | 
                                                        |
| 911 | - * @param $page_path  | 
                                                        |
| 912 | - * @param array $config  | 
                                                        |
| 913 | - * @return void  | 
                                                        |
| 914 | - * @throws EE_Error  | 
                                                        |
| 915 | - */  | 
                                                        |
| 916 | - public static function register_ee_admin_page($page_basename, $page_path, $config = array())  | 
                                                        |
| 917 | -    { | 
                                                        |
| 918 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 919 | - __METHOD__,  | 
                                                        |
| 920 | - sprintf(  | 
                                                        |
| 921 | - esc_html__(  | 
                                                        |
| 922 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.',  | 
                                                        |
| 923 | - 'event_espresso'  | 
                                                        |
| 924 | - ),  | 
                                                        |
| 925 | - $page_basename  | 
                                                        |
| 926 | - ),  | 
                                                        |
| 927 | - '4.3'  | 
                                                        |
| 928 | - );  | 
                                                        |
| 929 | -        if (class_exists('EE_Register_Admin_Page')) { | 
                                                        |
| 930 | - $config['page_path'] = $page_path;  | 
                                                        |
| 931 | - }  | 
                                                        |
| 932 | - EE_Register_Admin_Page::register($page_basename, $config);  | 
                                                        |
| 933 | - }  | 
                                                        |
| 934 | -  | 
                                                        |
| 935 | -  | 
                                                        |
| 936 | - /**  | 
                                                        |
| 937 | - * @deprecated 4.8.41  | 
                                                        |
| 938 | - * @param int $post_ID  | 
                                                        |
| 939 | - * @param \WP_Post $post  | 
                                                        |
| 940 | - * @return void  | 
                                                        |
| 941 | - */  | 
                                                        |
| 942 | - public static function parse_post_content_on_save($post_ID, $post)  | 
                                                        |
| 943 | -    { | 
                                                        |
| 944 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 945 | - __METHOD__,  | 
                                                        |
| 946 | -            esc_html__('Usage is deprecated', 'event_espresso'), | 
                                                        |
| 947 | - '4.8.41'  | 
                                                        |
| 948 | - );  | 
                                                        |
| 949 | - }  | 
                                                        |
| 950 | -  | 
                                                        |
| 951 | -  | 
                                                        |
| 952 | - /**  | 
                                                        |
| 953 | - * @deprecated 4.8.41  | 
                                                        |
| 954 | - * @param $option  | 
                                                        |
| 955 | - * @param $old_value  | 
                                                        |
| 956 | - * @param $value  | 
                                                        |
| 957 | - * @return void  | 
                                                        |
| 958 | - */  | 
                                                        |
| 959 | - public function reset_page_for_posts_on_change($option, $old_value, $value)  | 
                                                        |
| 960 | -    { | 
                                                        |
| 961 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 962 | - __METHOD__,  | 
                                                        |
| 963 | -            esc_html__('Usage is deprecated', 'event_espresso'), | 
                                                        |
| 964 | - '4.8.41'  | 
                                                        |
| 965 | - );  | 
                                                        |
| 966 | - }  | 
                                                        |
| 967 | -  | 
                                                        |
| 968 | -  | 
                                                        |
| 969 | - /**  | 
                                                        |
| 970 | - * @deprecated 4.9.27  | 
                                                        |
| 971 | - * @return void  | 
                                                        |
| 972 | - */  | 
                                                        |
| 973 | - public function get_persistent_admin_notices()  | 
                                                        |
| 974 | -    { | 
                                                        |
| 975 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 976 | - __METHOD__,  | 
                                                        |
| 977 | - sprintf(  | 
                                                        |
| 978 | -                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), | 
                                                        |
| 979 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 980 | - ),  | 
                                                        |
| 981 | - '4.9.27'  | 
                                                        |
| 982 | - );  | 
                                                        |
| 983 | - }  | 
                                                        |
| 984 | -  | 
                                                        |
| 985 | -  | 
                                                        |
| 986 | - /**  | 
                                                        |
| 987 | - * @deprecated 4.9.27  | 
                                                        |
| 988 | - * @throws InvalidInterfaceException  | 
                                                        |
| 989 | - * @throws InvalidDataTypeException  | 
                                                        |
| 990 | - * @throws DomainException  | 
                                                        |
| 991 | - */  | 
                                                        |
| 992 | - public function dismiss_ee_nag_notice_callback()  | 
                                                        |
| 993 | -    { | 
                                                        |
| 994 | - EE_Error::doing_it_wrong(  | 
                                                        |
| 995 | - __METHOD__,  | 
                                                        |
| 996 | - sprintf(  | 
                                                        |
| 997 | -                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), | 
                                                        |
| 998 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 999 | - ),  | 
                                                        |
| 1000 | - '4.9.27'  | 
                                                        |
| 1001 | - );  | 
                                                        |
| 1002 | - $this->persistent_admin_notice_manager->dismissNotice();  | 
                                                        |
| 1003 | - }  | 
                                                        |
| 1004 | -  | 
                                                        |
| 1005 | -  | 
                                                        |
| 1006 | - /**  | 
                                                        |
| 1007 | - * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.  | 
                                                        |
| 1008 | - *  | 
                                                        |
| 1009 | - * @throws InvalidArgumentException  | 
                                                        |
| 1010 | - * @throws InvalidDataTypeException  | 
                                                        |
| 1011 | - * @throws InvalidInterfaceException  | 
                                                        |
| 1012 | - */  | 
                                                        |
| 1013 | - public function hookIntoWpPluginsPage()  | 
                                                        |
| 1014 | -    { | 
                                                        |
| 1015 | -        $this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); | 
                                                        |
| 1016 | - $this->getLoader()  | 
                                                        |
| 1017 | -                     ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells') | 
                                                        |
| 1018 | - ->decafUpsells();  | 
                                                        |
| 1019 | - }  | 
                                                        |
| 1020 | -  | 
                                                        |
| 1021 | -  | 
                                                        |
| 1022 | - /**  | 
                                                        |
| 1023 | - * Hooks into the "post states" filter in a wp post type list table.  | 
                                                        |
| 1024 | - *  | 
                                                        |
| 1025 | - * @param array $post_states  | 
                                                        |
| 1026 | - * @param WP_Post $post  | 
                                                        |
| 1027 | - * @return array  | 
                                                        |
| 1028 | - * @throws InvalidArgumentException  | 
                                                        |
| 1029 | - * @throws InvalidDataTypeException  | 
                                                        |
| 1030 | - * @throws InvalidInterfaceException  | 
                                                        |
| 1031 | - */  | 
                                                        |
| 1032 | - public function displayStateForCriticalPages($post_states, $post)  | 
                                                        |
| 1033 | -    { | 
                                                        |
| 1034 | - $post_states = (array) $post_states;  | 
                                                        |
| 1035 | -        if (! $post instanceof WP_Post || $post->post_type !== 'page') { | 
                                                        |
| 1036 | - return $post_states;  | 
                                                        |
| 1037 | - }  | 
                                                        |
| 1038 | - /** @var EE_Core_Config $config */  | 
                                                        |
| 1039 | -        $config = $this->getLoader()->getShared('EE_Config')->core; | 
                                                        |
| 1040 | -        if (in_array($post->ID, $config->get_critical_pages_array(), true)) { | 
                                                        |
| 1041 | - $post_states[] = sprintf(  | 
                                                        |
| 1042 | - /* Translators: Using company name - Event Espresso Critical Page */  | 
                                                        |
| 1043 | -                esc_html__('%s Critical Page', 'event_espresso'), | 
                                                        |
| 1044 | - 'Event Espresso'  | 
                                                        |
| 1045 | - );  | 
                                                        |
| 1046 | - }  | 
                                                        |
| 1047 | - return $post_states;  | 
                                                        |
| 1048 | - }  | 
                                                        |
| 1049 | -  | 
                                                        |
| 1050 | -  | 
                                                        |
| 1051 | - /**  | 
                                                        |
| 1052 | - * Show documentation links on the plugins page  | 
                                                        |
| 1053 | - *  | 
                                                        |
| 1054 | - * @param mixed $meta Plugin Row Meta  | 
                                                        |
| 1055 | - * @param mixed $file Plugin Base file  | 
                                                        |
| 1056 | - * @return array  | 
                                                        |
| 1057 | - */  | 
                                                        |
| 1058 | - public function addLinksToPluginRowMeta($meta, $file)  | 
                                                        |
| 1059 | -    { | 
                                                        |
| 1060 | -        if (EE_PLUGIN_BASENAME === $file) { | 
                                                        |
| 1061 | - $row_meta = array(  | 
                                                        |
| 1062 | - 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'  | 
                                                        |
| 1063 | - . ' aria-label="'  | 
                                                        |
| 1064 | -                          . esc_attr__('View Event Espresso documentation', 'event_espresso') | 
                                                        |
| 1065 | - . '">'  | 
                                                        |
| 1066 | -                          . esc_html__('Docs', 'event_espresso') | 
                                                        |
| 1067 | - . '</a>',  | 
                                                        |
| 1068 | - 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'  | 
                                                        |
| 1069 | - . ' aria-label="'  | 
                                                        |
| 1070 | -                          . esc_attr__('View Event Espresso API docs', 'event_espresso') | 
                                                        |
| 1071 | - . '">'  | 
                                                        |
| 1072 | -                          . esc_html__('API docs', 'event_espresso') | 
                                                        |
| 1073 | - . '</a>',  | 
                                                        |
| 1074 | - );  | 
                                                        |
| 1075 | - return array_merge($meta, $row_meta);  | 
                                                        |
| 1076 | - }  | 
                                                        |
| 1077 | - return (array) $meta;  | 
                                                        |
| 1078 | - }  | 
                                                        |
| 517 | + }  | 
                                                        |
| 518 | +  | 
                                                        |
| 519 | +  | 
                                                        |
| 520 | + /**  | 
                                                        |
| 521 | + * Returns an array of event archive nav items.  | 
                                                        |
| 522 | + *  | 
                                                        |
| 523 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever  | 
                                                        |
| 524 | + * method we use for getting the extra nav menu items  | 
                                                        |
| 525 | + * @return array  | 
                                                        |
| 526 | + */  | 
                                                        |
| 527 | + private function _get_extra_nav_menu_pages_items()  | 
                                                        |
| 528 | +	{ | 
                                                        |
| 529 | + $menuitems[] = array(  | 
                                                        |
| 530 | +			'title'       => esc_html__('Event List', 'event_espresso'), | 
                                                        |
| 531 | +			'url'         => get_post_type_archive_link('espresso_events'), | 
                                                        |
| 532 | +			'description' => esc_html__('Archive page for all events.', 'event_espresso'), | 
                                                        |
| 533 | + );  | 
                                                        |
| 534 | +		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); | 
                                                        |
| 535 | + }  | 
                                                        |
| 536 | +  | 
                                                        |
| 537 | +  | 
                                                        |
| 538 | + /**  | 
                                                        |
| 539 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with  | 
                                                        |
| 540 | + * the properties and converts it to the menu item object.  | 
                                                        |
| 541 | + *  | 
                                                        |
| 542 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php  | 
                                                        |
| 543 | + * @param $menu_item_values  | 
                                                        |
| 544 | + * @return stdClass  | 
                                                        |
| 545 | + */  | 
                                                        |
| 546 | + private function _setup_extra_nav_menu_pages_items($menu_item_values)  | 
                                                        |
| 547 | +	{ | 
                                                        |
| 548 | + $menu_item = new stdClass();  | 
                                                        |
| 549 | + $keys = array(  | 
                                                        |
| 550 | + 'ID' => 0,  | 
                                                        |
| 551 | + 'db_id' => 0,  | 
                                                        |
| 552 | + 'menu_item_parent' => 0,  | 
                                                        |
| 553 | + 'object_id' => -1,  | 
                                                        |
| 554 | + 'post_parent' => 0,  | 
                                                        |
| 555 | + 'type' => 'custom',  | 
                                                        |
| 556 | + 'object' => '',  | 
                                                        |
| 557 | +			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'), | 
                                                        |
| 558 | + 'title' => '',  | 
                                                        |
| 559 | + 'url' => '',  | 
                                                        |
| 560 | + 'target' => '',  | 
                                                        |
| 561 | + 'attr_title' => '',  | 
                                                        |
| 562 | + 'description' => '',  | 
                                                        |
| 563 | + 'classes' => array(),  | 
                                                        |
| 564 | + 'xfn' => '',  | 
                                                        |
| 565 | + );  | 
                                                        |
| 566 | +  | 
                                                        |
| 567 | +		foreach ($keys as $key => $value) { | 
                                                        |
| 568 | +			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; | 
                                                        |
| 569 | + }  | 
                                                        |
| 570 | + return $menu_item;  | 
                                                        |
| 571 | + }  | 
                                                        |
| 572 | +  | 
                                                        |
| 573 | +  | 
                                                        |
| 574 | + /**  | 
                                                        |
| 575 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an  | 
                                                        |
| 576 | + * EE_Admin_Page route is called.  | 
                                                        |
| 577 | + *  | 
                                                        |
| 578 | + * @return void  | 
                                                        |
| 579 | + */  | 
                                                        |
| 580 | + public function route_admin_request()  | 
                                                        |
| 581 | +	{ | 
                                                        |
| 582 | + }  | 
                                                        |
| 583 | +  | 
                                                        |
| 584 | +  | 
                                                        |
| 585 | + /**  | 
                                                        |
| 586 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority.  | 
                                                        |
| 587 | + *  | 
                                                        |
| 588 | + * @return void  | 
                                                        |
| 589 | + */  | 
                                                        |
| 590 | + public function wp_loaded()  | 
                                                        |
| 591 | +	{ | 
                                                        |
| 592 | + }  | 
                                                        |
| 593 | +  | 
                                                        |
| 594 | +  | 
                                                        |
| 595 | + /**  | 
                                                        |
| 596 | + * admin_init  | 
                                                        |
| 597 | + *  | 
                                                        |
| 598 | + * @return void  | 
                                                        |
| 599 | + * @throws EE_Error  | 
                                                        |
| 600 | + * @throws InvalidArgumentException  | 
                                                        |
| 601 | + * @throws InvalidDataTypeException  | 
                                                        |
| 602 | + * @throws InvalidInterfaceException  | 
                                                        |
| 603 | + * @throws ReflectionException  | 
                                                        |
| 604 | + */  | 
                                                        |
| 605 | + public function admin_init()  | 
                                                        |
| 606 | +	{ | 
                                                        |
| 607 | + /**  | 
                                                        |
| 608 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),  | 
                                                        |
| 609 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code:  | 
                                                        |
| 610 | + * - check if doing post processing.  | 
                                                        |
| 611 | + * - check if doing post processing of one of EE CPTs  | 
                                                        |
| 612 | + * - instantiate the corresponding EE CPT model for the post_type being processed.  | 
                                                        |
| 613 | + */  | 
                                                        |
| 614 | +		if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { | 
                                                        |
| 615 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */  | 
                                                        |
| 616 | + $custom_post_types = $this->getLoader()->getShared(  | 
                                                        |
| 617 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'  | 
                                                        |
| 618 | + );  | 
                                                        |
| 619 | + $custom_post_types->getCustomPostTypeModels($_POST['post_type']);  | 
                                                        |
| 620 | + }  | 
                                                        |
| 621 | +  | 
                                                        |
| 622 | +  | 
                                                        |
| 623 | + /**  | 
                                                        |
| 624 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting  | 
                                                        |
| 625 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical  | 
                                                        |
| 626 | + * Pages" tab in the EE General Settings Admin page.  | 
                                                        |
| 627 | + * This is for user-proofing.  | 
                                                        |
| 628 | + */  | 
                                                        |
| 629 | +		add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); | 
                                                        |
| 630 | +		if (EE_Maintenance_Mode::instance()->models_can_query()) { | 
                                                        |
| 631 | + $this->adminInitModelsReady();  | 
                                                        |
| 632 | + }  | 
                                                        |
| 633 | + }  | 
                                                        |
| 634 | +  | 
                                                        |
| 635 | +  | 
                                                        |
| 636 | + /**  | 
                                                        |
| 637 | + * Runs on admin_init but only if models are usable (ie, we're not in maintenanc emode)  | 
                                                        |
| 638 | + */  | 
                                                        |
| 639 | + protected function adminInitModelsReady()  | 
                                                        |
| 640 | +	{ | 
                                                        |
| 641 | +		if (function_exists('wp_add_privacy_policy_content')) { | 
                                                        |
| 642 | +			$this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); | 
                                                        |
| 643 | + }  | 
                                                        |
| 644 | + }  | 
                                                        |
| 645 | +  | 
                                                        |
| 646 | +  | 
                                                        |
| 647 | + /**  | 
                                                        |
| 648 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.  | 
                                                        |
| 649 | + *  | 
                                                        |
| 650 | + * @param string $output Current output.  | 
                                                        |
| 651 | + * @return string  | 
                                                        |
| 652 | + * @throws InvalidArgumentException  | 
                                                        |
| 653 | + * @throws InvalidDataTypeException  | 
                                                        |
| 654 | + * @throws InvalidInterfaceException  | 
                                                        |
| 655 | + */  | 
                                                        |
| 656 | + public function modify_dropdown_pages($output)  | 
                                                        |
| 657 | +	{ | 
                                                        |
| 658 | + // get critical pages  | 
                                                        |
| 659 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();  | 
                                                        |
| 660 | +  | 
                                                        |
| 661 | + // split current output by line break for easier parsing.  | 
                                                        |
| 662 | +		$split_output = explode("\n", $output); | 
                                                        |
| 663 | +  | 
                                                        |
| 664 | + // loop through to remove any critical pages from the array.  | 
                                                        |
| 665 | +		foreach ($critical_pages as $page_id) { | 
                                                        |
| 666 | + $needle = 'value="' . $page_id . '"';  | 
                                                        |
| 667 | +			foreach ($split_output as $key => $haystack) { | 
                                                        |
| 668 | +				if (strpos($haystack, $needle) !== false) { | 
                                                        |
| 669 | + unset($split_output[ $key ]);  | 
                                                        |
| 670 | + }  | 
                                                        |
| 671 | + }  | 
                                                        |
| 672 | + }  | 
                                                        |
| 673 | + // replace output with the new contents  | 
                                                        |
| 674 | +		return implode("\n", $split_output); | 
                                                        |
| 675 | + }  | 
                                                        |
| 676 | +  | 
                                                        |
| 677 | +  | 
                                                        |
| 678 | + /**  | 
                                                        |
| 679 | + * enqueue all admin scripts that need loaded for admin pages  | 
                                                        |
| 680 | + *  | 
                                                        |
| 681 | + * @return void  | 
                                                        |
| 682 | + */  | 
                                                        |
| 683 | + public function enqueue_admin_scripts()  | 
                                                        |
| 684 | +	{ | 
                                                        |
| 685 | + // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.  | 
                                                        |
| 686 | + // Note: the intention of this script is to only do TARGETED injections. I.E, only injecting on certain script  | 
                                                        |
| 687 | + // calls.  | 
                                                        |
| 688 | + wp_enqueue_script(  | 
                                                        |
| 689 | + 'ee-inject-wp',  | 
                                                        |
| 690 | + EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',  | 
                                                        |
| 691 | +			array('jquery'), | 
                                                        |
| 692 | + EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 693 | + true  | 
                                                        |
| 694 | + );  | 
                                                        |
| 695 | + // register cookie script for future dependencies  | 
                                                        |
| 696 | + wp_register_script(  | 
                                                        |
| 697 | + 'jquery-cookie',  | 
                                                        |
| 698 | + EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',  | 
                                                        |
| 699 | +			array('jquery'), | 
                                                        |
| 700 | + '2.1',  | 
                                                        |
| 701 | + true  | 
                                                        |
| 702 | + );  | 
                                                        |
| 703 | + // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again  | 
                                                        |
| 704 | +		// via: add_filter('FHEE_load_joyride', '__return_true' ); | 
                                                        |
| 705 | +		if (apply_filters('FHEE_load_joyride', false)) { | 
                                                        |
| 706 | + // joyride style  | 
                                                        |
| 707 | +			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1'); | 
                                                        |
| 708 | + wp_register_style(  | 
                                                        |
| 709 | + 'ee-joyride-css',  | 
                                                        |
| 710 | + EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',  | 
                                                        |
| 711 | +				array('joyride-css'), | 
                                                        |
| 712 | + EVENT_ESPRESSO_VERSION  | 
                                                        |
| 713 | + );  | 
                                                        |
| 714 | + wp_register_script(  | 
                                                        |
| 715 | + 'joyride-modernizr',  | 
                                                        |
| 716 | + EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',  | 
                                                        |
| 717 | + array(),  | 
                                                        |
| 718 | + '2.1',  | 
                                                        |
| 719 | + true  | 
                                                        |
| 720 | + );  | 
                                                        |
| 721 | + // joyride JS  | 
                                                        |
| 722 | + wp_register_script(  | 
                                                        |
| 723 | + 'jquery-joyride',  | 
                                                        |
| 724 | + EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',  | 
                                                        |
| 725 | +				array('jquery-cookie', 'joyride-modernizr'), | 
                                                        |
| 726 | + '2.1',  | 
                                                        |
| 727 | + true  | 
                                                        |
| 728 | + );  | 
                                                        |
| 729 | + // wanna go for a joyride?  | 
                                                        |
| 730 | +			wp_enqueue_style('ee-joyride-css'); | 
                                                        |
| 731 | +			wp_enqueue_script('jquery-joyride'); | 
                                                        |
| 732 | + }  | 
                                                        |
| 733 | + }  | 
                                                        |
| 734 | +  | 
                                                        |
| 735 | +  | 
                                                        |
| 736 | + /**  | 
                                                        |
| 737 | + * display_admin_notices  | 
                                                        |
| 738 | + *  | 
                                                        |
| 739 | + * @return void  | 
                                                        |
| 740 | + */  | 
                                                        |
| 741 | + public function display_admin_notices()  | 
                                                        |
| 742 | +	{ | 
                                                        |
| 743 | + echo EE_Error::get_notices();  | 
                                                        |
| 744 | + }  | 
                                                        |
| 745 | +  | 
                                                        |
| 746 | +  | 
                                                        |
| 747 | + /**  | 
                                                        |
| 748 | + * @param array $elements  | 
                                                        |
| 749 | + * @return array  | 
                                                        |
| 750 | + * @throws EE_Error  | 
                                                        |
| 751 | + * @throws InvalidArgumentException  | 
                                                        |
| 752 | + * @throws InvalidDataTypeException  | 
                                                        |
| 753 | + * @throws InvalidInterfaceException  | 
                                                        |
| 754 | + */  | 
                                                        |
| 755 | + public function dashboard_glance_items($elements)  | 
                                                        |
| 756 | +	{ | 
                                                        |
| 757 | + $elements = is_array($elements) ? $elements : array($elements);  | 
                                                        |
| 758 | + $events = EEM_Event::instance()->count();  | 
                                                        |
| 759 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 760 | +			array('page' => 'espresso_events'), | 
                                                        |
| 761 | +			admin_url('admin.php') | 
                                                        |
| 762 | + );  | 
                                                        |
| 763 | + $items['events']['text'] = sprintf(  | 
                                                        |
| 764 | + esc_html(  | 
                                                        |
| 765 | +				_n('%s Event', '%s Events', $events, 'event_espresso') | 
                                                        |
| 766 | + ),  | 
                                                        |
| 767 | + number_format_i18n($events)  | 
                                                        |
| 768 | + );  | 
                                                        |
| 769 | +		$items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); | 
                                                        |
| 770 | + $registrations = EEM_Registration::instance()->count(  | 
                                                        |
| 771 | + array(  | 
                                                        |
| 772 | + array(  | 
                                                        |
| 773 | +					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), | 
                                                        |
| 774 | + ),  | 
                                                        |
| 775 | + )  | 
                                                        |
| 776 | + );  | 
                                                        |
| 777 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 778 | +			array('page' => 'espresso_registrations'), | 
                                                        |
| 779 | +			admin_url('admin.php') | 
                                                        |
| 780 | + );  | 
                                                        |
| 781 | + $items['registrations']['text'] = sprintf(  | 
                                                        |
| 782 | + esc_html(  | 
                                                        |
| 783 | +				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso') | 
                                                        |
| 784 | + ),  | 
                                                        |
| 785 | + number_format_i18n($registrations)  | 
                                                        |
| 786 | + );  | 
                                                        |
| 787 | +		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); | 
                                                        |
| 788 | +  | 
                                                        |
| 789 | +		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); | 
                                                        |
| 790 | +  | 
                                                        |
| 791 | +		foreach ($items as $type => $item_properties) { | 
                                                        |
| 792 | + $elements[] = sprintf(  | 
                                                        |
| 793 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',  | 
                                                        |
| 794 | + $item_properties['url'],  | 
                                                        |
| 795 | + $item_properties['title'],  | 
                                                        |
| 796 | + $item_properties['text']  | 
                                                        |
| 797 | + );  | 
                                                        |
| 798 | + }  | 
                                                        |
| 799 | + return $elements;  | 
                                                        |
| 800 | + }  | 
                                                        |
| 801 | +  | 
                                                        |
| 802 | +  | 
                                                        |
| 803 | + /**  | 
                                                        |
| 804 | + * check_for_invalid_datetime_formats  | 
                                                        |
| 805 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that  | 
                                                        |
| 806 | + * their selected format can be parsed by PHP  | 
                                                        |
| 807 | + *  | 
                                                        |
| 808 | + * @param $value  | 
                                                        |
| 809 | + * @param $option  | 
                                                        |
| 810 | + * @throws EE_Error  | 
                                                        |
| 811 | + * @return string  | 
                                                        |
| 812 | + */  | 
                                                        |
| 813 | + public function check_for_invalid_datetime_formats($value, $option)  | 
                                                        |
| 814 | +	{ | 
                                                        |
| 815 | + // check for date_format or time_format  | 
                                                        |
| 816 | +		switch ($option) { | 
                                                        |
| 817 | + case 'date_format':  | 
                                                        |
| 818 | +				$date_time_format = $value . ' ' . get_option('time_format'); | 
                                                        |
| 819 | + break;  | 
                                                        |
| 820 | + case 'time_format':  | 
                                                        |
| 821 | +				$date_time_format = get_option('date_format') . ' ' . $value; | 
                                                        |
| 822 | + break;  | 
                                                        |
| 823 | + default:  | 
                                                        |
| 824 | + $date_time_format = false;  | 
                                                        |
| 825 | + }  | 
                                                        |
| 826 | + // do we have a date_time format to check ?  | 
                                                        |
| 827 | +		if ($date_time_format) { | 
                                                        |
| 828 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);  | 
                                                        |
| 829 | +  | 
                                                        |
| 830 | +			if (is_array($error_msg)) { | 
                                                        |
| 831 | + $msg = '<p>'  | 
                                                        |
| 832 | + . sprintf(  | 
                                                        |
| 833 | + esc_html__(  | 
                                                        |
| 834 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',  | 
                                                        |
| 835 | + 'event_espresso'  | 
                                                        |
| 836 | + ),  | 
                                                        |
| 837 | + date($date_time_format),  | 
                                                        |
| 838 | + $date_time_format  | 
                                                        |
| 839 | + )  | 
                                                        |
| 840 | + . '</p><p><ul>';  | 
                                                        |
| 841 | +  | 
                                                        |
| 842 | +  | 
                                                        |
| 843 | +				foreach ($error_msg as $error) { | 
                                                        |
| 844 | + $msg .= '<li>' . $error . '</li>';  | 
                                                        |
| 845 | + }  | 
                                                        |
| 846 | +  | 
                                                        |
| 847 | + $msg .= '</ul></p><p>'  | 
                                                        |
| 848 | + . sprintf(  | 
                                                        |
| 849 | + esc_html__(  | 
                                                        |
| 850 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',  | 
                                                        |
| 851 | + 'event_espresso'  | 
                                                        |
| 852 | + ),  | 
                                                        |
| 853 | + '<span style="color:#D54E21;">',  | 
                                                        |
| 854 | + '</span>'  | 
                                                        |
| 855 | + )  | 
                                                        |
| 856 | + . '</p>';  | 
                                                        |
| 857 | +  | 
                                                        |
| 858 | + // trigger WP settings error  | 
                                                        |
| 859 | + add_settings_error(  | 
                                                        |
| 860 | + 'date_format',  | 
                                                        |
| 861 | + 'date_format',  | 
                                                        |
| 862 | + $msg  | 
                                                        |
| 863 | + );  | 
                                                        |
| 864 | +  | 
                                                        |
| 865 | + // set format to something valid  | 
                                                        |
| 866 | +				switch ($option) { | 
                                                        |
| 867 | + case 'date_format':  | 
                                                        |
| 868 | + $value = 'F j, Y';  | 
                                                        |
| 869 | + break;  | 
                                                        |
| 870 | + case 'time_format':  | 
                                                        |
| 871 | + $value = 'g:i a';  | 
                                                        |
| 872 | + break;  | 
                                                        |
| 873 | + }  | 
                                                        |
| 874 | + }  | 
                                                        |
| 875 | + }  | 
                                                        |
| 876 | + return $value;  | 
                                                        |
| 877 | + }  | 
                                                        |
| 878 | +  | 
                                                        |
| 879 | +  | 
                                                        |
| 880 | + /**  | 
                                                        |
| 881 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"  | 
                                                        |
| 882 | + *  | 
                                                        |
| 883 | + * @param $content  | 
                                                        |
| 884 | + * @return string  | 
                                                        |
| 885 | + */  | 
                                                        |
| 886 | + public function its_eSpresso($content)  | 
                                                        |
| 887 | +	{ | 
                                                        |
| 888 | +		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); | 
                                                        |
| 889 | + }  | 
                                                        |
| 890 | +  | 
                                                        |
| 891 | +  | 
                                                        |
| 892 | + /**  | 
                                                        |
| 893 | + * espresso_admin_footer  | 
                                                        |
| 894 | + *  | 
                                                        |
| 895 | + * @return string  | 
                                                        |
| 896 | + */  | 
                                                        |
| 897 | + public function espresso_admin_footer()  | 
                                                        |
| 898 | +	{ | 
                                                        |
| 899 | +		return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); | 
                                                        |
| 900 | + }  | 
                                                        |
| 901 | +  | 
                                                        |
| 902 | +  | 
                                                        |
| 903 | + /**  | 
                                                        |
| 904 | + * static method for registering ee admin page.  | 
                                                        |
| 905 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.  | 
                                                        |
| 906 | + *  | 
                                                        |
| 907 | + * @since 4.3.0  | 
                                                        |
| 908 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead  | 
                                                        |
| 909 | + * @see EE_Register_Admin_Page::register()  | 
                                                        |
| 910 | + * @param $page_basename  | 
                                                        |
| 911 | + * @param $page_path  | 
                                                        |
| 912 | + * @param array $config  | 
                                                        |
| 913 | + * @return void  | 
                                                        |
| 914 | + * @throws EE_Error  | 
                                                        |
| 915 | + */  | 
                                                        |
| 916 | + public static function register_ee_admin_page($page_basename, $page_path, $config = array())  | 
                                                        |
| 917 | +	{ | 
                                                        |
| 918 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 919 | + __METHOD__,  | 
                                                        |
| 920 | + sprintf(  | 
                                                        |
| 921 | + esc_html__(  | 
                                                        |
| 922 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.',  | 
                                                        |
| 923 | + 'event_espresso'  | 
                                                        |
| 924 | + ),  | 
                                                        |
| 925 | + $page_basename  | 
                                                        |
| 926 | + ),  | 
                                                        |
| 927 | + '4.3'  | 
                                                        |
| 928 | + );  | 
                                                        |
| 929 | +		if (class_exists('EE_Register_Admin_Page')) { | 
                                                        |
| 930 | + $config['page_path'] = $page_path;  | 
                                                        |
| 931 | + }  | 
                                                        |
| 932 | + EE_Register_Admin_Page::register($page_basename, $config);  | 
                                                        |
| 933 | + }  | 
                                                        |
| 934 | +  | 
                                                        |
| 935 | +  | 
                                                        |
| 936 | + /**  | 
                                                        |
| 937 | + * @deprecated 4.8.41  | 
                                                        |
| 938 | + * @param int $post_ID  | 
                                                        |
| 939 | + * @param \WP_Post $post  | 
                                                        |
| 940 | + * @return void  | 
                                                        |
| 941 | + */  | 
                                                        |
| 942 | + public static function parse_post_content_on_save($post_ID, $post)  | 
                                                        |
| 943 | +	{ | 
                                                        |
| 944 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 945 | + __METHOD__,  | 
                                                        |
| 946 | +			esc_html__('Usage is deprecated', 'event_espresso'), | 
                                                        |
| 947 | + '4.8.41'  | 
                                                        |
| 948 | + );  | 
                                                        |
| 949 | + }  | 
                                                        |
| 950 | +  | 
                                                        |
| 951 | +  | 
                                                        |
| 952 | + /**  | 
                                                        |
| 953 | + * @deprecated 4.8.41  | 
                                                        |
| 954 | + * @param $option  | 
                                                        |
| 955 | + * @param $old_value  | 
                                                        |
| 956 | + * @param $value  | 
                                                        |
| 957 | + * @return void  | 
                                                        |
| 958 | + */  | 
                                                        |
| 959 | + public function reset_page_for_posts_on_change($option, $old_value, $value)  | 
                                                        |
| 960 | +	{ | 
                                                        |
| 961 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 962 | + __METHOD__,  | 
                                                        |
| 963 | +			esc_html__('Usage is deprecated', 'event_espresso'), | 
                                                        |
| 964 | + '4.8.41'  | 
                                                        |
| 965 | + );  | 
                                                        |
| 966 | + }  | 
                                                        |
| 967 | +  | 
                                                        |
| 968 | +  | 
                                                        |
| 969 | + /**  | 
                                                        |
| 970 | + * @deprecated 4.9.27  | 
                                                        |
| 971 | + * @return void  | 
                                                        |
| 972 | + */  | 
                                                        |
| 973 | + public function get_persistent_admin_notices()  | 
                                                        |
| 974 | +	{ | 
                                                        |
| 975 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 976 | + __METHOD__,  | 
                                                        |
| 977 | + sprintf(  | 
                                                        |
| 978 | +				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), | 
                                                        |
| 979 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 980 | + ),  | 
                                                        |
| 981 | + '4.9.27'  | 
                                                        |
| 982 | + );  | 
                                                        |
| 983 | + }  | 
                                                        |
| 984 | +  | 
                                                        |
| 985 | +  | 
                                                        |
| 986 | + /**  | 
                                                        |
| 987 | + * @deprecated 4.9.27  | 
                                                        |
| 988 | + * @throws InvalidInterfaceException  | 
                                                        |
| 989 | + * @throws InvalidDataTypeException  | 
                                                        |
| 990 | + * @throws DomainException  | 
                                                        |
| 991 | + */  | 
                                                        |
| 992 | + public function dismiss_ee_nag_notice_callback()  | 
                                                        |
| 993 | +	{ | 
                                                        |
| 994 | + EE_Error::doing_it_wrong(  | 
                                                        |
| 995 | + __METHOD__,  | 
                                                        |
| 996 | + sprintf(  | 
                                                        |
| 997 | +				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), | 
                                                        |
| 998 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'  | 
                                                        |
| 999 | + ),  | 
                                                        |
| 1000 | + '4.9.27'  | 
                                                        |
| 1001 | + );  | 
                                                        |
| 1002 | + $this->persistent_admin_notice_manager->dismissNotice();  | 
                                                        |
| 1003 | + }  | 
                                                        |
| 1004 | +  | 
                                                        |
| 1005 | +  | 
                                                        |
| 1006 | + /**  | 
                                                        |
| 1007 | + * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.  | 
                                                        |
| 1008 | + *  | 
                                                        |
| 1009 | + * @throws InvalidArgumentException  | 
                                                        |
| 1010 | + * @throws InvalidDataTypeException  | 
                                                        |
| 1011 | + * @throws InvalidInterfaceException  | 
                                                        |
| 1012 | + */  | 
                                                        |
| 1013 | + public function hookIntoWpPluginsPage()  | 
                                                        |
| 1014 | +	{ | 
                                                        |
| 1015 | +		$this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal'); | 
                                                        |
| 1016 | + $this->getLoader()  | 
                                                        |
| 1017 | +					 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells') | 
                                                        |
| 1018 | + ->decafUpsells();  | 
                                                        |
| 1019 | + }  | 
                                                        |
| 1020 | +  | 
                                                        |
| 1021 | +  | 
                                                        |
| 1022 | + /**  | 
                                                        |
| 1023 | + * Hooks into the "post states" filter in a wp post type list table.  | 
                                                        |
| 1024 | + *  | 
                                                        |
| 1025 | + * @param array $post_states  | 
                                                        |
| 1026 | + * @param WP_Post $post  | 
                                                        |
| 1027 | + * @return array  | 
                                                        |
| 1028 | + * @throws InvalidArgumentException  | 
                                                        |
| 1029 | + * @throws InvalidDataTypeException  | 
                                                        |
| 1030 | + * @throws InvalidInterfaceException  | 
                                                        |
| 1031 | + */  | 
                                                        |
| 1032 | + public function displayStateForCriticalPages($post_states, $post)  | 
                                                        |
| 1033 | +	{ | 
                                                        |
| 1034 | + $post_states = (array) $post_states;  | 
                                                        |
| 1035 | +		if (! $post instanceof WP_Post || $post->post_type !== 'page') { | 
                                                        |
| 1036 | + return $post_states;  | 
                                                        |
| 1037 | + }  | 
                                                        |
| 1038 | + /** @var EE_Core_Config $config */  | 
                                                        |
| 1039 | +		$config = $this->getLoader()->getShared('EE_Config')->core; | 
                                                        |
| 1040 | +		if (in_array($post->ID, $config->get_critical_pages_array(), true)) { | 
                                                        |
| 1041 | + $post_states[] = sprintf(  | 
                                                        |
| 1042 | + /* Translators: Using company name - Event Espresso Critical Page */  | 
                                                        |
| 1043 | +				esc_html__('%s Critical Page', 'event_espresso'), | 
                                                        |
| 1044 | + 'Event Espresso'  | 
                                                        |
| 1045 | + );  | 
                                                        |
| 1046 | + }  | 
                                                        |
| 1047 | + return $post_states;  | 
                                                        |
| 1048 | + }  | 
                                                        |
| 1049 | +  | 
                                                        |
| 1050 | +  | 
                                                        |
| 1051 | + /**  | 
                                                        |
| 1052 | + * Show documentation links on the plugins page  | 
                                                        |
| 1053 | + *  | 
                                                        |
| 1054 | + * @param mixed $meta Plugin Row Meta  | 
                                                        |
| 1055 | + * @param mixed $file Plugin Base file  | 
                                                        |
| 1056 | + * @return array  | 
                                                        |
| 1057 | + */  | 
                                                        |
| 1058 | + public function addLinksToPluginRowMeta($meta, $file)  | 
                                                        |
| 1059 | +	{ | 
                                                        |
| 1060 | +		if (EE_PLUGIN_BASENAME === $file) { | 
                                                        |
| 1061 | + $row_meta = array(  | 
                                                        |
| 1062 | + 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'  | 
                                                        |
| 1063 | + . ' aria-label="'  | 
                                                        |
| 1064 | +						  . esc_attr__('View Event Espresso documentation', 'event_espresso') | 
                                                        |
| 1065 | + . '">'  | 
                                                        |
| 1066 | +						  . esc_html__('Docs', 'event_espresso') | 
                                                        |
| 1067 | + . '</a>',  | 
                                                        |
| 1068 | + 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'  | 
                                                        |
| 1069 | + . ' aria-label="'  | 
                                                        |
| 1070 | +						  . esc_attr__('View Event Espresso API docs', 'event_espresso') | 
                                                        |
| 1071 | + . '">'  | 
                                                        |
| 1072 | +						  . esc_html__('API docs', 'event_espresso') | 
                                                        |
| 1073 | + . '</a>',  | 
                                                        |
| 1074 | + );  | 
                                                        |
| 1075 | + return array_merge($meta, $row_meta);  | 
                                                        |
| 1076 | + }  | 
                                                        |
| 1077 | + return (array) $meta;  | 
                                                        |
| 1078 | + }  | 
                                                        |
| 1079 | 1079 | }  | 
                                                        
@@ -17,880 +17,880 @@  | 
                                                    ||
| 17 | 17 |  { | 
                                                        
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /**  | 
                                                        |
| 21 | - * @var EE_Form_Section_Proper  | 
                                                        |
| 22 | - */  | 
                                                        |
| 23 | - protected $datetime_fix_offset_form;  | 
                                                        |
| 24 | -  | 
                                                        |
| 25 | -  | 
                                                        |
| 26 | - protected function _init_page_props()  | 
                                                        |
| 27 | -    { | 
                                                        |
| 28 | - $this->page_slug = EE_MAINTENANCE_PG_SLUG;  | 
                                                        |
| 29 | - $this->page_label = EE_MAINTENANCE_LABEL;  | 
                                                        |
| 30 | - $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;  | 
                                                        |
| 31 | - $this->_admin_base_path = EE_MAINTENANCE_ADMIN;  | 
                                                        |
| 32 | - }  | 
                                                        |
| 33 | -  | 
                                                        |
| 34 | -  | 
                                                        |
| 35 | - protected function _ajax_hooks()  | 
                                                        |
| 36 | -    { | 
                                                        |
| 37 | -        add_action('wp_ajax_migration_step', array($this, 'migration_step')); | 
                                                        |
| 38 | -        add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); | 
                                                        |
| 39 | - }  | 
                                                        |
| 40 | -  | 
                                                        |
| 41 | -  | 
                                                        |
| 42 | - protected function _define_page_props()  | 
                                                        |
| 43 | -    { | 
                                                        |
| 44 | - $this->_admin_page_title = EE_MAINTENANCE_LABEL;  | 
                                                        |
| 45 | - $this->_labels = array(  | 
                                                        |
| 46 | - 'buttons' => array(  | 
                                                        |
| 47 | -                'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), | 
                                                        |
| 48 | -                'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), | 
                                                        |
| 49 | - ),  | 
                                                        |
| 50 | - );  | 
                                                        |
| 51 | - }  | 
                                                        |
| 52 | -  | 
                                                        |
| 53 | -  | 
                                                        |
| 54 | - protected function _set_page_routes()  | 
                                                        |
| 55 | -    { | 
                                                        |
| 56 | - $this->_page_routes = array(  | 
                                                        |
| 57 | - 'default' => array(  | 
                                                        |
| 58 | - 'func' => '_maintenance',  | 
                                                        |
| 59 | - 'capability' => 'manage_options',  | 
                                                        |
| 60 | - ),  | 
                                                        |
| 61 | - 'change_maintenance_level' => array(  | 
                                                        |
| 62 | - 'func' => '_change_maintenance_level',  | 
                                                        |
| 63 | - 'capability' => 'manage_options',  | 
                                                        |
| 64 | - 'noheader' => true,  | 
                                                        |
| 65 | - ),  | 
                                                        |
| 66 | - 'system_status' => array(  | 
                                                        |
| 67 | - 'func' => '_system_status',  | 
                                                        |
| 68 | - 'capability' => 'manage_options',  | 
                                                        |
| 69 | - ),  | 
                                                        |
| 70 | - 'download_system_status' => array(  | 
                                                        |
| 71 | - 'func' => '_download_system_status',  | 
                                                        |
| 72 | - 'capability' => 'manage_options',  | 
                                                        |
| 73 | - 'noheader' => true,  | 
                                                        |
| 74 | - ),  | 
                                                        |
| 75 | - 'send_migration_crash_report' => array(  | 
                                                        |
| 76 | - 'func' => '_send_migration_crash_report',  | 
                                                        |
| 77 | - 'capability' => 'manage_options',  | 
                                                        |
| 78 | - 'noheader' => true,  | 
                                                        |
| 79 | - ),  | 
                                                        |
| 80 | - 'confirm_migration_crash_report_sent' => array(  | 
                                                        |
| 81 | - 'func' => '_confirm_migration_crash_report_sent',  | 
                                                        |
| 82 | - 'capability' => 'manage_options',  | 
                                                        |
| 83 | - ),  | 
                                                        |
| 84 | - 'data_reset' => array(  | 
                                                        |
| 85 | - 'func' => '_data_reset_and_delete',  | 
                                                        |
| 86 | - 'capability' => 'manage_options',  | 
                                                        |
| 87 | - ),  | 
                                                        |
| 88 | - 'reset_db' => array(  | 
                                                        |
| 89 | - 'func' => '_reset_db',  | 
                                                        |
| 90 | - 'capability' => 'manage_options',  | 
                                                        |
| 91 | - 'noheader' => true,  | 
                                                        |
| 92 | -                'args'       => array('nuke_old_ee4_data' => true), | 
                                                        |
| 93 | - ),  | 
                                                        |
| 94 | - 'start_with_fresh_ee4_db' => array(  | 
                                                        |
| 95 | - 'func' => '_reset_db',  | 
                                                        |
| 96 | - 'capability' => 'manage_options',  | 
                                                        |
| 97 | - 'noheader' => true,  | 
                                                        |
| 98 | -                'args'       => array('nuke_old_ee4_data' => false), | 
                                                        |
| 99 | - ),  | 
                                                        |
| 100 | - 'delete_db' => array(  | 
                                                        |
| 101 | - 'func' => '_delete_db',  | 
                                                        |
| 102 | - 'capability' => 'manage_options',  | 
                                                        |
| 103 | - 'noheader' => true,  | 
                                                        |
| 104 | - ),  | 
                                                        |
| 105 | - 'rerun_migration_from_ee3' => array(  | 
                                                        |
| 106 | - 'func' => '_rerun_migration_from_ee3',  | 
                                                        |
| 107 | - 'capability' => 'manage_options',  | 
                                                        |
| 108 | - 'noheader' => true,  | 
                                                        |
| 109 | - ),  | 
                                                        |
| 110 | - 'reset_reservations' => array(  | 
                                                        |
| 111 | - 'func' => '_reset_reservations',  | 
                                                        |
| 112 | - 'capability' => 'manage_options',  | 
                                                        |
| 113 | - 'noheader' => true,  | 
                                                        |
| 114 | - ),  | 
                                                        |
| 115 | - 'reset_capabilities' => array(  | 
                                                        |
| 116 | - 'func' => '_reset_capabilities',  | 
                                                        |
| 117 | - 'capability' => 'manage_options',  | 
                                                        |
| 118 | - 'noheader' => true,  | 
                                                        |
| 119 | - ),  | 
                                                        |
| 120 | - 'reattempt_migration' => array(  | 
                                                        |
| 121 | - 'func' => '_reattempt_migration',  | 
                                                        |
| 122 | - 'capability' => 'manage_options',  | 
                                                        |
| 123 | - 'noheader' => true,  | 
                                                        |
| 124 | - ),  | 
                                                        |
| 125 | - 'datetime_tools' => array(  | 
                                                        |
| 126 | - 'func' => '_datetime_tools',  | 
                                                        |
| 127 | - 'capability' => 'manage_options',  | 
                                                        |
| 128 | - ),  | 
                                                        |
| 129 | - 'run_datetime_offset_fix' => array(  | 
                                                        |
| 130 | - 'func' => '_apply_datetime_offset',  | 
                                                        |
| 131 | - 'noheader' => true,  | 
                                                        |
| 132 | - 'headers_sent_route' => 'datetime_tools',  | 
                                                        |
| 133 | - 'capability' => 'manage_options',  | 
                                                        |
| 134 | - ),  | 
                                                        |
| 135 | - );  | 
                                                        |
| 136 | - }  | 
                                                        |
| 137 | -  | 
                                                        |
| 138 | -  | 
                                                        |
| 139 | - protected function _set_page_config()  | 
                                                        |
| 140 | -    { | 
                                                        |
| 141 | - $this->_page_config = array(  | 
                                                        |
| 142 | - 'default' => array(  | 
                                                        |
| 143 | - 'nav' => array(  | 
                                                        |
| 144 | -                    'label' => esc_html__('Maintenance', 'event_espresso'), | 
                                                        |
| 145 | - 'order' => 10,  | 
                                                        |
| 146 | - ),  | 
                                                        |
| 147 | - 'require_nonce' => false,  | 
                                                        |
| 148 | - ),  | 
                                                        |
| 149 | - 'data_reset' => array(  | 
                                                        |
| 150 | - 'nav' => array(  | 
                                                        |
| 151 | -                    'label' => esc_html__('Reset/Delete Data', 'event_espresso'), | 
                                                        |
| 152 | - 'order' => 20,  | 
                                                        |
| 153 | - ),  | 
                                                        |
| 154 | - 'require_nonce' => false,  | 
                                                        |
| 155 | - ),  | 
                                                        |
| 156 | - 'datetime_tools' => array(  | 
                                                        |
| 157 | - 'nav' => array(  | 
                                                        |
| 158 | -                    'label' => esc_html__('Datetime Utilities', 'event_espresso'), | 
                                                        |
| 159 | - 'order' => 25,  | 
                                                        |
| 160 | - ),  | 
                                                        |
| 161 | - 'require_nonce' => false,  | 
                                                        |
| 162 | - ),  | 
                                                        |
| 163 | - 'system_status' => array(  | 
                                                        |
| 164 | - 'nav' => array(  | 
                                                        |
| 165 | -                    'label' => esc_html__("System Information", "event_espresso"), | 
                                                        |
| 166 | - 'order' => 30,  | 
                                                        |
| 167 | - ),  | 
                                                        |
| 168 | - 'require_nonce' => false,  | 
                                                        |
| 169 | - ),  | 
                                                        |
| 170 | - );  | 
                                                        |
| 171 | - }  | 
                                                        |
| 172 | -  | 
                                                        |
| 173 | -  | 
                                                        |
| 174 | - /**  | 
                                                        |
| 175 | - * default maintenance page. If we're in maintenance mode level 2, then we need to show  | 
                                                        |
| 176 | - * the migration scripts and all that UI.  | 
                                                        |
| 177 | - */  | 
                                                        |
| 178 | - public function _maintenance()  | 
                                                        |
| 179 | -    { | 
                                                        |
| 180 | - // it all depends if we're in maintenance model level 1 (frontend-only) or  | 
                                                        |
| 181 | - // level 2 (everything except maintenance page)  | 
                                                        |
| 182 | -        try { | 
                                                        |
| 183 | - // get the current maintenance level and check if  | 
                                                        |
| 184 | - // we are removed  | 
                                                        |
| 185 | - $mm = EE_Maintenance_Mode::instance()->level();  | 
                                                        |
| 186 | - $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();  | 
                                                        |
| 187 | -            if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { | 
                                                        |
| 188 | - // we just took the site out of maintenance mode, so notify the user.  | 
                                                        |
| 189 | - // unfortunately this message appears to be echoed on the NEXT page load...  | 
                                                        |
| 190 | - // oh well, we should really be checking for this on addon deactivation anyways  | 
                                                        |
| 191 | - EE_Error::add_attention(  | 
                                                        |
| 192 | - __(  | 
                                                        |
| 193 | - 'Site taken out of maintenance mode because no data migration scripts are required',  | 
                                                        |
| 194 | - 'event_espresso'  | 
                                                        |
| 195 | - )  | 
                                                        |
| 196 | - );  | 
                                                        |
| 197 | -                $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); | 
                                                        |
| 198 | - }  | 
                                                        |
| 199 | - // in case an exception is thrown while trying to handle migrations  | 
                                                        |
| 200 | -            switch (EE_Maintenance_Mode::instance()->level()) { | 
                                                        |
| 201 | - case EE_Maintenance_Mode::level_0_not_in_maintenance:  | 
                                                        |
| 202 | - case EE_Maintenance_Mode::level_1_frontend_only_maintenance:  | 
                                                        |
| 203 | - $show_maintenance_switch = true;  | 
                                                        |
| 204 | - $show_backup_db_text = false;  | 
                                                        |
| 205 | - $show_migration_progress = false;  | 
                                                        |
| 206 | - $script_names = array();  | 
                                                        |
| 207 | - $addons_should_be_upgraded_first = false;  | 
                                                        |
| 208 | - break;  | 
                                                        |
| 209 | - case EE_Maintenance_Mode::level_2_complete_maintenance:  | 
                                                        |
| 210 | - $show_maintenance_switch = false;  | 
                                                        |
| 211 | - $show_migration_progress = true;  | 
                                                        |
| 212 | -                    if (isset($this->_req_data['continue_migration'])) { | 
                                                        |
| 213 | - $show_backup_db_text = false;  | 
                                                        |
| 214 | -                    } else { | 
                                                        |
| 215 | - $show_backup_db_text = true;  | 
                                                        |
| 216 | - }  | 
                                                        |
| 217 | - $scripts_needing_to_run = EE_Data_Migration_Manager::instance()  | 
                                                        |
| 218 | - ->check_for_applicable_data_migration_scripts();  | 
                                                        |
| 219 | - $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();  | 
                                                        |
| 220 | - $script_names = array();  | 
                                                        |
| 221 | - $current_script = null;  | 
                                                        |
| 222 | -                    foreach ($scripts_needing_to_run as $script) { | 
                                                        |
| 223 | -                        if ($script instanceof EE_Data_Migration_Script_Base) { | 
                                                        |
| 224 | -                            if (! $current_script) { | 
                                                        |
| 225 | - $current_script = $script;  | 
                                                        |
| 226 | - $current_script->migration_page_hooks();  | 
                                                        |
| 227 | - }  | 
                                                        |
| 228 | - $script_names[] = $script->pretty_name();  | 
                                                        |
| 229 | - }  | 
                                                        |
| 230 | - }  | 
                                                        |
| 231 | - break;  | 
                                                        |
| 232 | - }  | 
                                                        |
| 233 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);  | 
                                                        |
| 234 | - $exception_thrown = false;  | 
                                                        |
| 235 | -        } catch (EE_Error $e) { | 
                                                        |
| 236 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());  | 
                                                        |
| 237 | - // now, just so we can display the page correctly, make a error migration script stage object  | 
                                                        |
| 238 | - // and also put the error on it. It only persists for the duration of this request  | 
                                                        |
| 239 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0();  | 
                                                        |
| 240 | - $most_recent_migration->add_error($e->getMessage());  | 
                                                        |
| 241 | - $exception_thrown = true;  | 
                                                        |
| 242 | - }  | 
                                                        |
| 243 | - $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();  | 
                                                        |
| 244 | -        $current_db_state = str_replace('.decaf', '', $current_db_state); | 
                                                        |
| 245 | - if ($exception_thrown  | 
                                                        |
| 246 | - || ($most_recent_migration  | 
                                                        |
| 247 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base  | 
                                                        |
| 248 | - && $most_recent_migration->is_broken()  | 
                                                        |
| 249 | - )  | 
                                                        |
| 250 | -        ) { | 
                                                        |
| 251 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';  | 
                                                        |
| 252 | - $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';  | 
                                                        |
| 253 | - $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(  | 
                                                        |
| 254 | - array(  | 
                                                        |
| 255 | - 'action' => 'confirm_migration_crash_report_sent',  | 
                                                        |
| 256 | - 'success' => '0',  | 
                                                        |
| 257 | - ),  | 
                                                        |
| 258 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 259 | - );  | 
                                                        |
| 260 | -        } elseif ($addons_should_be_upgraded_first) { | 
                                                        |
| 261 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';  | 
                                                        |
| 262 | -        } else { | 
                                                        |
| 263 | - if ($most_recent_migration  | 
                                                        |
| 264 | - && $most_recent_migration instanceof EE_Data_Migration_Script_Base  | 
                                                        |
| 265 | - && $most_recent_migration->can_continue()  | 
                                                        |
| 266 | -            ) { | 
                                                        |
| 267 | - $show_backup_db_text = false;  | 
                                                        |
| 268 | - $show_continue_current_migration_script = true;  | 
                                                        |
| 269 | - $show_most_recent_migration = true;  | 
                                                        |
| 270 | -            } elseif (isset($this->_req_data['continue_migration'])) { | 
                                                        |
| 271 | - $show_most_recent_migration = true;  | 
                                                        |
| 272 | - $show_continue_current_migration_script = false;  | 
                                                        |
| 273 | -            } else { | 
                                                        |
| 274 | - $show_most_recent_migration = false;  | 
                                                        |
| 275 | - $show_continue_current_migration_script = false;  | 
                                                        |
| 276 | - }  | 
                                                        |
| 277 | -            if (isset($current_script)) { | 
                                                        |
| 278 | - $migrates_to = $current_script->migrates_to_version();  | 
                                                        |
| 279 | - $plugin_slug = $migrates_to['slug'];  | 
                                                        |
| 280 | - $new_version = $migrates_to['version'];  | 
                                                        |
| 281 | - $this->_template_args = array_merge(  | 
                                                        |
| 282 | - $this->_template_args,  | 
                                                        |
| 283 | - array(  | 
                                                        |
| 284 | - 'current_db_state' => sprintf(  | 
                                                        |
| 285 | -                            __("EE%s (%s)", "event_espresso"), | 
                                                        |
| 286 | - isset($current_db_state[ $plugin_slug ]) ? $current_db_state[ $plugin_slug ] : 3,  | 
                                                        |
| 287 | - $plugin_slug  | 
                                                        |
| 288 | - ),  | 
                                                        |
| 289 | - 'next_db_state' => isset($current_script) ? sprintf(  | 
                                                        |
| 290 | -                            __("EE%s (%s)", 'event_espresso'), | 
                                                        |
| 291 | - $new_version,  | 
                                                        |
| 292 | - $plugin_slug  | 
                                                        |
| 293 | - ) : null,  | 
                                                        |
| 294 | - )  | 
                                                        |
| 295 | - );  | 
                                                        |
| 296 | -            } else { | 
                                                        |
| 297 | - $this->_template_args['current_db_state'] = null;  | 
                                                        |
| 298 | - $this->_template_args['next_db_state'] = null;  | 
                                                        |
| 299 | - }  | 
                                                        |
| 300 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';  | 
                                                        |
| 301 | - $this->_template_args = array_merge(  | 
                                                        |
| 302 | - $this->_template_args,  | 
                                                        |
| 303 | - array(  | 
                                                        |
| 304 | - 'show_most_recent_migration' => $show_most_recent_migration,  | 
                                                        |
| 305 | - // flag for showing the most recent migration's status and/or errors  | 
                                                        |
| 306 | - 'show_migration_progress' => $show_migration_progress,  | 
                                                        |
| 307 | - // flag for showing the option to run migrations and see their progress  | 
                                                        |
| 308 | - 'show_backup_db_text' => $show_backup_db_text,  | 
                                                        |
| 309 | - // flag for showing text telling the user to backup their DB  | 
                                                        |
| 310 | - 'show_maintenance_switch' => $show_maintenance_switch,  | 
                                                        |
| 311 | - // flag for showing the option to change maintenance mode between levels 0 and 1  | 
                                                        |
| 312 | - 'script_names' => $script_names,  | 
                                                        |
| 313 | - // array of names of scripts that have run  | 
                                                        |
| 314 | - 'show_continue_current_migration_script' => $show_continue_current_migration_script,  | 
                                                        |
| 315 | - // flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0  | 
                                                        |
| 316 | - 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 317 | -                        array('action' => 'reset_db'), | 
                                                        |
| 318 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 319 | - ),  | 
                                                        |
| 320 | - 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 321 | -                        array('action' => 'data_reset'), | 
                                                        |
| 322 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 323 | - ),  | 
                                                        |
| 324 | - 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 325 | -                        array('action' => 'change_maintenance_level'), | 
                                                        |
| 326 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 327 | - ),  | 
                                                        |
| 328 | - 'ultimate_db_state' => sprintf(  | 
                                                        |
| 329 | -                        __("EE%s", 'event_espresso'), | 
                                                        |
| 330 | - espresso_version()  | 
                                                        |
| 331 | - ),  | 
                                                        |
| 332 | - )  | 
                                                        |
| 333 | - );  | 
                                                        |
| 334 | - // make sure we have the form fields helper available. It usually is, but sometimes it isn't  | 
                                                        |
| 335 | - }  | 
                                                        |
| 336 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;// the actual most recently ran migration  | 
                                                        |
| 337 | - // now render the migration options part, and put it in a variable  | 
                                                        |
| 338 | - $migration_options_template_file = apply_filters(  | 
                                                        |
| 339 | - 'FHEE__ee_migration_page__migration_options_template',  | 
                                                        |
| 340 | - EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'  | 
                                                        |
| 341 | - );  | 
                                                        |
| 342 | - $migration_options_html = EEH_Template::display_template(  | 
                                                        |
| 343 | - $migration_options_template_file,  | 
                                                        |
| 344 | - $this->_template_args,  | 
                                                        |
| 345 | - true  | 
                                                        |
| 346 | - );  | 
                                                        |
| 347 | - $this->_template_args['migration_options_html'] = $migration_options_html;  | 
                                                        |
| 348 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 349 | - $this->_template_path,  | 
                                                        |
| 350 | - $this->_template_args,  | 
                                                        |
| 351 | - true  | 
                                                        |
| 352 | - );  | 
                                                        |
| 353 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 354 | - }  | 
                                                        |
| 355 | -  | 
                                                        |
| 356 | -  | 
                                                        |
| 357 | - /**  | 
                                                        |
| 358 | - * returns JSON and executes another step of the currently-executing data migration (called via ajax)  | 
                                                        |
| 359 | - */  | 
                                                        |
| 360 | - public function migration_step()  | 
                                                        |
| 361 | -    { | 
                                                        |
| 362 | - $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();  | 
                                                        |
| 363 | - $this->_return_json();  | 
                                                        |
| 364 | - }  | 
                                                        |
| 365 | -  | 
                                                        |
| 366 | -  | 
                                                        |
| 367 | - /**  | 
                                                        |
| 368 | - * Can be used by js when it notices a response with HTML in it in order  | 
                                                        |
| 369 | - * to log the malformed response  | 
                                                        |
| 370 | - */  | 
                                                        |
| 371 | - public function add_error_to_migrations_ran()  | 
                                                        |
| 372 | -    { | 
                                                        |
| 373 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);  | 
                                                        |
| 374 | -        $this->_template_args['data'] = array('ok' => true); | 
                                                        |
| 375 | - $this->_return_json();  | 
                                                        |
| 376 | - }  | 
                                                        |
| 377 | -  | 
                                                        |
| 378 | -  | 
                                                        |
| 379 | - /**  | 
                                                        |
| 380 | - * changes the maintenance level, provided there are still no migration scripts that should run  | 
                                                        |
| 381 | - */  | 
                                                        |
| 382 | - public function _change_maintenance_level()  | 
                                                        |
| 383 | -    { | 
                                                        |
| 384 | - $new_level = absint($this->_req_data['maintenance_mode_level']);  | 
                                                        |
| 385 | -        if (! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { | 
                                                        |
| 386 | - EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);  | 
                                                        |
| 387 | - $success = true;  | 
                                                        |
| 388 | -        } else { | 
                                                        |
| 389 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();  | 
                                                        |
| 390 | - $success = false;  | 
                                                        |
| 391 | - }  | 
                                                        |
| 392 | -        $this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); | 
                                                        |
| 393 | - }  | 
                                                        |
| 394 | -  | 
                                                        |
| 395 | -  | 
                                                        |
| 396 | - /**  | 
                                                        |
| 397 | - * a tab with options for resetting and/or deleting EE data  | 
                                                        |
| 398 | - *  | 
                                                        |
| 399 | - * @throws \EE_Error  | 
                                                        |
| 400 | - * @throws \DomainException  | 
                                                        |
| 401 | - */  | 
                                                        |
| 402 | - public function _data_reset_and_delete()  | 
                                                        |
| 403 | -    { | 
                                                        |
| 404 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';  | 
                                                        |
| 405 | - $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(  | 
                                                        |
| 406 | - 'reset_reservations',  | 
                                                        |
| 407 | - 'reset_reservations',  | 
                                                        |
| 408 | - array(),  | 
                                                        |
| 409 | - 'button button-primary ee-confirm',  | 
                                                        |
| 410 | - '',  | 
                                                        |
| 411 | - false  | 
                                                        |
| 412 | - );  | 
                                                        |
| 413 | - $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(  | 
                                                        |
| 414 | - 'reset_capabilities',  | 
                                                        |
| 415 | - 'reset_capabilities',  | 
                                                        |
| 416 | - array(),  | 
                                                        |
| 417 | - 'button button-primary ee-confirm',  | 
                                                        |
| 418 | - '',  | 
                                                        |
| 419 | - false  | 
                                                        |
| 420 | - );  | 
                                                        |
| 421 | - $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 422 | -            array('action' => 'delete_db'), | 
                                                        |
| 423 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 424 | - );  | 
                                                        |
| 425 | - $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 426 | -            array('action' => 'reset_db'), | 
                                                        |
| 427 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 428 | - );  | 
                                                        |
| 429 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 430 | - $this->_template_path,  | 
                                                        |
| 431 | - $this->_template_args,  | 
                                                        |
| 432 | - true  | 
                                                        |
| 433 | - );  | 
                                                        |
| 434 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 435 | - }  | 
                                                        |
| 436 | -  | 
                                                        |
| 437 | -  | 
                                                        |
| 438 | - protected function _reset_reservations()  | 
                                                        |
| 439 | -    { | 
                                                        |
| 440 | -        if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { | 
                                                        |
| 441 | - EE_Error::add_success(  | 
                                                        |
| 442 | - __(  | 
                                                        |
| 443 | - 'Ticket and datetime reserved counts have been successfully reset.',  | 
                                                        |
| 444 | - 'event_espresso'  | 
                                                        |
| 445 | - )  | 
                                                        |
| 446 | - );  | 
                                                        |
| 447 | -        } else { | 
                                                        |
| 448 | - EE_Error::add_success(  | 
                                                        |
| 449 | - __(  | 
                                                        |
| 450 | - 'Ticket and datetime reserved counts were correct and did not need resetting.',  | 
                                                        |
| 451 | - 'event_espresso'  | 
                                                        |
| 452 | - )  | 
                                                        |
| 453 | - );  | 
                                                        |
| 454 | - }  | 
                                                        |
| 455 | -        $this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); | 
                                                        |
| 456 | - }  | 
                                                        |
| 457 | -  | 
                                                        |
| 458 | -  | 
                                                        |
| 459 | - protected function _reset_capabilities()  | 
                                                        |
| 460 | -    { | 
                                                        |
| 461 | - EE_Registry::instance()->CAP->init_caps(true);  | 
                                                        |
| 462 | - EE_Error::add_success(  | 
                                                        |
| 463 | - __(  | 
                                                        |
| 464 | - 'Default Event Espresso capabilities have been restored for all current roles.',  | 
                                                        |
| 465 | - 'event_espresso'  | 
                                                        |
| 466 | - )  | 
                                                        |
| 467 | - );  | 
                                                        |
| 468 | -        $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); | 
                                                        |
| 469 | - }  | 
                                                        |
| 470 | -  | 
                                                        |
| 471 | -  | 
                                                        |
| 472 | - /**  | 
                                                        |
| 473 | - * resets the DMSs so we can attempt to continue migrating after a fatal error  | 
                                                        |
| 474 | - * (only a good idea when someone has somehow tried ot fix whatever caused  | 
                                                        |
| 475 | - * the fatal error in teh first place)  | 
                                                        |
| 476 | - */  | 
                                                        |
| 477 | - protected function _reattempt_migration()  | 
                                                        |
| 478 | -    { | 
                                                        |
| 479 | - EE_Data_Migration_Manager::instance()->reattempt();  | 
                                                        |
| 480 | -        $this->_redirect_after_action(false, '', '', array('action' => 'default'), true); | 
                                                        |
| 481 | - }  | 
                                                        |
| 482 | -  | 
                                                        |
| 483 | -  | 
                                                        |
| 484 | - /**  | 
                                                        |
| 485 | - * shows the big ol' System Information page  | 
                                                        |
| 486 | - */  | 
                                                        |
| 487 | - public function _system_status()  | 
                                                        |
| 488 | -    { | 
                                                        |
| 489 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';  | 
                                                        |
| 490 | - $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();  | 
                                                        |
| 491 | - $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 492 | - array(  | 
                                                        |
| 493 | - 'action' => 'download_system_status',  | 
                                                        |
| 494 | - ),  | 
                                                        |
| 495 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 496 | - );  | 
                                                        |
| 497 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 498 | - $this->_template_path,  | 
                                                        |
| 499 | - $this->_template_args,  | 
                                                        |
| 500 | - true  | 
                                                        |
| 501 | - );  | 
                                                        |
| 502 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 503 | - }  | 
                                                        |
| 504 | -  | 
                                                        |
| 505 | - /**  | 
                                                        |
| 506 | - * Downloads an HTML file of the system status that can be easily stored or emailed  | 
                                                        |
| 507 | - */  | 
                                                        |
| 508 | - public function _download_system_status()  | 
                                                        |
| 509 | -    { | 
                                                        |
| 510 | - $status_info = EEM_System_Status::instance()->get_system_stati();  | 
                                                        |
| 511 | -        header('Content-Disposition: attachment'); | 
                                                        |
| 512 | -        header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html"); | 
                                                        |
| 513 | -        echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; | 
                                                        |
| 514 | - echo "<h1>System Information for " . site_url() . "</h1>";  | 
                                                        |
| 515 | - echo EEH_Template::layout_array_as_table($status_info);  | 
                                                        |
| 516 | - die;  | 
                                                        |
| 517 | - }  | 
                                                        |
| 518 | -  | 
                                                        |
| 519 | -  | 
                                                        |
| 520 | - public function _send_migration_crash_report()  | 
                                                        |
| 521 | -    { | 
                                                        |
| 522 | - $from = $this->_req_data['from'];  | 
                                                        |
| 523 | - $from_name = $this->_req_data['from_name'];  | 
                                                        |
| 524 | - $body = $this->_req_data['body'];  | 
                                                        |
| 525 | -        try { | 
                                                        |
| 526 | - $success = wp_mail(  | 
                                                        |
| 527 | - EE_SUPPORT_EMAIL,  | 
                                                        |
| 528 | - 'Migration Crash Report',  | 
                                                        |
| 529 | - $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),  | 
                                                        |
| 530 | - array(  | 
                                                        |
| 531 | - "from:$from_name<$from>",  | 
                                                        |
| 532 | - )  | 
                                                        |
| 533 | - );  | 
                                                        |
| 534 | -        } catch (Exception $e) { | 
                                                        |
| 535 | - $success = false;  | 
                                                        |
| 536 | - }  | 
                                                        |
| 537 | - $this->_redirect_after_action(  | 
                                                        |
| 538 | - $success,  | 
                                                        |
| 539 | -            esc_html__("Migration Crash Report", "event_espresso"), | 
                                                        |
| 540 | -            esc_html__("sent", "event_espresso"), | 
                                                        |
| 541 | -            array('success' => $success, 'action' => 'confirm_migration_crash_report_sent') | 
                                                        |
| 542 | - );  | 
                                                        |
| 543 | - }  | 
                                                        |
| 544 | -  | 
                                                        |
| 545 | -  | 
                                                        |
| 546 | - public function _confirm_migration_crash_report_sent()  | 
                                                        |
| 547 | -    { | 
                                                        |
| 548 | -        try { | 
                                                        |
| 549 | - $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);  | 
                                                        |
| 550 | -        } catch (EE_Error $e) { | 
                                                        |
| 551 | - EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());  | 
                                                        |
| 552 | - // now, just so we can display the page correctly, make a error migration script stage object  | 
                                                        |
| 553 | - // and also put the error on it. It only persists for the duration of this request  | 
                                                        |
| 554 | - $most_recent_migration = new EE_DMS_Unknown_1_0_0();  | 
                                                        |
| 555 | - $most_recent_migration->add_error($e->getMessage());  | 
                                                        |
| 556 | - }  | 
                                                        |
| 557 | - $success = $this->_req_data['success'] == '1' ? true : false;  | 
                                                        |
| 558 | - $this->_template_args['success'] = $success;  | 
                                                        |
| 559 | - $this->_template_args['most_recent_migration'] = $most_recent_migration;  | 
                                                        |
| 560 | - $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 561 | -            array('action' => 'reset_db'), | 
                                                        |
| 562 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 563 | - );  | 
                                                        |
| 564 | - $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 565 | -            array('action' => 'data_reset'), | 
                                                        |
| 566 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 567 | - );  | 
                                                        |
| 568 | - $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 569 | -            array('action' => 'reattempt_migration'), | 
                                                        |
| 570 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 571 | - );  | 
                                                        |
| 572 | - $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';  | 
                                                        |
| 573 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 574 | - $this->_template_path,  | 
                                                        |
| 575 | - $this->_template_args,  | 
                                                        |
| 576 | - true  | 
                                                        |
| 577 | - );  | 
                                                        |
| 578 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 579 | - }  | 
                                                        |
| 580 | -  | 
                                                        |
| 581 | -  | 
                                                        |
| 582 | - /**  | 
                                                        |
| 583 | - * Resets the entire EE4 database.  | 
                                                        |
| 584 | - * Currently basically only sets up ee4 database for a fresh install- doesn't  | 
                                                        |
| 585 | - * actually clean out the old wp options, or cpts (although does erase old ee table data)  | 
                                                        |
| 586 | - *  | 
                                                        |
| 587 | - * @param boolean $nuke_old_ee4_data controls whether or not we  | 
                                                        |
| 588 | - * destroy the old ee4 data, or just try initializing ee4 default data  | 
                                                        |
| 589 | - */  | 
                                                        |
| 590 | - public function _reset_db($nuke_old_ee4_data = true)  | 
                                                        |
| 591 | -    { | 
                                                        |
| 592 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 593 | -        if ($nuke_old_ee4_data) { | 
                                                        |
| 594 | - EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 595 | - EEH_Activation::delete_all_espresso_tables_and_data(false);  | 
                                                        |
| 596 | - EEH_Activation::remove_cron_tasks();  | 
                                                        |
| 597 | - }  | 
                                                        |
| 598 | - // make sure when we reset the registry's config that it  | 
                                                        |
| 599 | - // switches to using the new singleton  | 
                                                        |
| 600 | - EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);  | 
                                                        |
| 601 | - EE_System::instance()->initialize_db_if_no_migrations_required(true);  | 
                                                        |
| 602 | - EE_System::instance()->redirect_to_about_ee();  | 
                                                        |
| 603 | - }  | 
                                                        |
| 604 | -  | 
                                                        |
| 605 | -  | 
                                                        |
| 606 | - /**  | 
                                                        |
| 607 | - * Deletes ALL EE tables, Records, and Options from the database.  | 
                                                        |
| 608 | - */  | 
                                                        |
| 609 | - public function _delete_db()  | 
                                                        |
| 610 | -    { | 
                                                        |
| 611 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 612 | - EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 613 | - EEH_Activation::delete_all_espresso_tables_and_data();  | 
                                                        |
| 614 | - EEH_Activation::remove_cron_tasks();  | 
                                                        |
| 615 | - EEH_Activation::deactivate_event_espresso();  | 
                                                        |
| 616 | -        wp_safe_redirect(admin_url('plugins.php')); | 
                                                        |
| 617 | - exit;  | 
                                                        |
| 618 | - }  | 
                                                        |
| 619 | -  | 
                                                        |
| 620 | -  | 
                                                        |
| 621 | - /**  | 
                                                        |
| 622 | - * sets up EE4 to rerun the migrations from ee3 to ee4  | 
                                                        |
| 623 | - */  | 
                                                        |
| 624 | - public function _rerun_migration_from_ee3()  | 
                                                        |
| 625 | -    { | 
                                                        |
| 626 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 627 | - EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 628 | - EEH_Activation::delete_all_espresso_tables_and_data(false);  | 
                                                        |
| 629 | - // set the db state to something that will require migrations  | 
                                                        |
| 630 | - update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');  | 
                                                        |
| 631 | - EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);  | 
                                                        |
| 632 | - $this->_redirect_after_action(  | 
                                                        |
| 633 | - true,  | 
                                                        |
| 634 | -            esc_html__("Database", 'event_espresso'), | 
                                                        |
| 635 | -            esc_html__("reset", 'event_espresso') | 
                                                        |
| 636 | - );  | 
                                                        |
| 637 | - }  | 
                                                        |
| 638 | -  | 
                                                        |
| 639 | -  | 
                                                        |
| 640 | - // none of the below group are currently used for Gateway Settings  | 
                                                        |
| 641 | - protected function _add_screen_options()  | 
                                                        |
| 642 | -    { | 
                                                        |
| 643 | - }  | 
                                                        |
| 644 | -  | 
                                                        |
| 645 | -  | 
                                                        |
| 646 | - protected function _add_feature_pointers()  | 
                                                        |
| 647 | -    { | 
                                                        |
| 648 | - }  | 
                                                        |
| 649 | -  | 
                                                        |
| 650 | -  | 
                                                        |
| 651 | - public function admin_init()  | 
                                                        |
| 652 | -    { | 
                                                        |
| 653 | - }  | 
                                                        |
| 654 | -  | 
                                                        |
| 655 | -  | 
                                                        |
| 656 | - public function admin_notices()  | 
                                                        |
| 657 | -    { | 
                                                        |
| 658 | - }  | 
                                                        |
| 659 | -  | 
                                                        |
| 660 | -  | 
                                                        |
| 661 | - public function admin_footer_scripts()  | 
                                                        |
| 662 | -    { | 
                                                        |
| 663 | - }  | 
                                                        |
| 664 | -  | 
                                                        |
| 665 | -  | 
                                                        |
| 666 | - public function load_scripts_styles()  | 
                                                        |
| 667 | -    { | 
                                                        |
| 668 | -        wp_enqueue_script('ee_admin_js'); | 
                                                        |
| 669 | - wp_enqueue_script(  | 
                                                        |
| 670 | - 'ee-maintenance',  | 
                                                        |
| 671 | - EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',  | 
                                                        |
| 672 | -            array('jquery'), | 
                                                        |
| 673 | - EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 674 | - true  | 
                                                        |
| 675 | - );  | 
                                                        |
| 676 | - wp_register_style(  | 
                                                        |
| 677 | - 'espresso_maintenance',  | 
                                                        |
| 678 | - EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',  | 
                                                        |
| 679 | - array(),  | 
                                                        |
| 680 | - EVENT_ESPRESSO_VERSION  | 
                                                        |
| 681 | - );  | 
                                                        |
| 682 | -        wp_enqueue_style('espresso_maintenance'); | 
                                                        |
| 683 | - // localize script stuff  | 
                                                        |
| 684 | - wp_localize_script(  | 
                                                        |
| 685 | - 'ee-maintenance',  | 
                                                        |
| 686 | - 'ee_maintenance',  | 
                                                        |
| 687 | - array(  | 
                                                        |
| 688 | -                'migrating'                        => esc_html__("Updating Database...", "event_espresso"), | 
                                                        |
| 689 | -                'next'                             => esc_html__("Next", "event_espresso"), | 
                                                        |
| 690 | -                'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"), | 
                                                        |
| 691 | - 'click_next_when_ready' => esc_html__(  | 
                                                        |
| 692 | - "The current Database Update has ended. Click 'next' when ready to proceed",  | 
                                                        |
| 693 | - "event_espresso"  | 
                                                        |
| 694 | - ),  | 
                                                        |
| 695 | - 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,  | 
                                                        |
| 696 | - 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error,  | 
                                                        |
| 697 | - 'status_completed' => EE_Data_Migration_Manager::status_completed,  | 
                                                        |
| 698 | - 'confirm' => esc_html__(  | 
                                                        |
| 699 | - 'Are you sure you want to do this? It CANNOT be undone!',  | 
                                                        |
| 700 | - 'event_espresso'  | 
                                                        |
| 701 | - ),  | 
                                                        |
| 702 | - 'confirm_skip_migration' => esc_html__(  | 
                                                        |
| 703 | - 'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',  | 
                                                        |
| 704 | - 'event_espresso'  | 
                                                        |
| 705 | - ),  | 
                                                        |
| 706 | - )  | 
                                                        |
| 707 | - );  | 
                                                        |
| 708 | - }  | 
                                                        |
| 709 | -  | 
                                                        |
| 710 | -  | 
                                                        |
| 711 | - public function load_scripts_styles_default()  | 
                                                        |
| 712 | -    { | 
                                                        |
| 713 | - }  | 
                                                        |
| 714 | -  | 
                                                        |
| 715 | -  | 
                                                        |
| 716 | - /**  | 
                                                        |
| 717 | - * Enqueue scripts and styles for the datetime tools page.  | 
                                                        |
| 718 | - */  | 
                                                        |
| 719 | - public function load_scripts_styles_datetime_tools()  | 
                                                        |
| 720 | -    { | 
                                                        |
| 721 | - EE_Datepicker_Input::enqueue_styles_and_scripts();  | 
                                                        |
| 722 | - }  | 
                                                        |
| 723 | -  | 
                                                        |
| 724 | -  | 
                                                        |
| 725 | - protected function _datetime_tools()  | 
                                                        |
| 726 | -    { | 
                                                        |
| 727 | - $form_action = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 728 | - array(  | 
                                                        |
| 729 | - 'action' => 'run_datetime_offset_fix',  | 
                                                        |
| 730 | - 'return_action' => $this->_req_action,  | 
                                                        |
| 731 | - ),  | 
                                                        |
| 732 | - EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 733 | - );  | 
                                                        |
| 734 | - $form = $this->_get_datetime_offset_fix_form();  | 
                                                        |
| 735 | -        $this->_admin_page_title = esc_html__('Datetime Utilities', 'event_espresso'); | 
                                                        |
| 736 | - $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')  | 
                                                        |
| 737 | - . $form->get_html_and_js()  | 
                                                        |
| 738 | - . $form->form_close();  | 
                                                        |
| 739 | - $this->display_admin_page_with_no_sidebar();  | 
                                                        |
| 740 | - }  | 
                                                        |
| 741 | -  | 
                                                        |
| 742 | -  | 
                                                        |
| 743 | - protected function _get_datetime_offset_fix_form()  | 
                                                        |
| 744 | -    { | 
                                                        |
| 745 | -        if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { | 
                                                        |
| 746 | - $this->datetime_fix_offset_form = new EE_Form_Section_Proper(  | 
                                                        |
| 747 | - array(  | 
                                                        |
| 748 | - 'name' => 'datetime_offset_fix_option',  | 
                                                        |
| 749 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 750 | - 'subsections' => array(  | 
                                                        |
| 751 | - 'title' => new EE_Form_Section_HTML(  | 
                                                        |
| 752 | - EEH_HTML::h2(  | 
                                                        |
| 753 | -                                esc_html__('Datetime Offset Tool', 'event_espresso') | 
                                                        |
| 754 | - )  | 
                                                        |
| 755 | - ),  | 
                                                        |
| 756 | - 'explanation' => new EE_Form_Section_HTML(  | 
                                                        |
| 757 | - EEH_HTML::p(  | 
                                                        |
| 758 | - esc_html__(  | 
                                                        |
| 759 | - 'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',  | 
                                                        |
| 760 | - 'event_espresso'  | 
                                                        |
| 761 | - )  | 
                                                        |
| 762 | - )  | 
                                                        |
| 763 | - . EEH_HTML::p(  | 
                                                        |
| 764 | - esc_html__(  | 
                                                        |
| 765 | - 'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied. Decimals represent the fraction of hours, not minutes.',  | 
                                                        |
| 766 | - 'event_espresso'  | 
                                                        |
| 767 | - )  | 
                                                        |
| 768 | - )  | 
                                                        |
| 769 | - ),  | 
                                                        |
| 770 | - 'offset_input' => new EE_Float_Input(  | 
                                                        |
| 771 | - array(  | 
                                                        |
| 772 | - 'html_name' => 'offset_for_datetimes',  | 
                                                        |
| 773 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 774 | - 'Offset to apply (in hours):',  | 
                                                        |
| 775 | - 'event_espresso'  | 
                                                        |
| 776 | - ),  | 
                                                        |
| 777 | - 'min_value' => '-12',  | 
                                                        |
| 778 | - 'max_value' => '14',  | 
                                                        |
| 779 | - 'step_value' => '.25',  | 
                                                        |
| 780 | - 'default' => DatetimeOffsetFix::getOffset(),  | 
                                                        |
| 781 | - )  | 
                                                        |
| 782 | - ),  | 
                                                        |
| 783 | - 'date_range_explanation' => new EE_Form_Section_HTML(  | 
                                                        |
| 784 | - EEH_HTML::p(  | 
                                                        |
| 785 | - esc_html__(  | 
                                                        |
| 786 | - 'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',  | 
                                                        |
| 787 | - 'event_espresso'  | 
                                                        |
| 788 | - )  | 
                                                        |
| 789 | - )  | 
                                                        |
| 790 | - . EEH_HTML::p(  | 
                                                        |
| 791 | - EEH_HTML::strong(  | 
                                                        |
| 792 | - sprintf(  | 
                                                        |
| 793 | - esc_html__(  | 
                                                        |
| 794 | - 'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',  | 
                                                        |
| 795 | - 'event_espresso'  | 
                                                        |
| 796 | - ),  | 
                                                        |
| 797 | - '<a href="https://www.timeanddate.com/worldclock/converter.html">',  | 
                                                        |
| 798 | - '</a>'  | 
                                                        |
| 799 | - )  | 
                                                        |
| 800 | - )  | 
                                                        |
| 801 | - )  | 
                                                        |
| 802 | - ),  | 
                                                        |
| 803 | - 'date_range_start_date' => new EE_Datepicker_Input(  | 
                                                        |
| 804 | - array(  | 
                                                        |
| 805 | - 'html_name' => 'offset_date_start_range',  | 
                                                        |
| 806 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 807 | - 'Start Date for dates the offset applied to:',  | 
                                                        |
| 808 | - 'event_espresso'  | 
                                                        |
| 809 | - ),  | 
                                                        |
| 810 | - )  | 
                                                        |
| 811 | - ),  | 
                                                        |
| 812 | - 'date_range_end_date' => new EE_Datepicker_Input(  | 
                                                        |
| 813 | - array(  | 
                                                        |
| 814 | - 'html_name' => 'offset_date_end_range',  | 
                                                        |
| 815 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 816 | - 'End Date for dates the offset is applied to:',  | 
                                                        |
| 817 | - 'event_espresso'  | 
                                                        |
| 818 | - ),  | 
                                                        |
| 819 | - )  | 
                                                        |
| 820 | - ),  | 
                                                        |
| 821 | - 'submit' => new EE_Submit_Input(  | 
                                                        |
| 822 | - array(  | 
                                                        |
| 823 | - 'html_label_text' => '',  | 
                                                        |
| 824 | -                                'default'         => esc_html__('Apply Offset', 'event_espresso'), | 
                                                        |
| 825 | - )  | 
                                                        |
| 826 | - ),  | 
                                                        |
| 827 | - ),  | 
                                                        |
| 828 | - )  | 
                                                        |
| 829 | - );  | 
                                                        |
| 830 | - }  | 
                                                        |
| 831 | - return $this->datetime_fix_offset_form;  | 
                                                        |
| 832 | - }  | 
                                                        |
| 833 | -  | 
                                                        |
| 834 | -  | 
                                                        |
| 835 | - /**  | 
                                                        |
| 836 | - * Callback for the run_datetime_offset_fix route.  | 
                                                        |
| 837 | - *  | 
                                                        |
| 838 | - * @throws EE_Error  | 
                                                        |
| 839 | - */  | 
                                                        |
| 840 | - protected function _apply_datetime_offset()  | 
                                                        |
| 841 | -    { | 
                                                        |
| 842 | -        if ($_SERVER['REQUEST_METHOD'] === 'POST') { | 
                                                        |
| 843 | - $form = $this->_get_datetime_offset_fix_form();  | 
                                                        |
| 844 | - $form->receive_form_submission($this->_req_data);  | 
                                                        |
| 845 | -            if ($form->is_valid()) { | 
                                                        |
| 846 | - // save offset data so batch processor can get it.  | 
                                                        |
| 847 | -                DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input')); | 
                                                        |
| 848 | -                $utc_timezone = new DateTimeZone('UTC'); | 
                                                        |
| 849 | - $date_range_start_date = DateTime::createFromFormat(  | 
                                                        |
| 850 | - 'm/d/Y H:i:s',  | 
                                                        |
| 851 | -                    $form->get_input_value('date_range_start_date') . ' 00:00:00', | 
                                                        |
| 852 | - $utc_timezone  | 
                                                        |
| 853 | - );  | 
                                                        |
| 854 | - $date_range_end_date = DateTime::createFromFormat(  | 
                                                        |
| 855 | - 'm/d/Y H:i:s',  | 
                                                        |
| 856 | -                    $form->get_input_value('date_range_end_date') . ' 23:59:59', | 
                                                        |
| 857 | - $utc_timezone  | 
                                                        |
| 858 | - );  | 
                                                        |
| 859 | -                if ($date_range_start_date instanceof DateTime) { | 
                                                        |
| 860 | - DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));  | 
                                                        |
| 861 | - }  | 
                                                        |
| 862 | -                if ($date_range_end_date instanceof DateTime) { | 
                                                        |
| 863 | - DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));  | 
                                                        |
| 864 | - }  | 
                                                        |
| 865 | - // redirect to batch tool  | 
                                                        |
| 866 | - wp_redirect(  | 
                                                        |
| 867 | - EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 868 | - array(  | 
                                                        |
| 869 | - 'page' => 'espresso_batch',  | 
                                                        |
| 870 | - 'batch' => 'job',  | 
                                                        |
| 871 | -                            'label'       => esc_html__('Applying Offset', 'event_espresso'), | 
                                                        |
| 872 | -                            'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'), | 
                                                        |
| 873 | - 'return_url' => urlencode(  | 
                                                        |
| 874 | - add_query_arg(  | 
                                                        |
| 875 | - array(  | 
                                                        |
| 876 | - 'action' => 'datetime_tools',  | 
                                                        |
| 877 | - ),  | 
                                                        |
| 878 | - EEH_URL::current_url_without_query_paramaters(  | 
                                                        |
| 879 | - array(  | 
                                                        |
| 880 | - 'return_action',  | 
                                                        |
| 881 | - 'run_datetime_offset_fix_nonce',  | 
                                                        |
| 882 | - 'return',  | 
                                                        |
| 883 | - 'datetime_tools_nonce',  | 
                                                        |
| 884 | - )  | 
                                                        |
| 885 | - )  | 
                                                        |
| 886 | - )  | 
                                                        |
| 887 | - ),  | 
                                                        |
| 888 | - ),  | 
                                                        |
| 889 | - admin_url()  | 
                                                        |
| 890 | - )  | 
                                                        |
| 891 | - );  | 
                                                        |
| 892 | - exit;  | 
                                                        |
| 893 | - }  | 
                                                        |
| 894 | - }  | 
                                                        |
| 895 | - }  | 
                                                        |
| 20 | + /**  | 
                                                        |
| 21 | + * @var EE_Form_Section_Proper  | 
                                                        |
| 22 | + */  | 
                                                        |
| 23 | + protected $datetime_fix_offset_form;  | 
                                                        |
| 24 | +  | 
                                                        |
| 25 | +  | 
                                                        |
| 26 | + protected function _init_page_props()  | 
                                                        |
| 27 | +	{ | 
                                                        |
| 28 | + $this->page_slug = EE_MAINTENANCE_PG_SLUG;  | 
                                                        |
| 29 | + $this->page_label = EE_MAINTENANCE_LABEL;  | 
                                                        |
| 30 | + $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;  | 
                                                        |
| 31 | + $this->_admin_base_path = EE_MAINTENANCE_ADMIN;  | 
                                                        |
| 32 | + }  | 
                                                        |
| 33 | +  | 
                                                        |
| 34 | +  | 
                                                        |
| 35 | + protected function _ajax_hooks()  | 
                                                        |
| 36 | +	{ | 
                                                        |
| 37 | +		add_action('wp_ajax_migration_step', array($this, 'migration_step')); | 
                                                        |
| 38 | +		add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran')); | 
                                                        |
| 39 | + }  | 
                                                        |
| 40 | +  | 
                                                        |
| 41 | +  | 
                                                        |
| 42 | + protected function _define_page_props()  | 
                                                        |
| 43 | +	{ | 
                                                        |
| 44 | + $this->_admin_page_title = EE_MAINTENANCE_LABEL;  | 
                                                        |
| 45 | + $this->_labels = array(  | 
                                                        |
| 46 | + 'buttons' => array(  | 
                                                        |
| 47 | +				'reset_reservations' => esc_html__('Reset Ticket and Datetime Reserved Counts', 'event_espresso'), | 
                                                        |
| 48 | +				'reset_capabilities' => esc_html__('Reset Event Espresso Capabilities', 'event_espresso'), | 
                                                        |
| 49 | + ),  | 
                                                        |
| 50 | + );  | 
                                                        |
| 51 | + }  | 
                                                        |
| 52 | +  | 
                                                        |
| 53 | +  | 
                                                        |
| 54 | + protected function _set_page_routes()  | 
                                                        |
| 55 | +	{ | 
                                                        |
| 56 | + $this->_page_routes = array(  | 
                                                        |
| 57 | + 'default' => array(  | 
                                                        |
| 58 | + 'func' => '_maintenance',  | 
                                                        |
| 59 | + 'capability' => 'manage_options',  | 
                                                        |
| 60 | + ),  | 
                                                        |
| 61 | + 'change_maintenance_level' => array(  | 
                                                        |
| 62 | + 'func' => '_change_maintenance_level',  | 
                                                        |
| 63 | + 'capability' => 'manage_options',  | 
                                                        |
| 64 | + 'noheader' => true,  | 
                                                        |
| 65 | + ),  | 
                                                        |
| 66 | + 'system_status' => array(  | 
                                                        |
| 67 | + 'func' => '_system_status',  | 
                                                        |
| 68 | + 'capability' => 'manage_options',  | 
                                                        |
| 69 | + ),  | 
                                                        |
| 70 | + 'download_system_status' => array(  | 
                                                        |
| 71 | + 'func' => '_download_system_status',  | 
                                                        |
| 72 | + 'capability' => 'manage_options',  | 
                                                        |
| 73 | + 'noheader' => true,  | 
                                                        |
| 74 | + ),  | 
                                                        |
| 75 | + 'send_migration_crash_report' => array(  | 
                                                        |
| 76 | + 'func' => '_send_migration_crash_report',  | 
                                                        |
| 77 | + 'capability' => 'manage_options',  | 
                                                        |
| 78 | + 'noheader' => true,  | 
                                                        |
| 79 | + ),  | 
                                                        |
| 80 | + 'confirm_migration_crash_report_sent' => array(  | 
                                                        |
| 81 | + 'func' => '_confirm_migration_crash_report_sent',  | 
                                                        |
| 82 | + 'capability' => 'manage_options',  | 
                                                        |
| 83 | + ),  | 
                                                        |
| 84 | + 'data_reset' => array(  | 
                                                        |
| 85 | + 'func' => '_data_reset_and_delete',  | 
                                                        |
| 86 | + 'capability' => 'manage_options',  | 
                                                        |
| 87 | + ),  | 
                                                        |
| 88 | + 'reset_db' => array(  | 
                                                        |
| 89 | + 'func' => '_reset_db',  | 
                                                        |
| 90 | + 'capability' => 'manage_options',  | 
                                                        |
| 91 | + 'noheader' => true,  | 
                                                        |
| 92 | +				'args'       => array('nuke_old_ee4_data' => true), | 
                                                        |
| 93 | + ),  | 
                                                        |
| 94 | + 'start_with_fresh_ee4_db' => array(  | 
                                                        |
| 95 | + 'func' => '_reset_db',  | 
                                                        |
| 96 | + 'capability' => 'manage_options',  | 
                                                        |
| 97 | + 'noheader' => true,  | 
                                                        |
| 98 | +				'args'       => array('nuke_old_ee4_data' => false), | 
                                                        |
| 99 | + ),  | 
                                                        |
| 100 | + 'delete_db' => array(  | 
                                                        |
| 101 | + 'func' => '_delete_db',  | 
                                                        |
| 102 | + 'capability' => 'manage_options',  | 
                                                        |
| 103 | + 'noheader' => true,  | 
                                                        |
| 104 | + ),  | 
                                                        |
| 105 | + 'rerun_migration_from_ee3' => array(  | 
                                                        |
| 106 | + 'func' => '_rerun_migration_from_ee3',  | 
                                                        |
| 107 | + 'capability' => 'manage_options',  | 
                                                        |
| 108 | + 'noheader' => true,  | 
                                                        |
| 109 | + ),  | 
                                                        |
| 110 | + 'reset_reservations' => array(  | 
                                                        |
| 111 | + 'func' => '_reset_reservations',  | 
                                                        |
| 112 | + 'capability' => 'manage_options',  | 
                                                        |
| 113 | + 'noheader' => true,  | 
                                                        |
| 114 | + ),  | 
                                                        |
| 115 | + 'reset_capabilities' => array(  | 
                                                        |
| 116 | + 'func' => '_reset_capabilities',  | 
                                                        |
| 117 | + 'capability' => 'manage_options',  | 
                                                        |
| 118 | + 'noheader' => true,  | 
                                                        |
| 119 | + ),  | 
                                                        |
| 120 | + 'reattempt_migration' => array(  | 
                                                        |
| 121 | + 'func' => '_reattempt_migration',  | 
                                                        |
| 122 | + 'capability' => 'manage_options',  | 
                                                        |
| 123 | + 'noheader' => true,  | 
                                                        |
| 124 | + ),  | 
                                                        |
| 125 | + 'datetime_tools' => array(  | 
                                                        |
| 126 | + 'func' => '_datetime_tools',  | 
                                                        |
| 127 | + 'capability' => 'manage_options',  | 
                                                        |
| 128 | + ),  | 
                                                        |
| 129 | + 'run_datetime_offset_fix' => array(  | 
                                                        |
| 130 | + 'func' => '_apply_datetime_offset',  | 
                                                        |
| 131 | + 'noheader' => true,  | 
                                                        |
| 132 | + 'headers_sent_route' => 'datetime_tools',  | 
                                                        |
| 133 | + 'capability' => 'manage_options',  | 
                                                        |
| 134 | + ),  | 
                                                        |
| 135 | + );  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | +  | 
                                                        |
| 138 | +  | 
                                                        |
| 139 | + protected function _set_page_config()  | 
                                                        |
| 140 | +	{ | 
                                                        |
| 141 | + $this->_page_config = array(  | 
                                                        |
| 142 | + 'default' => array(  | 
                                                        |
| 143 | + 'nav' => array(  | 
                                                        |
| 144 | +					'label' => esc_html__('Maintenance', 'event_espresso'), | 
                                                        |
| 145 | + 'order' => 10,  | 
                                                        |
| 146 | + ),  | 
                                                        |
| 147 | + 'require_nonce' => false,  | 
                                                        |
| 148 | + ),  | 
                                                        |
| 149 | + 'data_reset' => array(  | 
                                                        |
| 150 | + 'nav' => array(  | 
                                                        |
| 151 | +					'label' => esc_html__('Reset/Delete Data', 'event_espresso'), | 
                                                        |
| 152 | + 'order' => 20,  | 
                                                        |
| 153 | + ),  | 
                                                        |
| 154 | + 'require_nonce' => false,  | 
                                                        |
| 155 | + ),  | 
                                                        |
| 156 | + 'datetime_tools' => array(  | 
                                                        |
| 157 | + 'nav' => array(  | 
                                                        |
| 158 | +					'label' => esc_html__('Datetime Utilities', 'event_espresso'), | 
                                                        |
| 159 | + 'order' => 25,  | 
                                                        |
| 160 | + ),  | 
                                                        |
| 161 | + 'require_nonce' => false,  | 
                                                        |
| 162 | + ),  | 
                                                        |
| 163 | + 'system_status' => array(  | 
                                                        |
| 164 | + 'nav' => array(  | 
                                                        |
| 165 | +					'label' => esc_html__("System Information", "event_espresso"), | 
                                                        |
| 166 | + 'order' => 30,  | 
                                                        |
| 167 | + ),  | 
                                                        |
| 168 | + 'require_nonce' => false,  | 
                                                        |
| 169 | + ),  | 
                                                        |
| 170 | + );  | 
                                                        |
| 171 | + }  | 
                                                        |
| 172 | +  | 
                                                        |
| 173 | +  | 
                                                        |
| 174 | + /**  | 
                                                        |
| 175 | + * default maintenance page. If we're in maintenance mode level 2, then we need to show  | 
                                                        |
| 176 | + * the migration scripts and all that UI.  | 
                                                        |
| 177 | + */  | 
                                                        |
| 178 | + public function _maintenance()  | 
                                                        |
| 179 | +	{ | 
                                                        |
| 180 | + // it all depends if we're in maintenance model level 1 (frontend-only) or  | 
                                                        |
| 181 | + // level 2 (everything except maintenance page)  | 
                                                        |
| 182 | +		try { | 
                                                        |
| 183 | + // get the current maintenance level and check if  | 
                                                        |
| 184 | + // we are removed  | 
                                                        |
| 185 | + $mm = EE_Maintenance_Mode::instance()->level();  | 
                                                        |
| 186 | + $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();  | 
                                                        |
| 187 | +			if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) { | 
                                                        |
| 188 | + // we just took the site out of maintenance mode, so notify the user.  | 
                                                        |
| 189 | + // unfortunately this message appears to be echoed on the NEXT page load...  | 
                                                        |
| 190 | + // oh well, we should really be checking for this on addon deactivation anyways  | 
                                                        |
| 191 | + EE_Error::add_attention(  | 
                                                        |
| 192 | + __(  | 
                                                        |
| 193 | + 'Site taken out of maintenance mode because no data migration scripts are required',  | 
                                                        |
| 194 | + 'event_espresso'  | 
                                                        |
| 195 | + )  | 
                                                        |
| 196 | + );  | 
                                                        |
| 197 | +				$this->_process_notices(array('page' => 'espresso_maintenance_settings'), false); | 
                                                        |
| 198 | + }  | 
                                                        |
| 199 | + // in case an exception is thrown while trying to handle migrations  | 
                                                        |
| 200 | +			switch (EE_Maintenance_Mode::instance()->level()) { | 
                                                        |
| 201 | + case EE_Maintenance_Mode::level_0_not_in_maintenance:  | 
                                                        |
| 202 | + case EE_Maintenance_Mode::level_1_frontend_only_maintenance:  | 
                                                        |
| 203 | + $show_maintenance_switch = true;  | 
                                                        |
| 204 | + $show_backup_db_text = false;  | 
                                                        |
| 205 | + $show_migration_progress = false;  | 
                                                        |
| 206 | + $script_names = array();  | 
                                                        |
| 207 | + $addons_should_be_upgraded_first = false;  | 
                                                        |
| 208 | + break;  | 
                                                        |
| 209 | + case EE_Maintenance_Mode::level_2_complete_maintenance:  | 
                                                        |
| 210 | + $show_maintenance_switch = false;  | 
                                                        |
| 211 | + $show_migration_progress = true;  | 
                                                        |
| 212 | +					if (isset($this->_req_data['continue_migration'])) { | 
                                                        |
| 213 | + $show_backup_db_text = false;  | 
                                                        |
| 214 | +					} else { | 
                                                        |
| 215 | + $show_backup_db_text = true;  | 
                                                        |
| 216 | + }  | 
                                                        |
| 217 | + $scripts_needing_to_run = EE_Data_Migration_Manager::instance()  | 
                                                        |
| 218 | + ->check_for_applicable_data_migration_scripts();  | 
                                                        |
| 219 | + $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();  | 
                                                        |
| 220 | + $script_names = array();  | 
                                                        |
| 221 | + $current_script = null;  | 
                                                        |
| 222 | +					foreach ($scripts_needing_to_run as $script) { | 
                                                        |
| 223 | +						if ($script instanceof EE_Data_Migration_Script_Base) { | 
                                                        |
| 224 | +							if (! $current_script) { | 
                                                        |
| 225 | + $current_script = $script;  | 
                                                        |
| 226 | + $current_script->migration_page_hooks();  | 
                                                        |
| 227 | + }  | 
                                                        |
| 228 | + $script_names[] = $script->pretty_name();  | 
                                                        |
| 229 | + }  | 
                                                        |
| 230 | + }  | 
                                                        |
| 231 | + break;  | 
                                                        |
| 232 | + }  | 
                                                        |
| 233 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);  | 
                                                        |
| 234 | + $exception_thrown = false;  | 
                                                        |
| 235 | +		} catch (EE_Error $e) { | 
                                                        |
| 236 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());  | 
                                                        |
| 237 | + // now, just so we can display the page correctly, make a error migration script stage object  | 
                                                        |
| 238 | + // and also put the error on it. It only persists for the duration of this request  | 
                                                        |
| 239 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0();  | 
                                                        |
| 240 | + $most_recent_migration->add_error($e->getMessage());  | 
                                                        |
| 241 | + $exception_thrown = true;  | 
                                                        |
| 242 | + }  | 
                                                        |
| 243 | + $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();  | 
                                                        |
| 244 | +		$current_db_state = str_replace('.decaf', '', $current_db_state); | 
                                                        |
| 245 | + if ($exception_thrown  | 
                                                        |
| 246 | + || ($most_recent_migration  | 
                                                        |
| 247 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base  | 
                                                        |
| 248 | + && $most_recent_migration->is_broken()  | 
                                                        |
| 249 | + )  | 
                                                        |
| 250 | +		) { | 
                                                        |
| 251 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';  | 
                                                        |
| 252 | + $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';  | 
                                                        |
| 253 | + $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(  | 
                                                        |
| 254 | + array(  | 
                                                        |
| 255 | + 'action' => 'confirm_migration_crash_report_sent',  | 
                                                        |
| 256 | + 'success' => '0',  | 
                                                        |
| 257 | + ),  | 
                                                        |
| 258 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 259 | + );  | 
                                                        |
| 260 | +		} elseif ($addons_should_be_upgraded_first) { | 
                                                        |
| 261 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';  | 
                                                        |
| 262 | +		} else { | 
                                                        |
| 263 | + if ($most_recent_migration  | 
                                                        |
| 264 | + && $most_recent_migration instanceof EE_Data_Migration_Script_Base  | 
                                                        |
| 265 | + && $most_recent_migration->can_continue()  | 
                                                        |
| 266 | +			) { | 
                                                        |
| 267 | + $show_backup_db_text = false;  | 
                                                        |
| 268 | + $show_continue_current_migration_script = true;  | 
                                                        |
| 269 | + $show_most_recent_migration = true;  | 
                                                        |
| 270 | +			} elseif (isset($this->_req_data['continue_migration'])) { | 
                                                        |
| 271 | + $show_most_recent_migration = true;  | 
                                                        |
| 272 | + $show_continue_current_migration_script = false;  | 
                                                        |
| 273 | +			} else { | 
                                                        |
| 274 | + $show_most_recent_migration = false;  | 
                                                        |
| 275 | + $show_continue_current_migration_script = false;  | 
                                                        |
| 276 | + }  | 
                                                        |
| 277 | +			if (isset($current_script)) { | 
                                                        |
| 278 | + $migrates_to = $current_script->migrates_to_version();  | 
                                                        |
| 279 | + $plugin_slug = $migrates_to['slug'];  | 
                                                        |
| 280 | + $new_version = $migrates_to['version'];  | 
                                                        |
| 281 | + $this->_template_args = array_merge(  | 
                                                        |
| 282 | + $this->_template_args,  | 
                                                        |
| 283 | + array(  | 
                                                        |
| 284 | + 'current_db_state' => sprintf(  | 
                                                        |
| 285 | +							__("EE%s (%s)", "event_espresso"), | 
                                                        |
| 286 | + isset($current_db_state[ $plugin_slug ]) ? $current_db_state[ $plugin_slug ] : 3,  | 
                                                        |
| 287 | + $plugin_slug  | 
                                                        |
| 288 | + ),  | 
                                                        |
| 289 | + 'next_db_state' => isset($current_script) ? sprintf(  | 
                                                        |
| 290 | +							__("EE%s (%s)", 'event_espresso'), | 
                                                        |
| 291 | + $new_version,  | 
                                                        |
| 292 | + $plugin_slug  | 
                                                        |
| 293 | + ) : null,  | 
                                                        |
| 294 | + )  | 
                                                        |
| 295 | + );  | 
                                                        |
| 296 | +			} else { | 
                                                        |
| 297 | + $this->_template_args['current_db_state'] = null;  | 
                                                        |
| 298 | + $this->_template_args['next_db_state'] = null;  | 
                                                        |
| 299 | + }  | 
                                                        |
| 300 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';  | 
                                                        |
| 301 | + $this->_template_args = array_merge(  | 
                                                        |
| 302 | + $this->_template_args,  | 
                                                        |
| 303 | + array(  | 
                                                        |
| 304 | + 'show_most_recent_migration' => $show_most_recent_migration,  | 
                                                        |
| 305 | + // flag for showing the most recent migration's status and/or errors  | 
                                                        |
| 306 | + 'show_migration_progress' => $show_migration_progress,  | 
                                                        |
| 307 | + // flag for showing the option to run migrations and see their progress  | 
                                                        |
| 308 | + 'show_backup_db_text' => $show_backup_db_text,  | 
                                                        |
| 309 | + // flag for showing text telling the user to backup their DB  | 
                                                        |
| 310 | + 'show_maintenance_switch' => $show_maintenance_switch,  | 
                                                        |
| 311 | + // flag for showing the option to change maintenance mode between levels 0 and 1  | 
                                                        |
| 312 | + 'script_names' => $script_names,  | 
                                                        |
| 313 | + // array of names of scripts that have run  | 
                                                        |
| 314 | + 'show_continue_current_migration_script' => $show_continue_current_migration_script,  | 
                                                        |
| 315 | + // flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0  | 
                                                        |
| 316 | + 'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 317 | +						array('action' => 'reset_db'), | 
                                                        |
| 318 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 319 | + ),  | 
                                                        |
| 320 | + 'data_reset_page' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 321 | +						array('action' => 'data_reset'), | 
                                                        |
| 322 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 323 | + ),  | 
                                                        |
| 324 | + 'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 325 | +						array('action' => 'change_maintenance_level'), | 
                                                        |
| 326 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 327 | + ),  | 
                                                        |
| 328 | + 'ultimate_db_state' => sprintf(  | 
                                                        |
| 329 | +						__("EE%s", 'event_espresso'), | 
                                                        |
| 330 | + espresso_version()  | 
                                                        |
| 331 | + ),  | 
                                                        |
| 332 | + )  | 
                                                        |
| 333 | + );  | 
                                                        |
| 334 | + // make sure we have the form fields helper available. It usually is, but sometimes it isn't  | 
                                                        |
| 335 | + }  | 
                                                        |
| 336 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;// the actual most recently ran migration  | 
                                                        |
| 337 | + // now render the migration options part, and put it in a variable  | 
                                                        |
| 338 | + $migration_options_template_file = apply_filters(  | 
                                                        |
| 339 | + 'FHEE__ee_migration_page__migration_options_template',  | 
                                                        |
| 340 | + EE_MAINTENANCE_TEMPLATE_PATH . 'migration_options_from_ee4.template.php'  | 
                                                        |
| 341 | + );  | 
                                                        |
| 342 | + $migration_options_html = EEH_Template::display_template(  | 
                                                        |
| 343 | + $migration_options_template_file,  | 
                                                        |
| 344 | + $this->_template_args,  | 
                                                        |
| 345 | + true  | 
                                                        |
| 346 | + );  | 
                                                        |
| 347 | + $this->_template_args['migration_options_html'] = $migration_options_html;  | 
                                                        |
| 348 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 349 | + $this->_template_path,  | 
                                                        |
| 350 | + $this->_template_args,  | 
                                                        |
| 351 | + true  | 
                                                        |
| 352 | + );  | 
                                                        |
| 353 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 354 | + }  | 
                                                        |
| 355 | +  | 
                                                        |
| 356 | +  | 
                                                        |
| 357 | + /**  | 
                                                        |
| 358 | + * returns JSON and executes another step of the currently-executing data migration (called via ajax)  | 
                                                        |
| 359 | + */  | 
                                                        |
| 360 | + public function migration_step()  | 
                                                        |
| 361 | +	{ | 
                                                        |
| 362 | + $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();  | 
                                                        |
| 363 | + $this->_return_json();  | 
                                                        |
| 364 | + }  | 
                                                        |
| 365 | +  | 
                                                        |
| 366 | +  | 
                                                        |
| 367 | + /**  | 
                                                        |
| 368 | + * Can be used by js when it notices a response with HTML in it in order  | 
                                                        |
| 369 | + * to log the malformed response  | 
                                                        |
| 370 | + */  | 
                                                        |
| 371 | + public function add_error_to_migrations_ran()  | 
                                                        |
| 372 | +	{ | 
                                                        |
| 373 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);  | 
                                                        |
| 374 | +		$this->_template_args['data'] = array('ok' => true); | 
                                                        |
| 375 | + $this->_return_json();  | 
                                                        |
| 376 | + }  | 
                                                        |
| 377 | +  | 
                                                        |
| 378 | +  | 
                                                        |
| 379 | + /**  | 
                                                        |
| 380 | + * changes the maintenance level, provided there are still no migration scripts that should run  | 
                                                        |
| 381 | + */  | 
                                                        |
| 382 | + public function _change_maintenance_level()  | 
                                                        |
| 383 | +	{ | 
                                                        |
| 384 | + $new_level = absint($this->_req_data['maintenance_mode_level']);  | 
                                                        |
| 385 | +		if (! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) { | 
                                                        |
| 386 | + EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);  | 
                                                        |
| 387 | + $success = true;  | 
                                                        |
| 388 | +		} else { | 
                                                        |
| 389 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();  | 
                                                        |
| 390 | + $success = false;  | 
                                                        |
| 391 | + }  | 
                                                        |
| 392 | +		$this->_redirect_after_action($success, 'Maintenance Mode', esc_html__("Updated", "event_espresso")); | 
                                                        |
| 393 | + }  | 
                                                        |
| 394 | +  | 
                                                        |
| 395 | +  | 
                                                        |
| 396 | + /**  | 
                                                        |
| 397 | + * a tab with options for resetting and/or deleting EE data  | 
                                                        |
| 398 | + *  | 
                                                        |
| 399 | + * @throws \EE_Error  | 
                                                        |
| 400 | + * @throws \DomainException  | 
                                                        |
| 401 | + */  | 
                                                        |
| 402 | + public function _data_reset_and_delete()  | 
                                                        |
| 403 | +	{ | 
                                                        |
| 404 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';  | 
                                                        |
| 405 | + $this->_template_args['reset_reservations_button'] = $this->get_action_link_or_button(  | 
                                                        |
| 406 | + 'reset_reservations',  | 
                                                        |
| 407 | + 'reset_reservations',  | 
                                                        |
| 408 | + array(),  | 
                                                        |
| 409 | + 'button button-primary ee-confirm',  | 
                                                        |
| 410 | + '',  | 
                                                        |
| 411 | + false  | 
                                                        |
| 412 | + );  | 
                                                        |
| 413 | + $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(  | 
                                                        |
| 414 | + 'reset_capabilities',  | 
                                                        |
| 415 | + 'reset_capabilities',  | 
                                                        |
| 416 | + array(),  | 
                                                        |
| 417 | + 'button button-primary ee-confirm',  | 
                                                        |
| 418 | + '',  | 
                                                        |
| 419 | + false  | 
                                                        |
| 420 | + );  | 
                                                        |
| 421 | + $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 422 | +			array('action' => 'delete_db'), | 
                                                        |
| 423 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 424 | + );  | 
                                                        |
| 425 | + $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 426 | +			array('action' => 'reset_db'), | 
                                                        |
| 427 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 428 | + );  | 
                                                        |
| 429 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 430 | + $this->_template_path,  | 
                                                        |
| 431 | + $this->_template_args,  | 
                                                        |
| 432 | + true  | 
                                                        |
| 433 | + );  | 
                                                        |
| 434 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 435 | + }  | 
                                                        |
| 436 | +  | 
                                                        |
| 437 | +  | 
                                                        |
| 438 | + protected function _reset_reservations()  | 
                                                        |
| 439 | +	{ | 
                                                        |
| 440 | +		if (\EED_Ticket_Sales_Monitor::reset_reservation_counts()) { | 
                                                        |
| 441 | + EE_Error::add_success(  | 
                                                        |
| 442 | + __(  | 
                                                        |
| 443 | + 'Ticket and datetime reserved counts have been successfully reset.',  | 
                                                        |
| 444 | + 'event_espresso'  | 
                                                        |
| 445 | + )  | 
                                                        |
| 446 | + );  | 
                                                        |
| 447 | +		} else { | 
                                                        |
| 448 | + EE_Error::add_success(  | 
                                                        |
| 449 | + __(  | 
                                                        |
| 450 | + 'Ticket and datetime reserved counts were correct and did not need resetting.',  | 
                                                        |
| 451 | + 'event_espresso'  | 
                                                        |
| 452 | + )  | 
                                                        |
| 453 | + );  | 
                                                        |
| 454 | + }  | 
                                                        |
| 455 | +		$this->_redirect_after_action(true, '', '', array('action' => 'data_reset'), true); | 
                                                        |
| 456 | + }  | 
                                                        |
| 457 | +  | 
                                                        |
| 458 | +  | 
                                                        |
| 459 | + protected function _reset_capabilities()  | 
                                                        |
| 460 | +	{ | 
                                                        |
| 461 | + EE_Registry::instance()->CAP->init_caps(true);  | 
                                                        |
| 462 | + EE_Error::add_success(  | 
                                                        |
| 463 | + __(  | 
                                                        |
| 464 | + 'Default Event Espresso capabilities have been restored for all current roles.',  | 
                                                        |
| 465 | + 'event_espresso'  | 
                                                        |
| 466 | + )  | 
                                                        |
| 467 | + );  | 
                                                        |
| 468 | +		$this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true); | 
                                                        |
| 469 | + }  | 
                                                        |
| 470 | +  | 
                                                        |
| 471 | +  | 
                                                        |
| 472 | + /**  | 
                                                        |
| 473 | + * resets the DMSs so we can attempt to continue migrating after a fatal error  | 
                                                        |
| 474 | + * (only a good idea when someone has somehow tried ot fix whatever caused  | 
                                                        |
| 475 | + * the fatal error in teh first place)  | 
                                                        |
| 476 | + */  | 
                                                        |
| 477 | + protected function _reattempt_migration()  | 
                                                        |
| 478 | +	{ | 
                                                        |
| 479 | + EE_Data_Migration_Manager::instance()->reattempt();  | 
                                                        |
| 480 | +		$this->_redirect_after_action(false, '', '', array('action' => 'default'), true); | 
                                                        |
| 481 | + }  | 
                                                        |
| 482 | +  | 
                                                        |
| 483 | +  | 
                                                        |
| 484 | + /**  | 
                                                        |
| 485 | + * shows the big ol' System Information page  | 
                                                        |
| 486 | + */  | 
                                                        |
| 487 | + public function _system_status()  | 
                                                        |
| 488 | +	{ | 
                                                        |
| 489 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';  | 
                                                        |
| 490 | + $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();  | 
                                                        |
| 491 | + $this->_template_args['download_system_status_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 492 | + array(  | 
                                                        |
| 493 | + 'action' => 'download_system_status',  | 
                                                        |
| 494 | + ),  | 
                                                        |
| 495 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 496 | + );  | 
                                                        |
| 497 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 498 | + $this->_template_path,  | 
                                                        |
| 499 | + $this->_template_args,  | 
                                                        |
| 500 | + true  | 
                                                        |
| 501 | + );  | 
                                                        |
| 502 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 503 | + }  | 
                                                        |
| 504 | +  | 
                                                        |
| 505 | + /**  | 
                                                        |
| 506 | + * Downloads an HTML file of the system status that can be easily stored or emailed  | 
                                                        |
| 507 | + */  | 
                                                        |
| 508 | + public function _download_system_status()  | 
                                                        |
| 509 | +	{ | 
                                                        |
| 510 | + $status_info = EEM_System_Status::instance()->get_system_stati();  | 
                                                        |
| 511 | +		header('Content-Disposition: attachment'); | 
                                                        |
| 512 | +		header("Content-Disposition: attachment; filename=system_status_" . sanitize_key(site_url()) . ".html"); | 
                                                        |
| 513 | +		echo "<style>table{border:1px solid darkgrey;}td{vertical-align:top}</style>"; | 
                                                        |
| 514 | + echo "<h1>System Information for " . site_url() . "</h1>";  | 
                                                        |
| 515 | + echo EEH_Template::layout_array_as_table($status_info);  | 
                                                        |
| 516 | + die;  | 
                                                        |
| 517 | + }  | 
                                                        |
| 518 | +  | 
                                                        |
| 519 | +  | 
                                                        |
| 520 | + public function _send_migration_crash_report()  | 
                                                        |
| 521 | +	{ | 
                                                        |
| 522 | + $from = $this->_req_data['from'];  | 
                                                        |
| 523 | + $from_name = $this->_req_data['from_name'];  | 
                                                        |
| 524 | + $body = $this->_req_data['body'];  | 
                                                        |
| 525 | +		try { | 
                                                        |
| 526 | + $success = wp_mail(  | 
                                                        |
| 527 | + EE_SUPPORT_EMAIL,  | 
                                                        |
| 528 | + 'Migration Crash Report',  | 
                                                        |
| 529 | + $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),  | 
                                                        |
| 530 | + array(  | 
                                                        |
| 531 | + "from:$from_name<$from>",  | 
                                                        |
| 532 | + )  | 
                                                        |
| 533 | + );  | 
                                                        |
| 534 | +		} catch (Exception $e) { | 
                                                        |
| 535 | + $success = false;  | 
                                                        |
| 536 | + }  | 
                                                        |
| 537 | + $this->_redirect_after_action(  | 
                                                        |
| 538 | + $success,  | 
                                                        |
| 539 | +			esc_html__("Migration Crash Report", "event_espresso"), | 
                                                        |
| 540 | +			esc_html__("sent", "event_espresso"), | 
                                                        |
| 541 | +			array('success' => $success, 'action' => 'confirm_migration_crash_report_sent') | 
                                                        |
| 542 | + );  | 
                                                        |
| 543 | + }  | 
                                                        |
| 544 | +  | 
                                                        |
| 545 | +  | 
                                                        |
| 546 | + public function _confirm_migration_crash_report_sent()  | 
                                                        |
| 547 | +	{ | 
                                                        |
| 548 | +		try { | 
                                                        |
| 549 | + $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);  | 
                                                        |
| 550 | +		} catch (EE_Error $e) { | 
                                                        |
| 551 | + EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());  | 
                                                        |
| 552 | + // now, just so we can display the page correctly, make a error migration script stage object  | 
                                                        |
| 553 | + // and also put the error on it. It only persists for the duration of this request  | 
                                                        |
| 554 | + $most_recent_migration = new EE_DMS_Unknown_1_0_0();  | 
                                                        |
| 555 | + $most_recent_migration->add_error($e->getMessage());  | 
                                                        |
| 556 | + }  | 
                                                        |
| 557 | + $success = $this->_req_data['success'] == '1' ? true : false;  | 
                                                        |
| 558 | + $this->_template_args['success'] = $success;  | 
                                                        |
| 559 | + $this->_template_args['most_recent_migration'] = $most_recent_migration;  | 
                                                        |
| 560 | + $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 561 | +			array('action' => 'reset_db'), | 
                                                        |
| 562 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 563 | + );  | 
                                                        |
| 564 | + $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 565 | +			array('action' => 'data_reset'), | 
                                                        |
| 566 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 567 | + );  | 
                                                        |
| 568 | + $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 569 | +			array('action' => 'reattempt_migration'), | 
                                                        |
| 570 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 571 | + );  | 
                                                        |
| 572 | + $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';  | 
                                                        |
| 573 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(  | 
                                                        |
| 574 | + $this->_template_path,  | 
                                                        |
| 575 | + $this->_template_args,  | 
                                                        |
| 576 | + true  | 
                                                        |
| 577 | + );  | 
                                                        |
| 578 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 579 | + }  | 
                                                        |
| 580 | +  | 
                                                        |
| 581 | +  | 
                                                        |
| 582 | + /**  | 
                                                        |
| 583 | + * Resets the entire EE4 database.  | 
                                                        |
| 584 | + * Currently basically only sets up ee4 database for a fresh install- doesn't  | 
                                                        |
| 585 | + * actually clean out the old wp options, or cpts (although does erase old ee table data)  | 
                                                        |
| 586 | + *  | 
                                                        |
| 587 | + * @param boolean $nuke_old_ee4_data controls whether or not we  | 
                                                        |
| 588 | + * destroy the old ee4 data, or just try initializing ee4 default data  | 
                                                        |
| 589 | + */  | 
                                                        |
| 590 | + public function _reset_db($nuke_old_ee4_data = true)  | 
                                                        |
| 591 | +	{ | 
                                                        |
| 592 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 593 | +		if ($nuke_old_ee4_data) { | 
                                                        |
| 594 | + EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 595 | + EEH_Activation::delete_all_espresso_tables_and_data(false);  | 
                                                        |
| 596 | + EEH_Activation::remove_cron_tasks();  | 
                                                        |
| 597 | + }  | 
                                                        |
| 598 | + // make sure when we reset the registry's config that it  | 
                                                        |
| 599 | + // switches to using the new singleton  | 
                                                        |
| 600 | + EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);  | 
                                                        |
| 601 | + EE_System::instance()->initialize_db_if_no_migrations_required(true);  | 
                                                        |
| 602 | + EE_System::instance()->redirect_to_about_ee();  | 
                                                        |
| 603 | + }  | 
                                                        |
| 604 | +  | 
                                                        |
| 605 | +  | 
                                                        |
| 606 | + /**  | 
                                                        |
| 607 | + * Deletes ALL EE tables, Records, and Options from the database.  | 
                                                        |
| 608 | + */  | 
                                                        |
| 609 | + public function _delete_db()  | 
                                                        |
| 610 | +	{ | 
                                                        |
| 611 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 612 | + EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 613 | + EEH_Activation::delete_all_espresso_tables_and_data();  | 
                                                        |
| 614 | + EEH_Activation::remove_cron_tasks();  | 
                                                        |
| 615 | + EEH_Activation::deactivate_event_espresso();  | 
                                                        |
| 616 | +		wp_safe_redirect(admin_url('plugins.php')); | 
                                                        |
| 617 | + exit;  | 
                                                        |
| 618 | + }  | 
                                                        |
| 619 | +  | 
                                                        |
| 620 | +  | 
                                                        |
| 621 | + /**  | 
                                                        |
| 622 | + * sets up EE4 to rerun the migrations from ee3 to ee4  | 
                                                        |
| 623 | + */  | 
                                                        |
| 624 | + public function _rerun_migration_from_ee3()  | 
                                                        |
| 625 | +	{ | 
                                                        |
| 626 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);  | 
                                                        |
| 627 | + EEH_Activation::delete_all_espresso_cpt_data();  | 
                                                        |
| 628 | + EEH_Activation::delete_all_espresso_tables_and_data(false);  | 
                                                        |
| 629 | + // set the db state to something that will require migrations  | 
                                                        |
| 630 | + update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');  | 
                                                        |
| 631 | + EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);  | 
                                                        |
| 632 | + $this->_redirect_after_action(  | 
                                                        |
| 633 | + true,  | 
                                                        |
| 634 | +			esc_html__("Database", 'event_espresso'), | 
                                                        |
| 635 | +			esc_html__("reset", 'event_espresso') | 
                                                        |
| 636 | + );  | 
                                                        |
| 637 | + }  | 
                                                        |
| 638 | +  | 
                                                        |
| 639 | +  | 
                                                        |
| 640 | + // none of the below group are currently used for Gateway Settings  | 
                                                        |
| 641 | + protected function _add_screen_options()  | 
                                                        |
| 642 | +	{ | 
                                                        |
| 643 | + }  | 
                                                        |
| 644 | +  | 
                                                        |
| 645 | +  | 
                                                        |
| 646 | + protected function _add_feature_pointers()  | 
                                                        |
| 647 | +	{ | 
                                                        |
| 648 | + }  | 
                                                        |
| 649 | +  | 
                                                        |
| 650 | +  | 
                                                        |
| 651 | + public function admin_init()  | 
                                                        |
| 652 | +	{ | 
                                                        |
| 653 | + }  | 
                                                        |
| 654 | +  | 
                                                        |
| 655 | +  | 
                                                        |
| 656 | + public function admin_notices()  | 
                                                        |
| 657 | +	{ | 
                                                        |
| 658 | + }  | 
                                                        |
| 659 | +  | 
                                                        |
| 660 | +  | 
                                                        |
| 661 | + public function admin_footer_scripts()  | 
                                                        |
| 662 | +	{ | 
                                                        |
| 663 | + }  | 
                                                        |
| 664 | +  | 
                                                        |
| 665 | +  | 
                                                        |
| 666 | + public function load_scripts_styles()  | 
                                                        |
| 667 | +	{ | 
                                                        |
| 668 | +		wp_enqueue_script('ee_admin_js'); | 
                                                        |
| 669 | + wp_enqueue_script(  | 
                                                        |
| 670 | + 'ee-maintenance',  | 
                                                        |
| 671 | + EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.js',  | 
                                                        |
| 672 | +			array('jquery'), | 
                                                        |
| 673 | + EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 674 | + true  | 
                                                        |
| 675 | + );  | 
                                                        |
| 676 | + wp_register_style(  | 
                                                        |
| 677 | + 'espresso_maintenance',  | 
                                                        |
| 678 | + EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css',  | 
                                                        |
| 679 | + array(),  | 
                                                        |
| 680 | + EVENT_ESPRESSO_VERSION  | 
                                                        |
| 681 | + );  | 
                                                        |
| 682 | +		wp_enqueue_style('espresso_maintenance'); | 
                                                        |
| 683 | + // localize script stuff  | 
                                                        |
| 684 | + wp_localize_script(  | 
                                                        |
| 685 | + 'ee-maintenance',  | 
                                                        |
| 686 | + 'ee_maintenance',  | 
                                                        |
| 687 | + array(  | 
                                                        |
| 688 | +				'migrating'                        => esc_html__("Updating Database...", "event_espresso"), | 
                                                        |
| 689 | +				'next'                             => esc_html__("Next", "event_espresso"), | 
                                                        |
| 690 | +				'fatal_error'                      => esc_html__("A Fatal Error Has Occurred", "event_espresso"), | 
                                                        |
| 691 | + 'click_next_when_ready' => esc_html__(  | 
                                                        |
| 692 | + "The current Database Update has ended. Click 'next' when ready to proceed",  | 
                                                        |
| 693 | + "event_espresso"  | 
                                                        |
| 694 | + ),  | 
                                                        |
| 695 | + 'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,  | 
                                                        |
| 696 | + 'status_fatal_error' => EE_Data_Migration_Manager::status_fatal_error,  | 
                                                        |
| 697 | + 'status_completed' => EE_Data_Migration_Manager::status_completed,  | 
                                                        |
| 698 | + 'confirm' => esc_html__(  | 
                                                        |
| 699 | + 'Are you sure you want to do this? It CANNOT be undone!',  | 
                                                        |
| 700 | + 'event_espresso'  | 
                                                        |
| 701 | + ),  | 
                                                        |
| 702 | + 'confirm_skip_migration' => esc_html__(  | 
                                                        |
| 703 | + 'You have chosen to NOT migrate your existing data. Are you sure you want to continue?',  | 
                                                        |
| 704 | + 'event_espresso'  | 
                                                        |
| 705 | + ),  | 
                                                        |
| 706 | + )  | 
                                                        |
| 707 | + );  | 
                                                        |
| 708 | + }  | 
                                                        |
| 709 | +  | 
                                                        |
| 710 | +  | 
                                                        |
| 711 | + public function load_scripts_styles_default()  | 
                                                        |
| 712 | +	{ | 
                                                        |
| 713 | + }  | 
                                                        |
| 714 | +  | 
                                                        |
| 715 | +  | 
                                                        |
| 716 | + /**  | 
                                                        |
| 717 | + * Enqueue scripts and styles for the datetime tools page.  | 
                                                        |
| 718 | + */  | 
                                                        |
| 719 | + public function load_scripts_styles_datetime_tools()  | 
                                                        |
| 720 | +	{ | 
                                                        |
| 721 | + EE_Datepicker_Input::enqueue_styles_and_scripts();  | 
                                                        |
| 722 | + }  | 
                                                        |
| 723 | +  | 
                                                        |
| 724 | +  | 
                                                        |
| 725 | + protected function _datetime_tools()  | 
                                                        |
| 726 | +	{ | 
                                                        |
| 727 | + $form_action = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 728 | + array(  | 
                                                        |
| 729 | + 'action' => 'run_datetime_offset_fix',  | 
                                                        |
| 730 | + 'return_action' => $this->_req_action,  | 
                                                        |
| 731 | + ),  | 
                                                        |
| 732 | + EE_MAINTENANCE_ADMIN_URL  | 
                                                        |
| 733 | + );  | 
                                                        |
| 734 | + $form = $this->_get_datetime_offset_fix_form();  | 
                                                        |
| 735 | +		$this->_admin_page_title = esc_html__('Datetime Utilities', 'event_espresso'); | 
                                                        |
| 736 | + $this->_template_args['admin_page_content'] = $form->form_open($form_action, 'post')  | 
                                                        |
| 737 | + . $form->get_html_and_js()  | 
                                                        |
| 738 | + . $form->form_close();  | 
                                                        |
| 739 | + $this->display_admin_page_with_no_sidebar();  | 
                                                        |
| 740 | + }  | 
                                                        |
| 741 | +  | 
                                                        |
| 742 | +  | 
                                                        |
| 743 | + protected function _get_datetime_offset_fix_form()  | 
                                                        |
| 744 | +	{ | 
                                                        |
| 745 | +		if (! $this->datetime_fix_offset_form instanceof EE_Form_Section_Proper) { | 
                                                        |
| 746 | + $this->datetime_fix_offset_form = new EE_Form_Section_Proper(  | 
                                                        |
| 747 | + array(  | 
                                                        |
| 748 | + 'name' => 'datetime_offset_fix_option',  | 
                                                        |
| 749 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 750 | + 'subsections' => array(  | 
                                                        |
| 751 | + 'title' => new EE_Form_Section_HTML(  | 
                                                        |
| 752 | + EEH_HTML::h2(  | 
                                                        |
| 753 | +								esc_html__('Datetime Offset Tool', 'event_espresso') | 
                                                        |
| 754 | + )  | 
                                                        |
| 755 | + ),  | 
                                                        |
| 756 | + 'explanation' => new EE_Form_Section_HTML(  | 
                                                        |
| 757 | + EEH_HTML::p(  | 
                                                        |
| 758 | + esc_html__(  | 
                                                        |
| 759 | + 'Use this tool to automatically apply the provided offset to all Event Espresso records in your database that involve dates and times.',  | 
                                                        |
| 760 | + 'event_espresso'  | 
                                                        |
| 761 | + )  | 
                                                        |
| 762 | + )  | 
                                                        |
| 763 | + . EEH_HTML::p(  | 
                                                        |
| 764 | + esc_html__(  | 
                                                        |
| 765 | + 'Note: If you enter 1.25, that will result in the offset of 1 hour 15 minutes being applied. Decimals represent the fraction of hours, not minutes.',  | 
                                                        |
| 766 | + 'event_espresso'  | 
                                                        |
| 767 | + )  | 
                                                        |
| 768 | + )  | 
                                                        |
| 769 | + ),  | 
                                                        |
| 770 | + 'offset_input' => new EE_Float_Input(  | 
                                                        |
| 771 | + array(  | 
                                                        |
| 772 | + 'html_name' => 'offset_for_datetimes',  | 
                                                        |
| 773 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 774 | + 'Offset to apply (in hours):',  | 
                                                        |
| 775 | + 'event_espresso'  | 
                                                        |
| 776 | + ),  | 
                                                        |
| 777 | + 'min_value' => '-12',  | 
                                                        |
| 778 | + 'max_value' => '14',  | 
                                                        |
| 779 | + 'step_value' => '.25',  | 
                                                        |
| 780 | + 'default' => DatetimeOffsetFix::getOffset(),  | 
                                                        |
| 781 | + )  | 
                                                        |
| 782 | + ),  | 
                                                        |
| 783 | + 'date_range_explanation' => new EE_Form_Section_HTML(  | 
                                                        |
| 784 | + EEH_HTML::p(  | 
                                                        |
| 785 | + esc_html__(  | 
                                                        |
| 786 | + 'Leave the following fields blank if you want the offset to be applied to all dates. If however, you want to just apply the offset to a specific range of dates you can restrict the offset application using these fields.',  | 
                                                        |
| 787 | + 'event_espresso'  | 
                                                        |
| 788 | + )  | 
                                                        |
| 789 | + )  | 
                                                        |
| 790 | + . EEH_HTML::p(  | 
                                                        |
| 791 | + EEH_HTML::strong(  | 
                                                        |
| 792 | + sprintf(  | 
                                                        |
| 793 | + esc_html__(  | 
                                                        |
| 794 | + 'Note: please enter the dates in UTC (You can use %1$sthis online tool%2$s to assist with conversions).',  | 
                                                        |
| 795 | + 'event_espresso'  | 
                                                        |
| 796 | + ),  | 
                                                        |
| 797 | + '<a href="https://www.timeanddate.com/worldclock/converter.html">',  | 
                                                        |
| 798 | + '</a>'  | 
                                                        |
| 799 | + )  | 
                                                        |
| 800 | + )  | 
                                                        |
| 801 | + )  | 
                                                        |
| 802 | + ),  | 
                                                        |
| 803 | + 'date_range_start_date' => new EE_Datepicker_Input(  | 
                                                        |
| 804 | + array(  | 
                                                        |
| 805 | + 'html_name' => 'offset_date_start_range',  | 
                                                        |
| 806 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 807 | + 'Start Date for dates the offset applied to:',  | 
                                                        |
| 808 | + 'event_espresso'  | 
                                                        |
| 809 | + ),  | 
                                                        |
| 810 | + )  | 
                                                        |
| 811 | + ),  | 
                                                        |
| 812 | + 'date_range_end_date' => new EE_Datepicker_Input(  | 
                                                        |
| 813 | + array(  | 
                                                        |
| 814 | + 'html_name' => 'offset_date_end_range',  | 
                                                        |
| 815 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 816 | + 'End Date for dates the offset is applied to:',  | 
                                                        |
| 817 | + 'event_espresso'  | 
                                                        |
| 818 | + ),  | 
                                                        |
| 819 | + )  | 
                                                        |
| 820 | + ),  | 
                                                        |
| 821 | + 'submit' => new EE_Submit_Input(  | 
                                                        |
| 822 | + array(  | 
                                                        |
| 823 | + 'html_label_text' => '',  | 
                                                        |
| 824 | +								'default'         => esc_html__('Apply Offset', 'event_espresso'), | 
                                                        |
| 825 | + )  | 
                                                        |
| 826 | + ),  | 
                                                        |
| 827 | + ),  | 
                                                        |
| 828 | + )  | 
                                                        |
| 829 | + );  | 
                                                        |
| 830 | + }  | 
                                                        |
| 831 | + return $this->datetime_fix_offset_form;  | 
                                                        |
| 832 | + }  | 
                                                        |
| 833 | +  | 
                                                        |
| 834 | +  | 
                                                        |
| 835 | + /**  | 
                                                        |
| 836 | + * Callback for the run_datetime_offset_fix route.  | 
                                                        |
| 837 | + *  | 
                                                        |
| 838 | + * @throws EE_Error  | 
                                                        |
| 839 | + */  | 
                                                        |
| 840 | + protected function _apply_datetime_offset()  | 
                                                        |
| 841 | +	{ | 
                                                        |
| 842 | +		if ($_SERVER['REQUEST_METHOD'] === 'POST') { | 
                                                        |
| 843 | + $form = $this->_get_datetime_offset_fix_form();  | 
                                                        |
| 844 | + $form->receive_form_submission($this->_req_data);  | 
                                                        |
| 845 | +			if ($form->is_valid()) { | 
                                                        |
| 846 | + // save offset data so batch processor can get it.  | 
                                                        |
| 847 | +				DatetimeOffsetFix::updateOffset($form->get_input_value('offset_input')); | 
                                                        |
| 848 | +				$utc_timezone = new DateTimeZone('UTC'); | 
                                                        |
| 849 | + $date_range_start_date = DateTime::createFromFormat(  | 
                                                        |
| 850 | + 'm/d/Y H:i:s',  | 
                                                        |
| 851 | +					$form->get_input_value('date_range_start_date') . ' 00:00:00', | 
                                                        |
| 852 | + $utc_timezone  | 
                                                        |
| 853 | + );  | 
                                                        |
| 854 | + $date_range_end_date = DateTime::createFromFormat(  | 
                                                        |
| 855 | + 'm/d/Y H:i:s',  | 
                                                        |
| 856 | +					$form->get_input_value('date_range_end_date') . ' 23:59:59', | 
                                                        |
| 857 | + $utc_timezone  | 
                                                        |
| 858 | + );  | 
                                                        |
| 859 | +				if ($date_range_start_date instanceof DateTime) { | 
                                                        |
| 860 | + DatetimeOffsetFix::updateStartDateRange(DbSafeDateTime::createFromDateTime($date_range_start_date));  | 
                                                        |
| 861 | + }  | 
                                                        |
| 862 | +				if ($date_range_end_date instanceof DateTime) { | 
                                                        |
| 863 | + DatetimeOffsetFix::updateEndDateRange(DbSafeDateTime::createFromDateTime($date_range_end_date));  | 
                                                        |
| 864 | + }  | 
                                                        |
| 865 | + // redirect to batch tool  | 
                                                        |
| 866 | + wp_redirect(  | 
                                                        |
| 867 | + EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 868 | + array(  | 
                                                        |
| 869 | + 'page' => 'espresso_batch',  | 
                                                        |
| 870 | + 'batch' => 'job',  | 
                                                        |
| 871 | +							'label'       => esc_html__('Applying Offset', 'event_espresso'), | 
                                                        |
| 872 | +							'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\DatetimeOffsetFix'), | 
                                                        |
| 873 | + 'return_url' => urlencode(  | 
                                                        |
| 874 | + add_query_arg(  | 
                                                        |
| 875 | + array(  | 
                                                        |
| 876 | + 'action' => 'datetime_tools',  | 
                                                        |
| 877 | + ),  | 
                                                        |
| 878 | + EEH_URL::current_url_without_query_paramaters(  | 
                                                        |
| 879 | + array(  | 
                                                        |
| 880 | + 'return_action',  | 
                                                        |
| 881 | + 'run_datetime_offset_fix_nonce',  | 
                                                        |
| 882 | + 'return',  | 
                                                        |
| 883 | + 'datetime_tools_nonce',  | 
                                                        |
| 884 | + )  | 
                                                        |
| 885 | + )  | 
                                                        |
| 886 | + )  | 
                                                        |
| 887 | + ),  | 
                                                        |
| 888 | + ),  | 
                                                        |
| 889 | + admin_url()  | 
                                                        |
| 890 | + )  | 
                                                        |
| 891 | + );  | 
                                                        |
| 892 | + exit;  | 
                                                        |
| 893 | + }  | 
                                                        |
| 894 | + }  | 
                                                        |
| 895 | + }  | 
                                                        |
| 896 | 896 | }  | 
                                                        
@@ -24,108 +24,108 @@  | 
                                                    ||
| 24 | 24 | */  | 
                                                        
| 25 | 25 | class Registration extends RegistrationCalculationBase  | 
                                                        
| 26 | 26 |  { | 
                                                        
| 27 | - /**  | 
                                                        |
| 28 | - * @var EEM_Registration  | 
                                                        |
| 29 | - */  | 
                                                        |
| 30 | - protected $registration_model;  | 
                                                        |
| 27 | + /**  | 
                                                        |
| 28 | + * @var EEM_Registration  | 
                                                        |
| 29 | + */  | 
                                                        |
| 30 | + protected $registration_model;  | 
                                                        |
| 31 | 31 | |
| 32 | - /**  | 
                                                        |
| 33 | - * Registration constructor.  | 
                                                        |
| 34 | - * @param EEM_Registration $registration_model  | 
                                                        |
| 35 | - */  | 
                                                        |
| 36 | - public function __construct(EEM_Registration $registration_model)  | 
                                                        |
| 37 | -    { | 
                                                        |
| 38 | - $this->registration_model = $registration_model;  | 
                                                        |
| 39 | - }  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * Registration constructor.  | 
                                                        |
| 34 | + * @param EEM_Registration $registration_model  | 
                                                        |
| 35 | + */  | 
                                                        |
| 36 | + public function __construct(EEM_Registration $registration_model)  | 
                                                        |
| 37 | +	{ | 
                                                        |
| 38 | + $this->registration_model = $registration_model;  | 
                                                        |
| 39 | + }  | 
                                                        |
| 40 | 40 | |
| 41 | - /**  | 
                                                        |
| 42 | - * Calculates the checkin status for each datetime this registration has access to  | 
                                                        |
| 43 | - *  | 
                                                        |
| 44 | - * @param array $wpdb_row  | 
                                                        |
| 45 | - * @param WP_REST_Request $request  | 
                                                        |
| 46 | - * @param RegistrationControllerBase $controller  | 
                                                        |
| 47 | - * @return array  | 
                                                        |
| 48 | - * @throws EE_Error  | 
                                                        |
| 49 | - * @throws InvalidDataTypeException  | 
                                                        |
| 50 | - * @throws InvalidInterfaceException  | 
                                                        |
| 51 | - * @throws InvalidArgumentException  | 
                                                        |
| 52 | - */  | 
                                                        |
| 53 | - public function datetimeCheckinStati($wpdb_row, $request, $controller)  | 
                                                        |
| 54 | -    { | 
                                                        |
| 55 | -        if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) { | 
                                                        |
| 56 | - $reg = $this->registration_model->get_one_by_ID($wpdb_row['Registration.REG_ID']);  | 
                                                        |
| 57 | -        } else { | 
                                                        |
| 58 | - $reg = null;  | 
                                                        |
| 59 | - }  | 
                                                        |
| 60 | - if (! $reg instanceof EE_Registration  | 
                                                        |
| 61 | -        ) { | 
                                                        |
| 62 | - throw new EE_Error(  | 
                                                        |
| 63 | - sprintf(  | 
                                                        |
| 64 | - __(  | 
                                                        |
| 65 | - // @codingStandardsIgnoreStart  | 
                                                        |
| 66 | - 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found',  | 
                                                        |
| 67 | - // @codingStandardsIgnoreEnd  | 
                                                        |
| 68 | - 'event_espresso'  | 
                                                        |
| 69 | - ),  | 
                                                        |
| 70 | - $wpdb_row['Registration.REG_ID'],  | 
                                                        |
| 71 | - print_r($wpdb_row, true)  | 
                                                        |
| 72 | - )  | 
                                                        |
| 73 | - );  | 
                                                        |
| 74 | - }  | 
                                                        |
| 75 | - $datetime_ids = EEM_Datetime::instance()->get_col(  | 
                                                        |
| 76 | - [  | 
                                                        |
| 77 | - [  | 
                                                        |
| 78 | - 'Ticket.TKT_ID' => $reg->ticket_ID(),  | 
                                                        |
| 79 | - ],  | 
                                                        |
| 80 | - 'default_where_conditions' => EEM_Base::default_where_conditions_minimum_all,  | 
                                                        |
| 81 | - ]  | 
                                                        |
| 82 | - );  | 
                                                        |
| 83 | - $checkin_stati = array();  | 
                                                        |
| 84 | -        foreach ($datetime_ids as $datetime_id) { | 
                                                        |
| 85 | - $status = $reg->check_in_status_for_datetime($datetime_id);  | 
                                                        |
| 86 | -            switch ($status) { | 
                                                        |
| 87 | - case EE_Checkin::status_checked_out:  | 
                                                        |
| 88 | - $status_pretty = 'OUT';  | 
                                                        |
| 89 | - break;  | 
                                                        |
| 90 | - case EE_Checkin::status_checked_in:  | 
                                                        |
| 91 | - $status_pretty = 'IN';  | 
                                                        |
| 92 | - break;  | 
                                                        |
| 93 | - case EE_Checkin::status_checked_never:  | 
                                                        |
| 94 | - default:  | 
                                                        |
| 95 | - $status_pretty = 'NEVER';  | 
                                                        |
| 96 | - break;  | 
                                                        |
| 97 | - }  | 
                                                        |
| 98 | - $checkin_stati[ $datetime_id ] = $status_pretty;  | 
                                                        |
| 99 | - }  | 
                                                        |
| 100 | - return $checkin_stati;  | 
                                                        |
| 101 | - }  | 
                                                        |
| 41 | + /**  | 
                                                        |
| 42 | + * Calculates the checkin status for each datetime this registration has access to  | 
                                                        |
| 43 | + *  | 
                                                        |
| 44 | + * @param array $wpdb_row  | 
                                                        |
| 45 | + * @param WP_REST_Request $request  | 
                                                        |
| 46 | + * @param RegistrationControllerBase $controller  | 
                                                        |
| 47 | + * @return array  | 
                                                        |
| 48 | + * @throws EE_Error  | 
                                                        |
| 49 | + * @throws InvalidDataTypeException  | 
                                                        |
| 50 | + * @throws InvalidInterfaceException  | 
                                                        |
| 51 | + * @throws InvalidArgumentException  | 
                                                        |
| 52 | + */  | 
                                                        |
| 53 | + public function datetimeCheckinStati($wpdb_row, $request, $controller)  | 
                                                        |
| 54 | +	{ | 
                                                        |
| 55 | +		if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) { | 
                                                        |
| 56 | + $reg = $this->registration_model->get_one_by_ID($wpdb_row['Registration.REG_ID']);  | 
                                                        |
| 57 | +		} else { | 
                                                        |
| 58 | + $reg = null;  | 
                                                        |
| 59 | + }  | 
                                                        |
| 60 | + if (! $reg instanceof EE_Registration  | 
                                                        |
| 61 | +		) { | 
                                                        |
| 62 | + throw new EE_Error(  | 
                                                        |
| 63 | + sprintf(  | 
                                                        |
| 64 | + __(  | 
                                                        |
| 65 | + // @codingStandardsIgnoreStart  | 
                                                        |
| 66 | + 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found',  | 
                                                        |
| 67 | + // @codingStandardsIgnoreEnd  | 
                                                        |
| 68 | + 'event_espresso'  | 
                                                        |
| 69 | + ),  | 
                                                        |
| 70 | + $wpdb_row['Registration.REG_ID'],  | 
                                                        |
| 71 | + print_r($wpdb_row, true)  | 
                                                        |
| 72 | + )  | 
                                                        |
| 73 | + );  | 
                                                        |
| 74 | + }  | 
                                                        |
| 75 | + $datetime_ids = EEM_Datetime::instance()->get_col(  | 
                                                        |
| 76 | + [  | 
                                                        |
| 77 | + [  | 
                                                        |
| 78 | + 'Ticket.TKT_ID' => $reg->ticket_ID(),  | 
                                                        |
| 79 | + ],  | 
                                                        |
| 80 | + 'default_where_conditions' => EEM_Base::default_where_conditions_minimum_all,  | 
                                                        |
| 81 | + ]  | 
                                                        |
| 82 | + );  | 
                                                        |
| 83 | + $checkin_stati = array();  | 
                                                        |
| 84 | +		foreach ($datetime_ids as $datetime_id) { | 
                                                        |
| 85 | + $status = $reg->check_in_status_for_datetime($datetime_id);  | 
                                                        |
| 86 | +			switch ($status) { | 
                                                        |
| 87 | + case EE_Checkin::status_checked_out:  | 
                                                        |
| 88 | + $status_pretty = 'OUT';  | 
                                                        |
| 89 | + break;  | 
                                                        |
| 90 | + case EE_Checkin::status_checked_in:  | 
                                                        |
| 91 | + $status_pretty = 'IN';  | 
                                                        |
| 92 | + break;  | 
                                                        |
| 93 | + case EE_Checkin::status_checked_never:  | 
                                                        |
| 94 | + default:  | 
                                                        |
| 95 | + $status_pretty = 'NEVER';  | 
                                                        |
| 96 | + break;  | 
                                                        |
| 97 | + }  | 
                                                        |
| 98 | + $checkin_stati[ $datetime_id ] = $status_pretty;  | 
                                                        |
| 99 | + }  | 
                                                        |
| 100 | + return $checkin_stati;  | 
                                                        |
| 101 | + }  | 
                                                        |
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /**  | 
                                                        |
| 105 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations.  | 
                                                        |
| 106 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation.  | 
                                                        |
| 107 | - *  | 
                                                        |
| 108 | - * @since 4.9.68.p  | 
                                                        |
| 109 | - * @return array  | 
                                                        |
| 110 | - */  | 
                                                        |
| 111 | - public function schemaForCalculations()  | 
                                                        |
| 112 | -    { | 
                                                        |
| 113 | - return array(  | 
                                                        |
| 114 | - 'datetime_checkin_stati' => array(  | 
                                                        |
| 115 | - 'description' => esc_html__(  | 
                                                        |
| 116 | - 'Returns the checkin status for each datetime this registration has access to.',  | 
                                                        |
| 117 | - 'event_espresso'  | 
                                                        |
| 118 | - ),  | 
                                                        |
| 119 | - 'type' => 'object',  | 
                                                        |
| 120 | - 'properties' => array(),  | 
                                                        |
| 121 | - 'additionalProperties' => array(  | 
                                                        |
| 122 | - 'description' => esc_html__(  | 
                                                        |
| 123 | - 'Keys are date-time ids and values are the check-in status',  | 
                                                        |
| 124 | - 'event_espresso'  | 
                                                        |
| 125 | - ),  | 
                                                        |
| 126 | - 'type' => 'string'  | 
                                                        |
| 127 | - ),  | 
                                                        |
| 128 | - ),  | 
                                                        |
| 129 | - );  | 
                                                        |
| 130 | - }  | 
                                                        |
| 104 | + /**  | 
                                                        |
| 105 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations.  | 
                                                        |
| 106 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation.  | 
                                                        |
| 107 | + *  | 
                                                        |
| 108 | + * @since 4.9.68.p  | 
                                                        |
| 109 | + * @return array  | 
                                                        |
| 110 | + */  | 
                                                        |
| 111 | + public function schemaForCalculations()  | 
                                                        |
| 112 | +	{ | 
                                                        |
| 113 | + return array(  | 
                                                        |
| 114 | + 'datetime_checkin_stati' => array(  | 
                                                        |
| 115 | + 'description' => esc_html__(  | 
                                                        |
| 116 | + 'Returns the checkin status for each datetime this registration has access to.',  | 
                                                        |
| 117 | + 'event_espresso'  | 
                                                        |
| 118 | + ),  | 
                                                        |
| 119 | + 'type' => 'object',  | 
                                                        |
| 120 | + 'properties' => array(),  | 
                                                        |
| 121 | + 'additionalProperties' => array(  | 
                                                        |
| 122 | + 'description' => esc_html__(  | 
                                                        |
| 123 | + 'Keys are date-time ids and values are the check-in status',  | 
                                                        |
| 124 | + 'event_espresso'  | 
                                                        |
| 125 | + ),  | 
                                                        |
| 126 | + 'type' => 'string'  | 
                                                        |
| 127 | + ),  | 
                                                        |
| 128 | + ),  | 
                                                        |
| 129 | + );  | 
                                                        |
| 130 | + }  | 
                                                        |
| 131 | 131 | }  | 
                                                        
@@ -44,531 +44,531 @@  | 
                                                    ||
| 44 | 44 | class OrganizationSettings extends FormHandler  | 
                                                        
| 45 | 45 |  { | 
                                                        
| 46 | 46 | |
| 47 | - /**  | 
                                                        |
| 48 | - * @var EE_Organization_Config  | 
                                                        |
| 49 | - */  | 
                                                        |
| 50 | - protected $organization_config;  | 
                                                        |
| 47 | + /**  | 
                                                        |
| 48 | + * @var EE_Organization_Config  | 
                                                        |
| 49 | + */  | 
                                                        |
| 50 | + protected $organization_config;  | 
                                                        |
| 51 | 51 | |
| 52 | - /**  | 
                                                        |
| 53 | - * @var EE_Core_Config  | 
                                                        |
| 54 | - */  | 
                                                        |
| 55 | - protected $core_config;  | 
                                                        |
| 52 | + /**  | 
                                                        |
| 53 | + * @var EE_Core_Config  | 
                                                        |
| 54 | + */  | 
                                                        |
| 55 | + protected $core_config;  | 
                                                        |
| 56 | 56 | |
| 57 | 57 | |
| 58 | - /**  | 
                                                        |
| 59 | - * @var EE_Network_Core_Config  | 
                                                        |
| 60 | - */  | 
                                                        |
| 61 | - protected $network_core_config;  | 
                                                        |
| 58 | + /**  | 
                                                        |
| 59 | + * @var EE_Network_Core_Config  | 
                                                        |
| 60 | + */  | 
                                                        |
| 61 | + protected $network_core_config;  | 
                                                        |
| 62 | 62 | |
| 63 | - /**  | 
                                                        |
| 64 | - * @var CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 65 | - */  | 
                                                        |
| 66 | - protected $countrySubRegionDao;  | 
                                                        |
| 63 | + /**  | 
                                                        |
| 64 | + * @var CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 65 | + */  | 
                                                        |
| 66 | + protected $countrySubRegionDao;  | 
                                                        |
| 67 | 67 | |
| 68 | - /**  | 
                                                        |
| 69 | - * Form constructor.  | 
                                                        |
| 70 | - *  | 
                                                        |
| 71 | - * @param EE_Registry $registry  | 
                                                        |
| 72 | - * @param EE_Organization_Config $organization_config  | 
                                                        |
| 73 | - * @param EE_Core_Config $core_config  | 
                                                        |
| 74 | - * @param EE_Network_Core_Config $network_core_config  | 
                                                        |
| 75 | - * @param CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 76 | - * @throws InvalidArgumentException  | 
                                                        |
| 77 | - * @throws InvalidDataTypeException  | 
                                                        |
| 78 | - * @throws DomainException  | 
                                                        |
| 79 | - */  | 
                                                        |
| 80 | - public function __construct(  | 
                                                        |
| 81 | - EE_Registry $registry,  | 
                                                        |
| 82 | - EE_Organization_Config $organization_config,  | 
                                                        |
| 83 | - EE_Core_Config $core_config,  | 
                                                        |
| 84 | - EE_Network_Core_Config $network_core_config,  | 
                                                        |
| 85 | - CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 86 | -    ) { | 
                                                        |
| 87 | - $this->organization_config = $organization_config;  | 
                                                        |
| 88 | - $this->core_config = $core_config;  | 
                                                        |
| 89 | - $this->network_core_config = $network_core_config;  | 
                                                        |
| 90 | - $this->countrySubRegionDao = $countrySubRegionDao;  | 
                                                        |
| 91 | - parent::__construct(  | 
                                                        |
| 92 | -            esc_html__('Your Organization Settings', 'event_espresso'), | 
                                                        |
| 93 | -            esc_html__('Your Organization Settings', 'event_espresso'), | 
                                                        |
| 94 | - 'organization_settings',  | 
                                                        |
| 95 | - '',  | 
                                                        |
| 96 | - FormHandler::DO_NOT_SETUP_FORM,  | 
                                                        |
| 97 | - $registry  | 
                                                        |
| 98 | - );  | 
                                                        |
| 99 | - }  | 
                                                        |
| 68 | + /**  | 
                                                        |
| 69 | + * Form constructor.  | 
                                                        |
| 70 | + *  | 
                                                        |
| 71 | + * @param EE_Registry $registry  | 
                                                        |
| 72 | + * @param EE_Organization_Config $organization_config  | 
                                                        |
| 73 | + * @param EE_Core_Config $core_config  | 
                                                        |
| 74 | + * @param EE_Network_Core_Config $network_core_config  | 
                                                        |
| 75 | + * @param CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 76 | + * @throws InvalidArgumentException  | 
                                                        |
| 77 | + * @throws InvalidDataTypeException  | 
                                                        |
| 78 | + * @throws DomainException  | 
                                                        |
| 79 | + */  | 
                                                        |
| 80 | + public function __construct(  | 
                                                        |
| 81 | + EE_Registry $registry,  | 
                                                        |
| 82 | + EE_Organization_Config $organization_config,  | 
                                                        |
| 83 | + EE_Core_Config $core_config,  | 
                                                        |
| 84 | + EE_Network_Core_Config $network_core_config,  | 
                                                        |
| 85 | + CountrySubRegionDao $countrySubRegionDao  | 
                                                        |
| 86 | +	) { | 
                                                        |
| 87 | + $this->organization_config = $organization_config;  | 
                                                        |
| 88 | + $this->core_config = $core_config;  | 
                                                        |
| 89 | + $this->network_core_config = $network_core_config;  | 
                                                        |
| 90 | + $this->countrySubRegionDao = $countrySubRegionDao;  | 
                                                        |
| 91 | + parent::__construct(  | 
                                                        |
| 92 | +			esc_html__('Your Organization Settings', 'event_espresso'), | 
                                                        |
| 93 | +			esc_html__('Your Organization Settings', 'event_espresso'), | 
                                                        |
| 94 | + 'organization_settings',  | 
                                                        |
| 95 | + '',  | 
                                                        |
| 96 | + FormHandler::DO_NOT_SETUP_FORM,  | 
                                                        |
| 97 | + $registry  | 
                                                        |
| 98 | + );  | 
                                                        |
| 99 | + }  | 
                                                        |
| 100 | 100 | |
| 101 | 101 | |
| 102 | - /**  | 
                                                        |
| 103 | - * creates and returns the actual form  | 
                                                        |
| 104 | - *  | 
                                                        |
| 105 | - * @return EE_Form_Section_Proper  | 
                                                        |
| 106 | - * @throws EE_Error  | 
                                                        |
| 107 | - * @throws InvalidArgumentException  | 
                                                        |
| 108 | - * @throws InvalidDataTypeException  | 
                                                        |
| 109 | - * @throws InvalidInterfaceException  | 
                                                        |
| 110 | - * @throws ReflectionException  | 
                                                        |
| 111 | - */  | 
                                                        |
| 112 | - public function generate()  | 
                                                        |
| 113 | -    { | 
                                                        |
| 114 | - $has_sub_regions = EEM_State::instance()->count(  | 
                                                        |
| 115 | -            array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) | 
                                                        |
| 116 | - );  | 
                                                        |
| 117 | - $form = new EE_Form_Section_Proper(  | 
                                                        |
| 118 | - array(  | 
                                                        |
| 119 | - 'name' => 'organization_settings',  | 
                                                        |
| 120 | - 'html_id' => 'organization_settings',  | 
                                                        |
| 121 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 122 | - 'subsections' => array(  | 
                                                        |
| 123 | - 'contact_information_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 124 | - EEH_HTML::h2(  | 
                                                        |
| 125 | -                            esc_html__('Contact Information', 'event_espresso') | 
                                                        |
| 126 | - . ' '  | 
                                                        |
| 127 | -                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), | 
                                                        |
| 128 | - '',  | 
                                                        |
| 129 | - 'contact-information-hdr'  | 
                                                        |
| 130 | - )  | 
                                                        |
| 131 | - ),  | 
                                                        |
| 132 | - 'organization_name' => new EE_Text_Input(  | 
                                                        |
| 133 | - array(  | 
                                                        |
| 134 | - 'html_name' => 'organization_name',  | 
                                                        |
| 135 | -                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'), | 
                                                        |
| 136 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 137 | - 'Displayed on all emails and invoices.',  | 
                                                        |
| 138 | - 'event_espresso'  | 
                                                        |
| 139 | - ),  | 
                                                        |
| 140 | -                            'default'         => $this->organization_config->get_pretty('name'), | 
                                                        |
| 141 | - 'required' => false,  | 
                                                        |
| 142 | - )  | 
                                                        |
| 143 | - ),  | 
                                                        |
| 144 | - 'organization_address_1' => new EE_Text_Input(  | 
                                                        |
| 145 | - array(  | 
                                                        |
| 146 | - 'html_name' => 'organization_address_1',  | 
                                                        |
| 147 | -                            'html_label_text' => esc_html__('Street Address', 'event_espresso'), | 
                                                        |
| 148 | -                            'default'         => $this->organization_config->get_pretty('address_1'), | 
                                                        |
| 149 | - 'required' => false,  | 
                                                        |
| 150 | - )  | 
                                                        |
| 151 | - ),  | 
                                                        |
| 152 | - 'organization_address_2' => new EE_Text_Input(  | 
                                                        |
| 153 | - array(  | 
                                                        |
| 154 | - 'html_name' => 'organization_address_2',  | 
                                                        |
| 155 | -                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), | 
                                                        |
| 156 | -                            'default'         => $this->organization_config->get_pretty('address_2'), | 
                                                        |
| 157 | - 'required' => false,  | 
                                                        |
| 158 | - )  | 
                                                        |
| 159 | - ),  | 
                                                        |
| 160 | - 'organization_city' => new EE_Text_Input(  | 
                                                        |
| 161 | - array(  | 
                                                        |
| 162 | - 'html_name' => 'organization_city',  | 
                                                        |
| 163 | -                            'html_label_text' => esc_html__('City', 'event_espresso'), | 
                                                        |
| 164 | -                            'default'         => $this->organization_config->get_pretty('city'), | 
                                                        |
| 165 | - 'required' => false,  | 
                                                        |
| 166 | - )  | 
                                                        |
| 167 | - ),  | 
                                                        |
| 168 | - 'organization_country' => new EE_Country_Select_Input(  | 
                                                        |
| 169 | - null,  | 
                                                        |
| 170 | - array(  | 
                                                        |
| 171 | - EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,  | 
                                                        |
| 172 | - 'html_name' => 'organization_country',  | 
                                                        |
| 173 | -                            'html_label_text' => esc_html__('Country', 'event_espresso'), | 
                                                        |
| 174 | - 'default' => $this->organization_config->CNT_ISO,  | 
                                                        |
| 175 | - 'required' => false,  | 
                                                        |
| 176 | - 'html_help_text' => sprintf(  | 
                                                        |
| 177 | - esc_html__(  | 
                                                        |
| 178 | - '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',  | 
                                                        |
| 179 | - 'event_espresso'  | 
                                                        |
| 180 | - ),  | 
                                                        |
| 181 | - '<span class="reminder-spn">',  | 
                                                        |
| 182 | - '</span>'  | 
                                                        |
| 183 | - ),  | 
                                                        |
| 184 | - )  | 
                                                        |
| 185 | - ),  | 
                                                        |
| 186 | - 'organization_state' => new EE_State_Select_Input(  | 
                                                        |
| 187 | - null,  | 
                                                        |
| 188 | - array(  | 
                                                        |
| 189 | - 'html_name' => 'organization_state',  | 
                                                        |
| 190 | -                            'html_label_text' => esc_html__('State/Province', 'event_espresso'), | 
                                                        |
| 191 | - 'default' => $this->organization_config->STA_ID,  | 
                                                        |
| 192 | - 'required' => false,  | 
                                                        |
| 193 | - 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions  | 
                                                        |
| 194 | - ? sprintf(  | 
                                                        |
| 195 | - esc_html__(  | 
                                                        |
| 196 | - 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',  | 
                                                        |
| 197 | - 'event_espresso'  | 
                                                        |
| 198 | - ),  | 
                                                        |
| 199 | - '<span class="reminder-spn">',  | 
                                                        |
| 200 | - '</span>',  | 
                                                        |
| 201 | - '<br />'  | 
                                                        |
| 202 | - )  | 
                                                        |
| 203 | - : '',  | 
                                                        |
| 204 | - )  | 
                                                        |
| 205 | - ),  | 
                                                        |
| 206 | - 'organization_zip' => new EE_Text_Input(  | 
                                                        |
| 207 | - array(  | 
                                                        |
| 208 | - 'html_name' => 'organization_zip',  | 
                                                        |
| 209 | -                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), | 
                                                        |
| 210 | -                            'default'         => $this->organization_config->get_pretty('zip'), | 
                                                        |
| 211 | - 'required' => false,  | 
                                                        |
| 212 | - )  | 
                                                        |
| 213 | - ),  | 
                                                        |
| 214 | - 'organization_email' => new EE_Text_Input(  | 
                                                        |
| 215 | - array(  | 
                                                        |
| 216 | - 'html_name' => 'organization_email',  | 
                                                        |
| 217 | -                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), | 
                                                        |
| 218 | - 'html_help_text' => sprintf(  | 
                                                        |
| 219 | - esc_html__(  | 
                                                        |
| 220 | - 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',  | 
                                                        |
| 221 | - 'event_espresso'  | 
                                                        |
| 222 | - ),  | 
                                                        |
| 223 | - '<code>[CO_FORMATTED_EMAIL]</code>',  | 
                                                        |
| 224 | - '<code>[CO_EMAIL]</code>'  | 
                                                        |
| 225 | - ),  | 
                                                        |
| 226 | -                            'default'         => $this->organization_config->get_pretty('email'), | 
                                                        |
| 227 | - 'required' => false,  | 
                                                        |
| 228 | - )  | 
                                                        |
| 229 | - ),  | 
                                                        |
| 230 | - 'organization_phone' => new EE_Text_Input(  | 
                                                        |
| 231 | - array(  | 
                                                        |
| 232 | - 'html_name' => 'organization_phone',  | 
                                                        |
| 233 | -                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'), | 
                                                        |
| 234 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 235 | - 'The phone number for your organization.',  | 
                                                        |
| 236 | - 'event_espresso'  | 
                                                        |
| 237 | - ),  | 
                                                        |
| 238 | -                            'default'         => $this->organization_config->get_pretty('phone'), | 
                                                        |
| 239 | - 'required' => false,  | 
                                                        |
| 240 | - )  | 
                                                        |
| 241 | - ),  | 
                                                        |
| 242 | - 'organization_vat' => new EE_Text_Input(  | 
                                                        |
| 243 | - array(  | 
                                                        |
| 244 | - 'html_name' => 'organization_vat',  | 
                                                        |
| 245 | -                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), | 
                                                        |
| 246 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 247 | - 'The VAT/Tax Number may be displayed on invoices and receipts.',  | 
                                                        |
| 248 | - 'event_espresso'  | 
                                                        |
| 249 | - ),  | 
                                                        |
| 250 | -                            'default'         => $this->organization_config->get_pretty('vat'), | 
                                                        |
| 251 | - 'required' => false,  | 
                                                        |
| 252 | - )  | 
                                                        |
| 253 | - ),  | 
                                                        |
| 254 | - 'company_logo_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 255 | - EEH_HTML::h2(  | 
                                                        |
| 256 | -                            esc_html__('Company Logo', 'event_espresso') | 
                                                        |
| 257 | - . ' '  | 
                                                        |
| 258 | -                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), | 
                                                        |
| 259 | - '',  | 
                                                        |
| 260 | - 'company-logo-hdr'  | 
                                                        |
| 261 | - )  | 
                                                        |
| 262 | - ),  | 
                                                        |
| 263 | - 'organization_logo_url' => new EE_Admin_File_Uploader_Input(  | 
                                                        |
| 264 | - array(  | 
                                                        |
| 265 | - 'html_name' => 'organization_logo_url',  | 
                                                        |
| 266 | -                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), | 
                                                        |
| 267 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 268 | - 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',  | 
                                                        |
| 269 | - 'event_espresso'  | 
                                                        |
| 270 | - ),  | 
                                                        |
| 271 | -                            'default'         => $this->organization_config->get_pretty('logo_url'), | 
                                                        |
| 272 | - 'required' => false,  | 
                                                        |
| 273 | - )  | 
                                                        |
| 274 | - ),  | 
                                                        |
| 275 | - 'social_links_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 276 | - EEH_HTML::h2(  | 
                                                        |
| 277 | -                            esc_html__('Social Links', 'event_espresso') | 
                                                        |
| 278 | - . ' '  | 
                                                        |
| 279 | -                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) | 
                                                        |
| 280 | - . EEH_HTML::br()  | 
                                                        |
| 281 | - . EEH_HTML::p(  | 
                                                        |
| 282 | - esc_html__(  | 
                                                        |
| 283 | - 'Enter any links to social accounts for your organization here',  | 
                                                        |
| 284 | - 'event_espresso'  | 
                                                        |
| 285 | - ),  | 
                                                        |
| 286 | - '',  | 
                                                        |
| 287 | - 'description'  | 
                                                        |
| 288 | - ),  | 
                                                        |
| 289 | - '',  | 
                                                        |
| 290 | - 'social-links-hdr'  | 
                                                        |
| 291 | - )  | 
                                                        |
| 292 | - ),  | 
                                                        |
| 293 | - 'organization_facebook' => new EE_Text_Input(  | 
                                                        |
| 294 | - array(  | 
                                                        |
| 295 | - 'html_name' => 'organization_facebook',  | 
                                                        |
| 296 | -                            'html_label_text' => esc_html__('Facebook', 'event_espresso'), | 
                                                        |
| 297 | - 'other_html_attributes' => ' placeholder="facebook.com/profile.name"',  | 
                                                        |
| 298 | -                            'default'         => $this->organization_config->get_pretty('facebook'), | 
                                                        |
| 299 | - 'required' => false,  | 
                                                        |
| 300 | - )  | 
                                                        |
| 301 | - ),  | 
                                                        |
| 302 | - 'organization_twitter' => new EE_Text_Input(  | 
                                                        |
| 303 | - array(  | 
                                                        |
| 304 | - 'html_name' => 'organization_twitter',  | 
                                                        |
| 305 | -                            'html_label_text' => esc_html__('Twitter', 'event_espresso'), | 
                                                        |
| 306 | - 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',  | 
                                                        |
| 307 | -                            'default'         => $this->organization_config->get_pretty('twitter'), | 
                                                        |
| 308 | - 'required' => false,  | 
                                                        |
| 309 | - )  | 
                                                        |
| 310 | - ),  | 
                                                        |
| 311 | - 'organization_linkedin' => new EE_Text_Input(  | 
                                                        |
| 312 | - array(  | 
                                                        |
| 313 | - 'html_name' => 'organization_linkedin',  | 
                                                        |
| 314 | -                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), | 
                                                        |
| 315 | - 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',  | 
                                                        |
| 316 | -                            'default'         => $this->organization_config->get_pretty('linkedin'), | 
                                                        |
| 317 | - 'required' => false,  | 
                                                        |
| 318 | - )  | 
                                                        |
| 319 | - ),  | 
                                                        |
| 320 | - 'organization_pinterest' => new EE_Text_Input(  | 
                                                        |
| 321 | - array(  | 
                                                        |
| 322 | - 'html_name' => 'organization_pinterest',  | 
                                                        |
| 323 | -                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'), | 
                                                        |
| 324 | - 'other_html_attributes' => ' placeholder="pinterest.com/profilename"',  | 
                                                        |
| 325 | -                            'default'         => $this->organization_config->get_pretty('pinterest'), | 
                                                        |
| 326 | - 'required' => false,  | 
                                                        |
| 327 | - )  | 
                                                        |
| 328 | - ),  | 
                                                        |
| 329 | - 'organization_instagram' => new EE_Text_Input(  | 
                                                        |
| 330 | - array(  | 
                                                        |
| 331 | - 'html_name' => 'organization_instagram',  | 
                                                        |
| 332 | -                            'html_label_text' => esc_html__('Instagram', 'event_espresso'), | 
                                                        |
| 333 | - 'other_html_attributes' => ' placeholder="instagram.com/handle"',  | 
                                                        |
| 334 | -                            'default'         => $this->organization_config->get_pretty('instagram'), | 
                                                        |
| 335 | - 'required' => false,  | 
                                                        |
| 336 | - )  | 
                                                        |
| 337 | - ),  | 
                                                        |
| 338 | - ),  | 
                                                        |
| 339 | - )  | 
                                                        |
| 340 | - );  | 
                                                        |
| 341 | -        if (is_main_site()) { | 
                                                        |
| 342 | - $form->add_subsections(  | 
                                                        |
| 343 | - array(  | 
                                                        |
| 344 | - 'site_license_key_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 345 | - EEH_HTML::h2(  | 
                                                        |
| 346 | -                            esc_html__('Your Event Espresso License Key', 'event_espresso') | 
                                                        |
| 347 | - . ' '  | 
                                                        |
| 348 | - . EEH_HTML::span(  | 
                                                        |
| 349 | -                                EEH_Template::get_help_tab_link('site_license_key_info'), | 
                                                        |
| 350 | - 'help_tour_activation'  | 
                                                        |
| 351 | - ),  | 
                                                        |
| 352 | - '',  | 
                                                        |
| 353 | - 'site-license-key-hdr'  | 
                                                        |
| 354 | - )  | 
                                                        |
| 355 | - ),  | 
                                                        |
| 356 | - 'site_license_key' => $this->getSiteLicenseKeyField()  | 
                                                        |
| 357 | - )  | 
                                                        |
| 358 | - );  | 
                                                        |
| 359 | - $form->add_subsections(  | 
                                                        |
| 360 | - array(  | 
                                                        |
| 361 | - 'uxip_optin_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 362 | - $this->uxipOptinText()  | 
                                                        |
| 363 | - ),  | 
                                                        |
| 364 | - 'ueip_optin' => new EE_Checkbox_Multi_Input(  | 
                                                        |
| 365 | - array(  | 
                                                        |
| 366 | -                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso') | 
                                                        |
| 367 | - ),  | 
                                                        |
| 368 | - array(  | 
                                                        |
| 369 | - 'html_name' => EE_Core_Config::OPTION_NAME_UXIP,  | 
                                                        |
| 370 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 371 | - 'UXIP Opt In?',  | 
                                                        |
| 372 | - 'event_espresso'  | 
                                                        |
| 373 | - ),  | 
                                                        |
| 374 | - 'default' => isset($this->core_config->ee_ueip_optin)  | 
                                                        |
| 375 | - ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 376 | - : false,  | 
                                                        |
| 377 | - 'required' => false,  | 
                                                        |
| 378 | - )  | 
                                                        |
| 379 | - ),  | 
                                                        |
| 380 | - ),  | 
                                                        |
| 381 | - 'organization_instagram',  | 
                                                        |
| 382 | - false  | 
                                                        |
| 383 | - );  | 
                                                        |
| 384 | - }  | 
                                                        |
| 385 | - return $form;  | 
                                                        |
| 386 | - }  | 
                                                        |
| 102 | + /**  | 
                                                        |
| 103 | + * creates and returns the actual form  | 
                                                        |
| 104 | + *  | 
                                                        |
| 105 | + * @return EE_Form_Section_Proper  | 
                                                        |
| 106 | + * @throws EE_Error  | 
                                                        |
| 107 | + * @throws InvalidArgumentException  | 
                                                        |
| 108 | + * @throws InvalidDataTypeException  | 
                                                        |
| 109 | + * @throws InvalidInterfaceException  | 
                                                        |
| 110 | + * @throws ReflectionException  | 
                                                        |
| 111 | + */  | 
                                                        |
| 112 | + public function generate()  | 
                                                        |
| 113 | +	{ | 
                                                        |
| 114 | + $has_sub_regions = EEM_State::instance()->count(  | 
                                                        |
| 115 | +			array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO)) | 
                                                        |
| 116 | + );  | 
                                                        |
| 117 | + $form = new EE_Form_Section_Proper(  | 
                                                        |
| 118 | + array(  | 
                                                        |
| 119 | + 'name' => 'organization_settings',  | 
                                                        |
| 120 | + 'html_id' => 'organization_settings',  | 
                                                        |
| 121 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 122 | + 'subsections' => array(  | 
                                                        |
| 123 | + 'contact_information_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 124 | + EEH_HTML::h2(  | 
                                                        |
| 125 | +							esc_html__('Contact Information', 'event_espresso') | 
                                                        |
| 126 | + . ' '  | 
                                                        |
| 127 | +							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')), | 
                                                        |
| 128 | + '',  | 
                                                        |
| 129 | + 'contact-information-hdr'  | 
                                                        |
| 130 | + )  | 
                                                        |
| 131 | + ),  | 
                                                        |
| 132 | + 'organization_name' => new EE_Text_Input(  | 
                                                        |
| 133 | + array(  | 
                                                        |
| 134 | + 'html_name' => 'organization_name',  | 
                                                        |
| 135 | +							'html_label_text' => esc_html__('Organization Name', 'event_espresso'), | 
                                                        |
| 136 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 137 | + 'Displayed on all emails and invoices.',  | 
                                                        |
| 138 | + 'event_espresso'  | 
                                                        |
| 139 | + ),  | 
                                                        |
| 140 | +							'default'         => $this->organization_config->get_pretty('name'), | 
                                                        |
| 141 | + 'required' => false,  | 
                                                        |
| 142 | + )  | 
                                                        |
| 143 | + ),  | 
                                                        |
| 144 | + 'organization_address_1' => new EE_Text_Input(  | 
                                                        |
| 145 | + array(  | 
                                                        |
| 146 | + 'html_name' => 'organization_address_1',  | 
                                                        |
| 147 | +							'html_label_text' => esc_html__('Street Address', 'event_espresso'), | 
                                                        |
| 148 | +							'default'         => $this->organization_config->get_pretty('address_1'), | 
                                                        |
| 149 | + 'required' => false,  | 
                                                        |
| 150 | + )  | 
                                                        |
| 151 | + ),  | 
                                                        |
| 152 | + 'organization_address_2' => new EE_Text_Input(  | 
                                                        |
| 153 | + array(  | 
                                                        |
| 154 | + 'html_name' => 'organization_address_2',  | 
                                                        |
| 155 | +							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'), | 
                                                        |
| 156 | +							'default'         => $this->organization_config->get_pretty('address_2'), | 
                                                        |
| 157 | + 'required' => false,  | 
                                                        |
| 158 | + )  | 
                                                        |
| 159 | + ),  | 
                                                        |
| 160 | + 'organization_city' => new EE_Text_Input(  | 
                                                        |
| 161 | + array(  | 
                                                        |
| 162 | + 'html_name' => 'organization_city',  | 
                                                        |
| 163 | +							'html_label_text' => esc_html__('City', 'event_espresso'), | 
                                                        |
| 164 | +							'default'         => $this->organization_config->get_pretty('city'), | 
                                                        |
| 165 | + 'required' => false,  | 
                                                        |
| 166 | + )  | 
                                                        |
| 167 | + ),  | 
                                                        |
| 168 | + 'organization_country' => new EE_Country_Select_Input(  | 
                                                        |
| 169 | + null,  | 
                                                        |
| 170 | + array(  | 
                                                        |
| 171 | + EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,  | 
                                                        |
| 172 | + 'html_name' => 'organization_country',  | 
                                                        |
| 173 | +							'html_label_text' => esc_html__('Country', 'event_espresso'), | 
                                                        |
| 174 | + 'default' => $this->organization_config->CNT_ISO,  | 
                                                        |
| 175 | + 'required' => false,  | 
                                                        |
| 176 | + 'html_help_text' => sprintf(  | 
                                                        |
| 177 | + esc_html__(  | 
                                                        |
| 178 | + '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',  | 
                                                        |
| 179 | + 'event_espresso'  | 
                                                        |
| 180 | + ),  | 
                                                        |
| 181 | + '<span class="reminder-spn">',  | 
                                                        |
| 182 | + '</span>'  | 
                                                        |
| 183 | + ),  | 
                                                        |
| 184 | + )  | 
                                                        |
| 185 | + ),  | 
                                                        |
| 186 | + 'organization_state' => new EE_State_Select_Input(  | 
                                                        |
| 187 | + null,  | 
                                                        |
| 188 | + array(  | 
                                                        |
| 189 | + 'html_name' => 'organization_state',  | 
                                                        |
| 190 | +							'html_label_text' => esc_html__('State/Province', 'event_espresso'), | 
                                                        |
| 191 | + 'default' => $this->organization_config->STA_ID,  | 
                                                        |
| 192 | + 'required' => false,  | 
                                                        |
| 193 | + 'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions  | 
                                                        |
| 194 | + ? sprintf(  | 
                                                        |
| 195 | + esc_html__(  | 
                                                        |
| 196 | + 'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',  | 
                                                        |
| 197 | + 'event_espresso'  | 
                                                        |
| 198 | + ),  | 
                                                        |
| 199 | + '<span class="reminder-spn">',  | 
                                                        |
| 200 | + '</span>',  | 
                                                        |
| 201 | + '<br />'  | 
                                                        |
| 202 | + )  | 
                                                        |
| 203 | + : '',  | 
                                                        |
| 204 | + )  | 
                                                        |
| 205 | + ),  | 
                                                        |
| 206 | + 'organization_zip' => new EE_Text_Input(  | 
                                                        |
| 207 | + array(  | 
                                                        |
| 208 | + 'html_name' => 'organization_zip',  | 
                                                        |
| 209 | +							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'), | 
                                                        |
| 210 | +							'default'         => $this->organization_config->get_pretty('zip'), | 
                                                        |
| 211 | + 'required' => false,  | 
                                                        |
| 212 | + )  | 
                                                        |
| 213 | + ),  | 
                                                        |
| 214 | + 'organization_email' => new EE_Text_Input(  | 
                                                        |
| 215 | + array(  | 
                                                        |
| 216 | + 'html_name' => 'organization_email',  | 
                                                        |
| 217 | +							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'), | 
                                                        |
| 218 | + 'html_help_text' => sprintf(  | 
                                                        |
| 219 | + esc_html__(  | 
                                                        |
| 220 | + 'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',  | 
                                                        |
| 221 | + 'event_espresso'  | 
                                                        |
| 222 | + ),  | 
                                                        |
| 223 | + '<code>[CO_FORMATTED_EMAIL]</code>',  | 
                                                        |
| 224 | + '<code>[CO_EMAIL]</code>'  | 
                                                        |
| 225 | + ),  | 
                                                        |
| 226 | +							'default'         => $this->organization_config->get_pretty('email'), | 
                                                        |
| 227 | + 'required' => false,  | 
                                                        |
| 228 | + )  | 
                                                        |
| 229 | + ),  | 
                                                        |
| 230 | + 'organization_phone' => new EE_Text_Input(  | 
                                                        |
| 231 | + array(  | 
                                                        |
| 232 | + 'html_name' => 'organization_phone',  | 
                                                        |
| 233 | +							'html_label_text' => esc_html__('Phone Number', 'event_espresso'), | 
                                                        |
| 234 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 235 | + 'The phone number for your organization.',  | 
                                                        |
| 236 | + 'event_espresso'  | 
                                                        |
| 237 | + ),  | 
                                                        |
| 238 | +							'default'         => $this->organization_config->get_pretty('phone'), | 
                                                        |
| 239 | + 'required' => false,  | 
                                                        |
| 240 | + )  | 
                                                        |
| 241 | + ),  | 
                                                        |
| 242 | + 'organization_vat' => new EE_Text_Input(  | 
                                                        |
| 243 | + array(  | 
                                                        |
| 244 | + 'html_name' => 'organization_vat',  | 
                                                        |
| 245 | +							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'), | 
                                                        |
| 246 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 247 | + 'The VAT/Tax Number may be displayed on invoices and receipts.',  | 
                                                        |
| 248 | + 'event_espresso'  | 
                                                        |
| 249 | + ),  | 
                                                        |
| 250 | +							'default'         => $this->organization_config->get_pretty('vat'), | 
                                                        |
| 251 | + 'required' => false,  | 
                                                        |
| 252 | + )  | 
                                                        |
| 253 | + ),  | 
                                                        |
| 254 | + 'company_logo_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 255 | + EEH_HTML::h2(  | 
                                                        |
| 256 | +							esc_html__('Company Logo', 'event_espresso') | 
                                                        |
| 257 | + . ' '  | 
                                                        |
| 258 | +							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')), | 
                                                        |
| 259 | + '',  | 
                                                        |
| 260 | + 'company-logo-hdr'  | 
                                                        |
| 261 | + )  | 
                                                        |
| 262 | + ),  | 
                                                        |
| 263 | + 'organization_logo_url' => new EE_Admin_File_Uploader_Input(  | 
                                                        |
| 264 | + array(  | 
                                                        |
| 265 | + 'html_name' => 'organization_logo_url',  | 
                                                        |
| 266 | +							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'), | 
                                                        |
| 267 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 268 | + 'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',  | 
                                                        |
| 269 | + 'event_espresso'  | 
                                                        |
| 270 | + ),  | 
                                                        |
| 271 | +							'default'         => $this->organization_config->get_pretty('logo_url'), | 
                                                        |
| 272 | + 'required' => false,  | 
                                                        |
| 273 | + )  | 
                                                        |
| 274 | + ),  | 
                                                        |
| 275 | + 'social_links_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 276 | + EEH_HTML::h2(  | 
                                                        |
| 277 | +							esc_html__('Social Links', 'event_espresso') | 
                                                        |
| 278 | + . ' '  | 
                                                        |
| 279 | +							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info')) | 
                                                        |
| 280 | + . EEH_HTML::br()  | 
                                                        |
| 281 | + . EEH_HTML::p(  | 
                                                        |
| 282 | + esc_html__(  | 
                                                        |
| 283 | + 'Enter any links to social accounts for your organization here',  | 
                                                        |
| 284 | + 'event_espresso'  | 
                                                        |
| 285 | + ),  | 
                                                        |
| 286 | + '',  | 
                                                        |
| 287 | + 'description'  | 
                                                        |
| 288 | + ),  | 
                                                        |
| 289 | + '',  | 
                                                        |
| 290 | + 'social-links-hdr'  | 
                                                        |
| 291 | + )  | 
                                                        |
| 292 | + ),  | 
                                                        |
| 293 | + 'organization_facebook' => new EE_Text_Input(  | 
                                                        |
| 294 | + array(  | 
                                                        |
| 295 | + 'html_name' => 'organization_facebook',  | 
                                                        |
| 296 | +							'html_label_text' => esc_html__('Facebook', 'event_espresso'), | 
                                                        |
| 297 | + 'other_html_attributes' => ' placeholder="facebook.com/profile.name"',  | 
                                                        |
| 298 | +							'default'         => $this->organization_config->get_pretty('facebook'), | 
                                                        |
| 299 | + 'required' => false,  | 
                                                        |
| 300 | + )  | 
                                                        |
| 301 | + ),  | 
                                                        |
| 302 | + 'organization_twitter' => new EE_Text_Input(  | 
                                                        |
| 303 | + array(  | 
                                                        |
| 304 | + 'html_name' => 'organization_twitter',  | 
                                                        |
| 305 | +							'html_label_text' => esc_html__('Twitter', 'event_espresso'), | 
                                                        |
| 306 | + 'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',  | 
                                                        |
| 307 | +							'default'         => $this->organization_config->get_pretty('twitter'), | 
                                                        |
| 308 | + 'required' => false,  | 
                                                        |
| 309 | + )  | 
                                                        |
| 310 | + ),  | 
                                                        |
| 311 | + 'organization_linkedin' => new EE_Text_Input(  | 
                                                        |
| 312 | + array(  | 
                                                        |
| 313 | + 'html_name' => 'organization_linkedin',  | 
                                                        |
| 314 | +							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'), | 
                                                        |
| 315 | + 'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',  | 
                                                        |
| 316 | +							'default'         => $this->organization_config->get_pretty('linkedin'), | 
                                                        |
| 317 | + 'required' => false,  | 
                                                        |
| 318 | + )  | 
                                                        |
| 319 | + ),  | 
                                                        |
| 320 | + 'organization_pinterest' => new EE_Text_Input(  | 
                                                        |
| 321 | + array(  | 
                                                        |
| 322 | + 'html_name' => 'organization_pinterest',  | 
                                                        |
| 323 | +							'html_label_text' => esc_html__('Pinterest', 'event_espresso'), | 
                                                        |
| 324 | + 'other_html_attributes' => ' placeholder="pinterest.com/profilename"',  | 
                                                        |
| 325 | +							'default'         => $this->organization_config->get_pretty('pinterest'), | 
                                                        |
| 326 | + 'required' => false,  | 
                                                        |
| 327 | + )  | 
                                                        |
| 328 | + ),  | 
                                                        |
| 329 | + 'organization_instagram' => new EE_Text_Input(  | 
                                                        |
| 330 | + array(  | 
                                                        |
| 331 | + 'html_name' => 'organization_instagram',  | 
                                                        |
| 332 | +							'html_label_text' => esc_html__('Instagram', 'event_espresso'), | 
                                                        |
| 333 | + 'other_html_attributes' => ' placeholder="instagram.com/handle"',  | 
                                                        |
| 334 | +							'default'         => $this->organization_config->get_pretty('instagram'), | 
                                                        |
| 335 | + 'required' => false,  | 
                                                        |
| 336 | + )  | 
                                                        |
| 337 | + ),  | 
                                                        |
| 338 | + ),  | 
                                                        |
| 339 | + )  | 
                                                        |
| 340 | + );  | 
                                                        |
| 341 | +		if (is_main_site()) { | 
                                                        |
| 342 | + $form->add_subsections(  | 
                                                        |
| 343 | + array(  | 
                                                        |
| 344 | + 'site_license_key_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 345 | + EEH_HTML::h2(  | 
                                                        |
| 346 | +							esc_html__('Your Event Espresso License Key', 'event_espresso') | 
                                                        |
| 347 | + . ' '  | 
                                                        |
| 348 | + . EEH_HTML::span(  | 
                                                        |
| 349 | +								EEH_Template::get_help_tab_link('site_license_key_info'), | 
                                                        |
| 350 | + 'help_tour_activation'  | 
                                                        |
| 351 | + ),  | 
                                                        |
| 352 | + '',  | 
                                                        |
| 353 | + 'site-license-key-hdr'  | 
                                                        |
| 354 | + )  | 
                                                        |
| 355 | + ),  | 
                                                        |
| 356 | + 'site_license_key' => $this->getSiteLicenseKeyField()  | 
                                                        |
| 357 | + )  | 
                                                        |
| 358 | + );  | 
                                                        |
| 359 | + $form->add_subsections(  | 
                                                        |
| 360 | + array(  | 
                                                        |
| 361 | + 'uxip_optin_hdr' => new EE_Form_Section_HTML(  | 
                                                        |
| 362 | + $this->uxipOptinText()  | 
                                                        |
| 363 | + ),  | 
                                                        |
| 364 | + 'ueip_optin' => new EE_Checkbox_Multi_Input(  | 
                                                        |
| 365 | + array(  | 
                                                        |
| 366 | +							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso') | 
                                                        |
| 367 | + ),  | 
                                                        |
| 368 | + array(  | 
                                                        |
| 369 | + 'html_name' => EE_Core_Config::OPTION_NAME_UXIP,  | 
                                                        |
| 370 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 371 | + 'UXIP Opt In?',  | 
                                                        |
| 372 | + 'event_espresso'  | 
                                                        |
| 373 | + ),  | 
                                                        |
| 374 | + 'default' => isset($this->core_config->ee_ueip_optin)  | 
                                                        |
| 375 | + ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 376 | + : false,  | 
                                                        |
| 377 | + 'required' => false,  | 
                                                        |
| 378 | + )  | 
                                                        |
| 379 | + ),  | 
                                                        |
| 380 | + ),  | 
                                                        |
| 381 | + 'organization_instagram',  | 
                                                        |
| 382 | + false  | 
                                                        |
| 383 | + );  | 
                                                        |
| 384 | + }  | 
                                                        |
| 385 | + return $form;  | 
                                                        |
| 386 | + }  | 
                                                        |
| 387 | 387 | |
| 388 | 388 | |
| 389 | - /**  | 
                                                        |
| 390 | - * takes the generated form and displays it along with ony other non-form HTML that may be required  | 
                                                        |
| 391 | - * returns a string of HTML that can be directly echoed in a template  | 
                                                        |
| 392 | - *  | 
                                                        |
| 393 | - * @return string  | 
                                                        |
| 394 | - * @throws EE_Error  | 
                                                        |
| 395 | - * @throws InvalidArgumentException  | 
                                                        |
| 396 | - * @throws InvalidDataTypeException  | 
                                                        |
| 397 | - * @throws InvalidInterfaceException  | 
                                                        |
| 398 | - * @throws LogicException  | 
                                                        |
| 399 | - */  | 
                                                        |
| 400 | - public function display()  | 
                                                        |
| 401 | -    { | 
                                                        |
| 402 | - $this->form()->enqueue_js();  | 
                                                        |
| 403 | - return parent::display();  | 
                                                        |
| 404 | - }  | 
                                                        |
| 389 | + /**  | 
                                                        |
| 390 | + * takes the generated form and displays it along with ony other non-form HTML that may be required  | 
                                                        |
| 391 | + * returns a string of HTML that can be directly echoed in a template  | 
                                                        |
| 392 | + *  | 
                                                        |
| 393 | + * @return string  | 
                                                        |
| 394 | + * @throws EE_Error  | 
                                                        |
| 395 | + * @throws InvalidArgumentException  | 
                                                        |
| 396 | + * @throws InvalidDataTypeException  | 
                                                        |
| 397 | + * @throws InvalidInterfaceException  | 
                                                        |
| 398 | + * @throws LogicException  | 
                                                        |
| 399 | + */  | 
                                                        |
| 400 | + public function display()  | 
                                                        |
| 401 | +	{ | 
                                                        |
| 402 | + $this->form()->enqueue_js();  | 
                                                        |
| 403 | + return parent::display();  | 
                                                        |
| 404 | + }  | 
                                                        |
| 405 | 405 | |
| 406 | 406 | |
| 407 | - /**  | 
                                                        |
| 408 | - * handles processing the form submission  | 
                                                        |
| 409 | - * returns true or false depending on whether the form was processed successfully or not  | 
                                                        |
| 410 | - *  | 
                                                        |
| 411 | - * @param array $form_data  | 
                                                        |
| 412 | - * @return bool  | 
                                                        |
| 413 | - * @throws InvalidFormSubmissionException  | 
                                                        |
| 414 | - * @throws EE_Error  | 
                                                        |
| 415 | - * @throws LogicException  | 
                                                        |
| 416 | - * @throws InvalidArgumentException  | 
                                                        |
| 417 | - * @throws InvalidDataTypeException  | 
                                                        |
| 418 | - * @throws ReflectionException  | 
                                                        |
| 419 | - */  | 
                                                        |
| 420 | - public function process($form_data = array())  | 
                                                        |
| 421 | -    { | 
                                                        |
| 422 | - // process form  | 
                                                        |
| 423 | - $valid_data = (array) parent::process($form_data);  | 
                                                        |
| 424 | -        if (empty($valid_data)) { | 
                                                        |
| 425 | - return false;  | 
                                                        |
| 426 | - }  | 
                                                        |
| 407 | + /**  | 
                                                        |
| 408 | + * handles processing the form submission  | 
                                                        |
| 409 | + * returns true or false depending on whether the form was processed successfully or not  | 
                                                        |
| 410 | + *  | 
                                                        |
| 411 | + * @param array $form_data  | 
                                                        |
| 412 | + * @return bool  | 
                                                        |
| 413 | + * @throws InvalidFormSubmissionException  | 
                                                        |
| 414 | + * @throws EE_Error  | 
                                                        |
| 415 | + * @throws LogicException  | 
                                                        |
| 416 | + * @throws InvalidArgumentException  | 
                                                        |
| 417 | + * @throws InvalidDataTypeException  | 
                                                        |
| 418 | + * @throws ReflectionException  | 
                                                        |
| 419 | + */  | 
                                                        |
| 420 | + public function process($form_data = array())  | 
                                                        |
| 421 | +	{ | 
                                                        |
| 422 | + // process form  | 
                                                        |
| 423 | + $valid_data = (array) parent::process($form_data);  | 
                                                        |
| 424 | +		if (empty($valid_data)) { | 
                                                        |
| 425 | + return false;  | 
                                                        |
| 426 | + }  | 
                                                        |
| 427 | 427 | |
| 428 | -        if (is_main_site()) { | 
                                                        |
| 429 | - $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])  | 
                                                        |
| 430 | - ? sanitize_text_field($form_data['ee_site_license_key'])  | 
                                                        |
| 431 | - : $this->network_core_config->site_license_key;  | 
                                                        |
| 432 | - }  | 
                                                        |
| 433 | - $this->organization_config->name = isset($form_data['organization_name'])  | 
                                                        |
| 434 | - ? sanitize_text_field($form_data['organization_name'])  | 
                                                        |
| 435 | - : $this->organization_config->name;  | 
                                                        |
| 436 | - $this->organization_config->address_1 = isset($form_data['organization_address_1'])  | 
                                                        |
| 437 | - ? sanitize_text_field($form_data['organization_address_1'])  | 
                                                        |
| 438 | - : $this->organization_config->address_1;  | 
                                                        |
| 439 | - $this->organization_config->address_2 = isset($form_data['organization_address_2'])  | 
                                                        |
| 440 | - ? sanitize_text_field($form_data['organization_address_2'])  | 
                                                        |
| 441 | - : $this->organization_config->address_2;  | 
                                                        |
| 442 | - $this->organization_config->city = isset($form_data['organization_city'])  | 
                                                        |
| 443 | - ? sanitize_text_field($form_data['organization_city'])  | 
                                                        |
| 444 | - : $this->organization_config->city;  | 
                                                        |
| 445 | - $this->organization_config->STA_ID = isset($form_data['organization_state'])  | 
                                                        |
| 446 | - ? absint($form_data['organization_state'])  | 
                                                        |
| 447 | - : $this->organization_config->STA_ID;  | 
                                                        |
| 448 | - $this->organization_config->CNT_ISO = isset($form_data['organization_country'])  | 
                                                        |
| 449 | - ? sanitize_text_field($form_data['organization_country'])  | 
                                                        |
| 450 | - : $this->organization_config->CNT_ISO;  | 
                                                        |
| 451 | - $this->organization_config->zip = isset($form_data['organization_zip'])  | 
                                                        |
| 452 | - ? sanitize_text_field($form_data['organization_zip'])  | 
                                                        |
| 453 | - : $this->organization_config->zip;  | 
                                                        |
| 454 | - $this->organization_config->email = isset($form_data['organization_email'])  | 
                                                        |
| 455 | - ? sanitize_email($form_data['organization_email'])  | 
                                                        |
| 456 | - : $this->organization_config->email;  | 
                                                        |
| 457 | - $this->organization_config->vat = isset($form_data['organization_vat'])  | 
                                                        |
| 458 | - ? sanitize_text_field($form_data['organization_vat'])  | 
                                                        |
| 459 | - : $this->organization_config->vat;  | 
                                                        |
| 460 | - $this->organization_config->phone = isset($form_data['organization_phone'])  | 
                                                        |
| 461 | - ? sanitize_text_field($form_data['organization_phone'])  | 
                                                        |
| 462 | - : $this->organization_config->phone;  | 
                                                        |
| 463 | - $this->organization_config->logo_url = isset($form_data['organization_logo_url'])  | 
                                                        |
| 464 | - ? esc_url_raw($form_data['organization_logo_url'])  | 
                                                        |
| 465 | - : $this->organization_config->logo_url;  | 
                                                        |
| 466 | - $this->organization_config->facebook = isset($form_data['organization_facebook'])  | 
                                                        |
| 467 | - ? esc_url_raw($form_data['organization_facebook'])  | 
                                                        |
| 468 | - : $this->organization_config->facebook;  | 
                                                        |
| 469 | - $this->organization_config->twitter = isset($form_data['organization_twitter'])  | 
                                                        |
| 470 | - ? esc_url_raw($form_data['organization_twitter'])  | 
                                                        |
| 471 | - : $this->organization_config->twitter;  | 
                                                        |
| 472 | - $this->organization_config->linkedin = isset($form_data['organization_linkedin'])  | 
                                                        |
| 473 | - ? esc_url_raw($form_data['organization_linkedin'])  | 
                                                        |
| 474 | - : $this->organization_config->linkedin;  | 
                                                        |
| 475 | - $this->organization_config->pinterest = isset($form_data['organization_pinterest'])  | 
                                                        |
| 476 | - ? esc_url_raw($form_data['organization_pinterest'])  | 
                                                        |
| 477 | - : $this->organization_config->pinterest;  | 
                                                        |
| 478 | - $this->organization_config->google = isset($form_data['organization_google'])  | 
                                                        |
| 479 | - ? esc_url_raw($form_data['organization_google'])  | 
                                                        |
| 480 | - : $this->organization_config->google;  | 
                                                        |
| 481 | - $this->organization_config->instagram = isset($form_data['organization_instagram'])  | 
                                                        |
| 482 | - ? esc_url_raw($form_data['organization_instagram'])  | 
                                                        |
| 483 | - : $this->organization_config->instagram;  | 
                                                        |
| 484 | - $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])  | 
                                                        |
| 485 | - ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 486 | - : false;  | 
                                                        |
| 487 | - $this->core_config->ee_ueip_has_notified = true;  | 
                                                        |
| 428 | +		if (is_main_site()) { | 
                                                        |
| 429 | + $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])  | 
                                                        |
| 430 | + ? sanitize_text_field($form_data['ee_site_license_key'])  | 
                                                        |
| 431 | + : $this->network_core_config->site_license_key;  | 
                                                        |
| 432 | + }  | 
                                                        |
| 433 | + $this->organization_config->name = isset($form_data['organization_name'])  | 
                                                        |
| 434 | + ? sanitize_text_field($form_data['organization_name'])  | 
                                                        |
| 435 | + : $this->organization_config->name;  | 
                                                        |
| 436 | + $this->organization_config->address_1 = isset($form_data['organization_address_1'])  | 
                                                        |
| 437 | + ? sanitize_text_field($form_data['organization_address_1'])  | 
                                                        |
| 438 | + : $this->organization_config->address_1;  | 
                                                        |
| 439 | + $this->organization_config->address_2 = isset($form_data['organization_address_2'])  | 
                                                        |
| 440 | + ? sanitize_text_field($form_data['organization_address_2'])  | 
                                                        |
| 441 | + : $this->organization_config->address_2;  | 
                                                        |
| 442 | + $this->organization_config->city = isset($form_data['organization_city'])  | 
                                                        |
| 443 | + ? sanitize_text_field($form_data['organization_city'])  | 
                                                        |
| 444 | + : $this->organization_config->city;  | 
                                                        |
| 445 | + $this->organization_config->STA_ID = isset($form_data['organization_state'])  | 
                                                        |
| 446 | + ? absint($form_data['organization_state'])  | 
                                                        |
| 447 | + : $this->organization_config->STA_ID;  | 
                                                        |
| 448 | + $this->organization_config->CNT_ISO = isset($form_data['organization_country'])  | 
                                                        |
| 449 | + ? sanitize_text_field($form_data['organization_country'])  | 
                                                        |
| 450 | + : $this->organization_config->CNT_ISO;  | 
                                                        |
| 451 | + $this->organization_config->zip = isset($form_data['organization_zip'])  | 
                                                        |
| 452 | + ? sanitize_text_field($form_data['organization_zip'])  | 
                                                        |
| 453 | + : $this->organization_config->zip;  | 
                                                        |
| 454 | + $this->organization_config->email = isset($form_data['organization_email'])  | 
                                                        |
| 455 | + ? sanitize_email($form_data['organization_email'])  | 
                                                        |
| 456 | + : $this->organization_config->email;  | 
                                                        |
| 457 | + $this->organization_config->vat = isset($form_data['organization_vat'])  | 
                                                        |
| 458 | + ? sanitize_text_field($form_data['organization_vat'])  | 
                                                        |
| 459 | + : $this->organization_config->vat;  | 
                                                        |
| 460 | + $this->organization_config->phone = isset($form_data['organization_phone'])  | 
                                                        |
| 461 | + ? sanitize_text_field($form_data['organization_phone'])  | 
                                                        |
| 462 | + : $this->organization_config->phone;  | 
                                                        |
| 463 | + $this->organization_config->logo_url = isset($form_data['organization_logo_url'])  | 
                                                        |
| 464 | + ? esc_url_raw($form_data['organization_logo_url'])  | 
                                                        |
| 465 | + : $this->organization_config->logo_url;  | 
                                                        |
| 466 | + $this->organization_config->facebook = isset($form_data['organization_facebook'])  | 
                                                        |
| 467 | + ? esc_url_raw($form_data['organization_facebook'])  | 
                                                        |
| 468 | + : $this->organization_config->facebook;  | 
                                                        |
| 469 | + $this->organization_config->twitter = isset($form_data['organization_twitter'])  | 
                                                        |
| 470 | + ? esc_url_raw($form_data['organization_twitter'])  | 
                                                        |
| 471 | + : $this->organization_config->twitter;  | 
                                                        |
| 472 | + $this->organization_config->linkedin = isset($form_data['organization_linkedin'])  | 
                                                        |
| 473 | + ? esc_url_raw($form_data['organization_linkedin'])  | 
                                                        |
| 474 | + : $this->organization_config->linkedin;  | 
                                                        |
| 475 | + $this->organization_config->pinterest = isset($form_data['organization_pinterest'])  | 
                                                        |
| 476 | + ? esc_url_raw($form_data['organization_pinterest'])  | 
                                                        |
| 477 | + : $this->organization_config->pinterest;  | 
                                                        |
| 478 | + $this->organization_config->google = isset($form_data['organization_google'])  | 
                                                        |
| 479 | + ? esc_url_raw($form_data['organization_google'])  | 
                                                        |
| 480 | + : $this->organization_config->google;  | 
                                                        |
| 481 | + $this->organization_config->instagram = isset($form_data['organization_instagram'])  | 
                                                        |
| 482 | + ? esc_url_raw($form_data['organization_instagram'])  | 
                                                        |
| 483 | + : $this->organization_config->instagram;  | 
                                                        |
| 484 | + $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])  | 
                                                        |
| 485 | + ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)  | 
                                                        |
| 486 | + : false;  | 
                                                        |
| 487 | + $this->core_config->ee_ueip_has_notified = true;  | 
                                                        |
| 488 | 488 | |
| 489 | - $this->registry->CFG->currency = new EE_Currency_Config(  | 
                                                        |
| 490 | - $this->organization_config->CNT_ISO  | 
                                                        |
| 491 | - );  | 
                                                        |
| 492 | - /** @var EE_Country $country */  | 
                                                        |
| 493 | - $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);  | 
                                                        |
| 494 | -        if ($country instanceof EE_Country) { | 
                                                        |
| 495 | -            $country->set('CNT_active', 1); | 
                                                        |
| 496 | - $country->save();  | 
                                                        |
| 497 | - $this->countrySubRegionDao->saveCountrySubRegions($country);  | 
                                                        |
| 498 | - }  | 
                                                        |
| 499 | - return true;  | 
                                                        |
| 500 | - }  | 
                                                        |
| 489 | + $this->registry->CFG->currency = new EE_Currency_Config(  | 
                                                        |
| 490 | + $this->organization_config->CNT_ISO  | 
                                                        |
| 491 | + );  | 
                                                        |
| 492 | + /** @var EE_Country $country */  | 
                                                        |
| 493 | + $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);  | 
                                                        |
| 494 | +		if ($country instanceof EE_Country) { | 
                                                        |
| 495 | +			$country->set('CNT_active', 1); | 
                                                        |
| 496 | + $country->save();  | 
                                                        |
| 497 | + $this->countrySubRegionDao->saveCountrySubRegions($country);  | 
                                                        |
| 498 | + }  | 
                                                        |
| 499 | + return true;  | 
                                                        |
| 500 | + }  | 
                                                        |
| 501 | 501 | |
| 502 | 502 | |
| 503 | - /**  | 
                                                        |
| 504 | - * @return string  | 
                                                        |
| 505 | - */  | 
                                                        |
| 506 | - private function uxipOptinText()  | 
                                                        |
| 507 | -    { | 
                                                        |
| 508 | - ob_start();  | 
                                                        |
| 509 | - Stats::optinText(false);  | 
                                                        |
| 510 | - return ob_get_clean();  | 
                                                        |
| 511 | - }  | 
                                                        |
| 503 | + /**  | 
                                                        |
| 504 | + * @return string  | 
                                                        |
| 505 | + */  | 
                                                        |
| 506 | + private function uxipOptinText()  | 
                                                        |
| 507 | +	{ | 
                                                        |
| 508 | + ob_start();  | 
                                                        |
| 509 | + Stats::optinText(false);  | 
                                                        |
| 510 | + return ob_get_clean();  | 
                                                        |
| 511 | + }  | 
                                                        |
| 512 | 512 | |
| 513 | 513 | |
| 514 | - /**  | 
                                                        |
| 515 | - * Return whether the site license key has been verified or not.  | 
                                                        |
| 516 | - * @return bool  | 
                                                        |
| 517 | - */  | 
                                                        |
| 518 | - private function licenseKeyVerified()  | 
                                                        |
| 519 | -    { | 
                                                        |
| 520 | -        if (empty($this->network_core_config->site_license_key)) { | 
                                                        |
| 521 | - return false;  | 
                                                        |
| 522 | - }  | 
                                                        |
| 523 | - $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);  | 
                                                        |
| 524 | - $verify_fail = get_option($ver_option_key, false);  | 
                                                        |
| 525 | - return $verify_fail === false  | 
                                                        |
| 526 | - || (! empty($this->network_core_config->site_license_key)  | 
                                                        |
| 527 | - && $verify_fail === false  | 
                                                        |
| 528 | - );  | 
                                                        |
| 529 | - }  | 
                                                        |
| 514 | + /**  | 
                                                        |
| 515 | + * Return whether the site license key has been verified or not.  | 
                                                        |
| 516 | + * @return bool  | 
                                                        |
| 517 | + */  | 
                                                        |
| 518 | + private function licenseKeyVerified()  | 
                                                        |
| 519 | +	{ | 
                                                        |
| 520 | +		if (empty($this->network_core_config->site_license_key)) { | 
                                                        |
| 521 | + return false;  | 
                                                        |
| 522 | + }  | 
                                                        |
| 523 | + $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);  | 
                                                        |
| 524 | + $verify_fail = get_option($ver_option_key, false);  | 
                                                        |
| 525 | + return $verify_fail === false  | 
                                                        |
| 526 | + || (! empty($this->network_core_config->site_license_key)  | 
                                                        |
| 527 | + && $verify_fail === false  | 
                                                        |
| 528 | + );  | 
                                                        |
| 529 | + }  | 
                                                        |
| 530 | 530 | |
| 531 | 531 | |
| 532 | - /**  | 
                                                        |
| 533 | - * @return EE_Text_Input  | 
                                                        |
| 534 | - */  | 
                                                        |
| 535 | - private function getSiteLicenseKeyField()  | 
                                                        |
| 536 | -    { | 
                                                        |
| 537 | - $text_input = new EE_Text_Input(  | 
                                                        |
| 538 | - array(  | 
                                                        |
| 539 | - 'html_name' => 'ee_site_license_key',  | 
                                                        |
| 540 | - 'html_id' => 'site_license_key',  | 
                                                        |
| 541 | -                'html_label_text' => esc_html__('Support License Key', 'event_espresso'), | 
                                                        |
| 542 | - /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */  | 
                                                        |
| 543 | - 'html_help_text' => sprintf(  | 
                                                        |
| 544 | - esc_html__(  | 
                                                        |
| 545 | - 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',  | 
                                                        |
| 546 | - 'event_espresso'  | 
                                                        |
| 547 | - ),  | 
                                                        |
| 548 | - '<strong>',  | 
                                                        |
| 549 | - '</strong>'  | 
                                                        |
| 550 | - ),  | 
                                                        |
| 551 | - /** phpcs:enable */  | 
                                                        |
| 552 | - 'default' => isset($this->network_core_config->site_license_key)  | 
                                                        |
| 553 | - ? $this->network_core_config->site_license_key  | 
                                                        |
| 554 | - : '',  | 
                                                        |
| 555 | - 'required' => false,  | 
                                                        |
| 556 | - 'form_html_filter' => new VsprintfFilter(  | 
                                                        |
| 557 | - '%2$s %1$s',  | 
                                                        |
| 558 | - array($this->getValidationIndicator())  | 
                                                        |
| 559 | - )  | 
                                                        |
| 560 | - )  | 
                                                        |
| 561 | - );  | 
                                                        |
| 562 | - return $text_input;  | 
                                                        |
| 563 | - }  | 
                                                        |
| 532 | + /**  | 
                                                        |
| 533 | + * @return EE_Text_Input  | 
                                                        |
| 534 | + */  | 
                                                        |
| 535 | + private function getSiteLicenseKeyField()  | 
                                                        |
| 536 | +	{ | 
                                                        |
| 537 | + $text_input = new EE_Text_Input(  | 
                                                        |
| 538 | + array(  | 
                                                        |
| 539 | + 'html_name' => 'ee_site_license_key',  | 
                                                        |
| 540 | + 'html_id' => 'site_license_key',  | 
                                                        |
| 541 | +				'html_label_text' => esc_html__('Support License Key', 'event_espresso'), | 
                                                        |
| 542 | + /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */  | 
                                                        |
| 543 | + 'html_help_text' => sprintf(  | 
                                                        |
| 544 | + esc_html__(  | 
                                                        |
| 545 | + 'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',  | 
                                                        |
| 546 | + 'event_espresso'  | 
                                                        |
| 547 | + ),  | 
                                                        |
| 548 | + '<strong>',  | 
                                                        |
| 549 | + '</strong>'  | 
                                                        |
| 550 | + ),  | 
                                                        |
| 551 | + /** phpcs:enable */  | 
                                                        |
| 552 | + 'default' => isset($this->network_core_config->site_license_key)  | 
                                                        |
| 553 | + ? $this->network_core_config->site_license_key  | 
                                                        |
| 554 | + : '',  | 
                                                        |
| 555 | + 'required' => false,  | 
                                                        |
| 556 | + 'form_html_filter' => new VsprintfFilter(  | 
                                                        |
| 557 | + '%2$s %1$s',  | 
                                                        |
| 558 | + array($this->getValidationIndicator())  | 
                                                        |
| 559 | + )  | 
                                                        |
| 560 | + )  | 
                                                        |
| 561 | + );  | 
                                                        |
| 562 | + return $text_input;  | 
                                                        |
| 563 | + }  | 
                                                        |
| 564 | 564 | |
| 565 | 565 | |
| 566 | - /**  | 
                                                        |
| 567 | - * @return string  | 
                                                        |
| 568 | - */  | 
                                                        |
| 569 | - private function getValidationIndicator()  | 
                                                        |
| 570 | -    { | 
                                                        |
| 571 | - $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';  | 
                                                        |
| 572 | - return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';  | 
                                                        |
| 573 | - }  | 
                                                        |
| 566 | + /**  | 
                                                        |
| 567 | + * @return string  | 
                                                        |
| 568 | + */  | 
                                                        |
| 569 | + private function getValidationIndicator()  | 
                                                        |
| 570 | +	{ | 
                                                        |
| 571 | + $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';  | 
                                                        |
| 572 | + return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';  | 
                                                        |
| 573 | + }  | 
                                                        |
| 574 | 574 | }  | 
                                                        
@@ -38,103 +38,103 @@  | 
                                                    ||
| 38 | 38 | * @since 4.0  | 
                                                        
| 39 | 39 | */  | 
                                                        
| 40 | 40 |  if (function_exists('espresso_version')) { | 
                                                        
| 41 | -    if (! function_exists('espresso_duplicate_plugin_error')) { | 
                                                        |
| 42 | - /**  | 
                                                        |
| 43 | - * espresso_duplicate_plugin_error  | 
                                                        |
| 44 | - * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 45 | - */  | 
                                                        |
| 46 | - function espresso_duplicate_plugin_error()  | 
                                                        |
| 47 | -        { | 
                                                        |
| 48 | - ?>  | 
                                                        |
| 41 | +	if (! function_exists('espresso_duplicate_plugin_error')) { | 
                                                        |
| 42 | + /**  | 
                                                        |
| 43 | + * espresso_duplicate_plugin_error  | 
                                                        |
| 44 | + * displays if more than one version of EE is activated at the same time  | 
                                                        |
| 45 | + */  | 
                                                        |
| 46 | + function espresso_duplicate_plugin_error()  | 
                                                        |
| 47 | +		{ | 
                                                        |
| 48 | + ?>  | 
                                                        |
| 49 | 49 | <div class="error">  | 
                                                        
| 50 | 50 | <p>  | 
                                                        
| 51 | 51 | <?php  | 
                                                        
| 52 | - echo esc_html__(  | 
                                                        |
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',  | 
                                                        |
| 54 | - 'event_espresso'  | 
                                                        |
| 55 | - ); ?>  | 
                                                        |
| 52 | + echo esc_html__(  | 
                                                        |
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',  | 
                                                        |
| 54 | + 'event_espresso'  | 
                                                        |
| 55 | + ); ?>  | 
                                                        |
| 56 | 56 | </p>  | 
                                                        
| 57 | 57 | </div>  | 
                                                        
| 58 | 58 | <?php  | 
                                                        
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | - }  | 
                                                        |
| 61 | - }  | 
                                                        |
| 62 | -    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 60 | + }  | 
                                                        |
| 61 | + }  | 
                                                        |
| 62 | +	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); | 
                                                        |
| 63 | 63 |  } else { | 
                                                        
| 64 | -    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); | 
                                                        |
| 65 | -    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { | 
                                                        |
| 66 | - /**  | 
                                                        |
| 67 | - * espresso_minimum_php_version_error  | 
                                                        |
| 68 | - *  | 
                                                        |
| 69 | - * @return void  | 
                                                        |
| 70 | - */  | 
                                                        |
| 71 | - function espresso_minimum_php_version_error()  | 
                                                        |
| 72 | -        { | 
                                                        |
| 73 | - ?>  | 
                                                        |
| 64 | +	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); | 
                                                        |
| 65 | +	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { | 
                                                        |
| 66 | + /**  | 
                                                        |
| 67 | + * espresso_minimum_php_version_error  | 
                                                        |
| 68 | + *  | 
                                                        |
| 69 | + * @return void  | 
                                                        |
| 70 | + */  | 
                                                        |
| 71 | + function espresso_minimum_php_version_error()  | 
                                                        |
| 72 | +		{ | 
                                                        |
| 73 | + ?>  | 
                                                        |
| 74 | 74 | <div class="error">  | 
                                                        
| 75 | 75 | <p>  | 
                                                        
| 76 | 76 | <?php  | 
                                                        
| 77 | - printf(  | 
                                                        |
| 78 | - esc_html__(  | 
                                                        |
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',  | 
                                                        |
| 80 | - 'event_espresso'  | 
                                                        |
| 81 | - ),  | 
                                                        |
| 82 | - EE_MIN_PHP_VER_REQUIRED,  | 
                                                        |
| 83 | - PHP_VERSION,  | 
                                                        |
| 84 | - '<br/>',  | 
                                                        |
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'  | 
                                                        |
| 86 | - );  | 
                                                        |
| 87 | - ?>  | 
                                                        |
| 77 | + printf(  | 
                                                        |
| 78 | + esc_html__(  | 
                                                        |
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',  | 
                                                        |
| 80 | + 'event_espresso'  | 
                                                        |
| 81 | + ),  | 
                                                        |
| 82 | + EE_MIN_PHP_VER_REQUIRED,  | 
                                                        |
| 83 | + PHP_VERSION,  | 
                                                        |
| 84 | + '<br/>',  | 
                                                        |
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'  | 
                                                        |
| 86 | + );  | 
                                                        |
| 87 | + ?>  | 
                                                        |
| 88 | 88 | </p>  | 
                                                        
| 89 | 89 | </div>  | 
                                                        
| 90 | 90 | <?php  | 
                                                        
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 92 | - }  | 
                                                        |
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__));  | 
                                                        |
| 92 | + }  | 
                                                        |
| 93 | 93 | |
| 94 | -        add_action('admin_notices', 'espresso_minimum_php_version_error', 1); | 
                                                        |
| 95 | -    } else { | 
                                                        |
| 96 | -        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 97 | - /**  | 
                                                        |
| 98 | - * espresso_version  | 
                                                        |
| 99 | - * Returns the plugin version  | 
                                                        |
| 100 | - *  | 
                                                        |
| 101 | - * @return string  | 
                                                        |
| 102 | - */  | 
                                                        |
| 103 | - function espresso_version()  | 
                                                        |
| 104 | -        { | 
                                                        |
| 105 | -            return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.014'); | 
                                                        |
| 106 | - }  | 
                                                        |
| 94 | +		add_action('admin_notices', 'espresso_minimum_php_version_error', 1); | 
                                                        |
| 95 | +	} else { | 
                                                        |
| 96 | +		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); | 
                                                        |
| 97 | + /**  | 
                                                        |
| 98 | + * espresso_version  | 
                                                        |
| 99 | + * Returns the plugin version  | 
                                                        |
| 100 | + *  | 
                                                        |
| 101 | + * @return string  | 
                                                        |
| 102 | + */  | 
                                                        |
| 103 | + function espresso_version()  | 
                                                        |
| 104 | +		{ | 
                                                        |
| 105 | +			return apply_filters('FHEE__espresso__espresso_version', '4.9.80.rc.014'); | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | 107 | |
| 108 | - /**  | 
                                                        |
| 109 | - * espresso_plugin_activation  | 
                                                        |
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 111 | - */  | 
                                                        |
| 112 | - function espresso_plugin_activation()  | 
                                                        |
| 113 | -        { | 
                                                        |
| 114 | -            update_option('ee_espresso_activation', true); | 
                                                        |
| 115 | - }  | 
                                                        |
| 108 | + /**  | 
                                                        |
| 109 | + * espresso_plugin_activation  | 
                                                        |
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page  | 
                                                        |
| 111 | + */  | 
                                                        |
| 112 | + function espresso_plugin_activation()  | 
                                                        |
| 113 | +		{ | 
                                                        |
| 114 | +			update_option('ee_espresso_activation', true); | 
                                                        |
| 115 | + }  | 
                                                        |
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');  | 
                                                        |
| 118 | 118 | |
| 119 | - require_once __DIR__ . '/core/bootstrap_espresso.php';  | 
                                                        |
| 120 | - bootstrap_espresso();  | 
                                                        |
| 121 | - }  | 
                                                        |
| 119 | + require_once __DIR__ . '/core/bootstrap_espresso.php';  | 
                                                        |
| 120 | + bootstrap_espresso();  | 
                                                        |
| 121 | + }  | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | 123 |  if (! function_exists('espresso_deactivate_plugin')) { | 
                                                        
| 124 | - /**  | 
                                                        |
| 125 | - * deactivate_plugin  | 
                                                        |
| 126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 127 | - *  | 
                                                        |
| 128 | - * @access public  | 
                                                        |
| 129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 130 | - * @return void  | 
                                                        |
| 131 | - */  | 
                                                        |
| 132 | - function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 133 | -    { | 
                                                        |
| 134 | -        if (! function_exists('deactivate_plugins')) { | 
                                                        |
| 135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 136 | - }  | 
                                                        |
| 137 | - unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 138 | - deactivate_plugins($plugin_basename);  | 
                                                        |
| 139 | - }  | 
                                                        |
| 124 | + /**  | 
                                                        |
| 125 | + * deactivate_plugin  | 
                                                        |
| 126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ ));  | 
                                                        |
| 127 | + *  | 
                                                        |
| 128 | + * @access public  | 
                                                        |
| 129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file  | 
                                                        |
| 130 | + * @return void  | 
                                                        |
| 131 | + */  | 
                                                        |
| 132 | + function espresso_deactivate_plugin($plugin_basename = '')  | 
                                                        |
| 133 | +	{ | 
                                                        |
| 134 | +		if (! function_exists('deactivate_plugins')) { | 
                                                        |
| 135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php';  | 
                                                        |
| 136 | + }  | 
                                                        |
| 137 | + unset($_GET['activate'], $_REQUEST['activate']);  | 
                                                        |
| 138 | + deactivate_plugins($plugin_basename);  | 
                                                        |
| 139 | + }  | 
                                                        |
| 140 | 140 | }  | 
                                                        
@@ -12,2683 +12,2683 @@  | 
                                                    ||
| 12 | 12 | class Events_Admin_Page extends EE_Admin_Page_CPT  | 
                                                        
| 13 | 13 |  { | 
                                                        
| 14 | 14 | |
| 15 | - /**  | 
                                                        |
| 16 | - * This will hold the event object for event_details screen.  | 
                                                        |
| 17 | - *  | 
                                                        |
| 18 | - * @access protected  | 
                                                        |
| 19 | - * @var EE_Event $_event  | 
                                                        |
| 20 | - */  | 
                                                        |
| 21 | - protected $_event;  | 
                                                        |
| 22 | -  | 
                                                        |
| 23 | -  | 
                                                        |
| 24 | - /**  | 
                                                        |
| 25 | - * This will hold the category object for category_details screen.  | 
                                                        |
| 26 | - *  | 
                                                        |
| 27 | - * @var stdClass $_category  | 
                                                        |
| 28 | - */  | 
                                                        |
| 29 | - protected $_category;  | 
                                                        |
| 30 | -  | 
                                                        |
| 31 | -  | 
                                                        |
| 32 | - /**  | 
                                                        |
| 33 | - * This will hold the event model instance  | 
                                                        |
| 34 | - *  | 
                                                        |
| 35 | - * @var EEM_Event $_event_model  | 
                                                        |
| 36 | - */  | 
                                                        |
| 37 | - protected $_event_model;  | 
                                                        |
| 38 | -  | 
                                                        |
| 39 | -  | 
                                                        |
| 40 | - /**  | 
                                                        |
| 41 | - * @var EE_Event  | 
                                                        |
| 42 | - */  | 
                                                        |
| 43 | - protected $_cpt_model_obj = false;  | 
                                                        |
| 44 | -  | 
                                                        |
| 45 | -  | 
                                                        |
| 46 | - /**  | 
                                                        |
| 47 | - * Initialize page props for this admin page group.  | 
                                                        |
| 48 | - */  | 
                                                        |
| 49 | - protected function _init_page_props()  | 
                                                        |
| 50 | -    { | 
                                                        |
| 51 | - $this->page_slug = EVENTS_PG_SLUG;  | 
                                                        |
| 52 | - $this->page_label = EVENTS_LABEL;  | 
                                                        |
| 53 | - $this->_admin_base_url = EVENTS_ADMIN_URL;  | 
                                                        |
| 54 | - $this->_admin_base_path = EVENTS_ADMIN;  | 
                                                        |
| 55 | - $this->_cpt_model_names = array(  | 
                                                        |
| 56 | - 'create_new' => 'EEM_Event',  | 
                                                        |
| 57 | - 'edit' => 'EEM_Event',  | 
                                                        |
| 58 | - );  | 
                                                        |
| 59 | - $this->_cpt_edit_routes = array(  | 
                                                        |
| 60 | - 'espresso_events' => 'edit',  | 
                                                        |
| 61 | - );  | 
                                                        |
| 62 | - add_action(  | 
                                                        |
| 63 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',  | 
                                                        |
| 64 | - array($this, 'verify_event_edit'),  | 
                                                        |
| 65 | - 10,  | 
                                                        |
| 66 | - 2  | 
                                                        |
| 67 | - );  | 
                                                        |
| 68 | - }  | 
                                                        |
| 69 | -  | 
                                                        |
| 70 | -  | 
                                                        |
| 71 | - /**  | 
                                                        |
| 72 | - * Sets the ajax hooks used for this admin page group.  | 
                                                        |
| 73 | - */  | 
                                                        |
| 74 | - protected function _ajax_hooks()  | 
                                                        |
| 75 | -    { | 
                                                        |
| 76 | -        add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); | 
                                                        |
| 77 | - }  | 
                                                        |
| 78 | -  | 
                                                        |
| 79 | -  | 
                                                        |
| 80 | - /**  | 
                                                        |
| 81 | - * Sets the page properties for this admin page group.  | 
                                                        |
| 82 | - */  | 
                                                        |
| 83 | - protected function _define_page_props()  | 
                                                        |
| 84 | -    { | 
                                                        |
| 85 | - $this->_admin_page_title = EVENTS_LABEL;  | 
                                                        |
| 86 | - $this->_labels = array(  | 
                                                        |
| 87 | - 'buttons' => array(  | 
                                                        |
| 88 | -                'add'             => esc_html__('Add New Event', 'event_espresso'), | 
                                                        |
| 89 | -                'edit'            => esc_html__('Edit Event', 'event_espresso'), | 
                                                        |
| 90 | -                'delete'          => esc_html__('Delete Event', 'event_espresso'), | 
                                                        |
| 91 | -                'add_category'    => esc_html__('Add New Category', 'event_espresso'), | 
                                                        |
| 92 | -                'edit_category'   => esc_html__('Edit Category', 'event_espresso'), | 
                                                        |
| 93 | -                'delete_category' => esc_html__('Delete Category', 'event_espresso'), | 
                                                        |
| 94 | - ),  | 
                                                        |
| 95 | - 'editor_title' => array(  | 
                                                        |
| 96 | -                'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), | 
                                                        |
| 97 | - ),  | 
                                                        |
| 98 | - 'publishbox' => array(  | 
                                                        |
| 99 | -                'create_new'        => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 100 | -                'edit'              => esc_html__('Update Event', 'event_espresso'), | 
                                                        |
| 101 | -                'add_category'      => esc_html__('Save New Category', 'event_espresso'), | 
                                                        |
| 102 | -                'edit_category'     => esc_html__('Update Category', 'event_espresso'), | 
                                                        |
| 103 | -                'template_settings' => esc_html__('Update Settings', 'event_espresso'), | 
                                                        |
| 104 | - ),  | 
                                                        |
| 105 | - );  | 
                                                        |
| 106 | - }  | 
                                                        |
| 107 | -  | 
                                                        |
| 108 | -  | 
                                                        |
| 109 | - /**  | 
                                                        |
| 110 | - * Sets the page routes property for this admin page group.  | 
                                                        |
| 111 | - */  | 
                                                        |
| 112 | - protected function _set_page_routes()  | 
                                                        |
| 113 | -    { | 
                                                        |
| 114 | - // load formatter helper  | 
                                                        |
| 115 | - // load field generator helper  | 
                                                        |
| 116 | - // is there a evt_id in the request?  | 
                                                        |
| 117 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])  | 
                                                        |
| 118 | - ? $this->_req_data['EVT_ID']  | 
                                                        |
| 119 | - : 0;  | 
                                                        |
| 120 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;  | 
                                                        |
| 121 | - $this->_page_routes = array(  | 
                                                        |
| 122 | - 'default' => array(  | 
                                                        |
| 123 | - 'func' => '_events_overview_list_table',  | 
                                                        |
| 124 | - 'capability' => 'ee_read_events',  | 
                                                        |
| 125 | - ),  | 
                                                        |
| 126 | - 'create_new' => array(  | 
                                                        |
| 127 | - 'func' => '_create_new_cpt_item',  | 
                                                        |
| 128 | - 'capability' => 'ee_edit_events',  | 
                                                        |
| 129 | - ),  | 
                                                        |
| 130 | - 'edit' => array(  | 
                                                        |
| 131 | - 'func' => '_edit_cpt_item',  | 
                                                        |
| 132 | - 'capability' => 'ee_edit_event',  | 
                                                        |
| 133 | - 'obj_id' => $evt_id,  | 
                                                        |
| 134 | - ),  | 
                                                        |
| 135 | - 'copy_event' => array(  | 
                                                        |
| 136 | - 'func' => '_copy_events',  | 
                                                        |
| 137 | - 'capability' => 'ee_edit_event',  | 
                                                        |
| 138 | - 'obj_id' => $evt_id,  | 
                                                        |
| 139 | - 'noheader' => true,  | 
                                                        |
| 140 | - ),  | 
                                                        |
| 141 | - 'trash_event' => array(  | 
                                                        |
| 142 | - 'func' => '_trash_or_restore_event',  | 
                                                        |
| 143 | -                'args'       => array('event_status' => 'trash'), | 
                                                        |
| 144 | - 'capability' => 'ee_delete_event',  | 
                                                        |
| 145 | - 'obj_id' => $evt_id,  | 
                                                        |
| 146 | - 'noheader' => true,  | 
                                                        |
| 147 | - ),  | 
                                                        |
| 148 | - 'trash_events' => array(  | 
                                                        |
| 149 | - 'func' => '_trash_or_restore_events',  | 
                                                        |
| 150 | -                'args'       => array('event_status' => 'trash'), | 
                                                        |
| 151 | - 'capability' => 'ee_delete_events',  | 
                                                        |
| 152 | - 'noheader' => true,  | 
                                                        |
| 153 | - ),  | 
                                                        |
| 154 | - 'restore_event' => array(  | 
                                                        |
| 155 | - 'func' => '_trash_or_restore_event',  | 
                                                        |
| 156 | -                'args'       => array('event_status' => 'draft'), | 
                                                        |
| 157 | - 'capability' => 'ee_delete_event',  | 
                                                        |
| 158 | - 'obj_id' => $evt_id,  | 
                                                        |
| 159 | - 'noheader' => true,  | 
                                                        |
| 160 | - ),  | 
                                                        |
| 161 | - 'restore_events' => array(  | 
                                                        |
| 162 | - 'func' => '_trash_or_restore_events',  | 
                                                        |
| 163 | -                'args'       => array('event_status' => 'draft'), | 
                                                        |
| 164 | - 'capability' => 'ee_delete_events',  | 
                                                        |
| 165 | - 'noheader' => true,  | 
                                                        |
| 166 | - ),  | 
                                                        |
| 167 | - 'delete_event' => array(  | 
                                                        |
| 168 | - 'func' => '_delete_event',  | 
                                                        |
| 169 | - 'capability' => 'ee_delete_event',  | 
                                                        |
| 170 | - 'obj_id' => $evt_id,  | 
                                                        |
| 171 | - 'noheader' => true,  | 
                                                        |
| 172 | - ),  | 
                                                        |
| 173 | - 'delete_events' => array(  | 
                                                        |
| 174 | - 'func' => '_delete_events',  | 
                                                        |
| 175 | - 'capability' => 'ee_delete_events',  | 
                                                        |
| 176 | - 'noheader' => true,  | 
                                                        |
| 177 | - ),  | 
                                                        |
| 178 | - 'view_report' => array(  | 
                                                        |
| 179 | - 'func' => '_view_report',  | 
                                                        |
| 180 | - 'capablity' => 'ee_edit_events',  | 
                                                        |
| 181 | - ),  | 
                                                        |
| 182 | - 'default_event_settings' => array(  | 
                                                        |
| 183 | - 'func' => '_default_event_settings',  | 
                                                        |
| 184 | - 'capability' => 'manage_options',  | 
                                                        |
| 185 | - ),  | 
                                                        |
| 186 | - 'update_default_event_settings' => array(  | 
                                                        |
| 187 | - 'func' => '_update_default_event_settings',  | 
                                                        |
| 188 | - 'capability' => 'manage_options',  | 
                                                        |
| 189 | - 'noheader' => true,  | 
                                                        |
| 190 | - ),  | 
                                                        |
| 191 | - 'template_settings' => array(  | 
                                                        |
| 192 | - 'func' => '_template_settings',  | 
                                                        |
| 193 | - 'capability' => 'manage_options',  | 
                                                        |
| 194 | - ),  | 
                                                        |
| 195 | - // event category tab related  | 
                                                        |
| 196 | - 'add_category' => array(  | 
                                                        |
| 197 | - 'func' => '_category_details',  | 
                                                        |
| 198 | - 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 199 | -                'args'       => array('add'), | 
                                                        |
| 200 | - ),  | 
                                                        |
| 201 | - 'edit_category' => array(  | 
                                                        |
| 202 | - 'func' => '_category_details',  | 
                                                        |
| 203 | - 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 204 | -                'args'       => array('edit'), | 
                                                        |
| 205 | - ),  | 
                                                        |
| 206 | - 'delete_categories' => array(  | 
                                                        |
| 207 | - 'func' => '_delete_categories',  | 
                                                        |
| 208 | - 'capability' => 'ee_delete_event_category',  | 
                                                        |
| 209 | - 'noheader' => true,  | 
                                                        |
| 210 | - ),  | 
                                                        |
| 211 | - 'delete_category' => array(  | 
                                                        |
| 212 | - 'func' => '_delete_categories',  | 
                                                        |
| 213 | - 'capability' => 'ee_delete_event_category',  | 
                                                        |
| 214 | - 'noheader' => true,  | 
                                                        |
| 215 | - ),  | 
                                                        |
| 216 | - 'insert_category' => array(  | 
                                                        |
| 217 | - 'func' => '_insert_or_update_category',  | 
                                                        |
| 218 | -                'args'       => array('new_category' => true), | 
                                                        |
| 219 | - 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 220 | - 'noheader' => true,  | 
                                                        |
| 221 | - ),  | 
                                                        |
| 222 | - 'update_category' => array(  | 
                                                        |
| 223 | - 'func' => '_insert_or_update_category',  | 
                                                        |
| 224 | -                'args'       => array('new_category' => false), | 
                                                        |
| 225 | - 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 226 | - 'noheader' => true,  | 
                                                        |
| 227 | - ),  | 
                                                        |
| 228 | - 'category_list' => array(  | 
                                                        |
| 229 | - 'func' => '_category_list_table',  | 
                                                        |
| 230 | - 'capability' => 'ee_manage_event_categories',  | 
                                                        |
| 231 | - ),  | 
                                                        |
| 232 | - );  | 
                                                        |
| 233 | - }  | 
                                                        |
| 234 | -  | 
                                                        |
| 235 | -  | 
                                                        |
| 236 | - /**  | 
                                                        |
| 237 | - * Set the _page_config property for this admin page group.  | 
                                                        |
| 238 | - */  | 
                                                        |
| 239 | - protected function _set_page_config()  | 
                                                        |
| 240 | -    { | 
                                                        |
| 241 | - $this->_page_config = array(  | 
                                                        |
| 242 | - 'default' => array(  | 
                                                        |
| 243 | - 'nav' => array(  | 
                                                        |
| 244 | -                    'label' => esc_html__('Overview', 'event_espresso'), | 
                                                        |
| 245 | - 'order' => 10,  | 
                                                        |
| 246 | - ),  | 
                                                        |
| 247 | - 'list_table' => 'Events_Admin_List_Table',  | 
                                                        |
| 248 | - 'help_tabs' => array(  | 
                                                        |
| 249 | - 'events_overview_help_tab' => array(  | 
                                                        |
| 250 | -                        'title'    => esc_html__('Events Overview', 'event_espresso'), | 
                                                        |
| 251 | - 'filename' => 'events_overview',  | 
                                                        |
| 252 | - ),  | 
                                                        |
| 253 | - 'events_overview_table_column_headings_help_tab' => array(  | 
                                                        |
| 254 | -                        'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'), | 
                                                        |
| 255 | - 'filename' => 'events_overview_table_column_headings',  | 
                                                        |
| 256 | - ),  | 
                                                        |
| 257 | - 'events_overview_filters_help_tab' => array(  | 
                                                        |
| 258 | -                        'title'    => esc_html__('Events Overview Filters', 'event_espresso'), | 
                                                        |
| 259 | - 'filename' => 'events_overview_filters',  | 
                                                        |
| 260 | - ),  | 
                                                        |
| 261 | - 'events_overview_view_help_tab' => array(  | 
                                                        |
| 262 | -                        'title'    => esc_html__('Events Overview Views', 'event_espresso'), | 
                                                        |
| 263 | - 'filename' => 'events_overview_views',  | 
                                                        |
| 264 | - ),  | 
                                                        |
| 265 | - 'events_overview_other_help_tab' => array(  | 
                                                        |
| 266 | -                        'title'    => esc_html__('Events Overview Other', 'event_espresso'), | 
                                                        |
| 267 | - 'filename' => 'events_overview_other',  | 
                                                        |
| 268 | - ),  | 
                                                        |
| 269 | - ),  | 
                                                        |
| 270 | - 'help_tour' => array(  | 
                                                        |
| 271 | - 'Event_Overview_Help_Tour',  | 
                                                        |
| 272 | - // 'New_Features_Test_Help_Tour' for testing multiple help tour  | 
                                                        |
| 273 | - ),  | 
                                                        |
| 274 | - 'qtips' => array(  | 
                                                        |
| 275 | - 'EE_Event_List_Table_Tips',  | 
                                                        |
| 276 | - ),  | 
                                                        |
| 277 | - 'require_nonce' => false,  | 
                                                        |
| 278 | - ),  | 
                                                        |
| 279 | - 'create_new' => array(  | 
                                                        |
| 280 | - 'nav' => array(  | 
                                                        |
| 281 | -                    'label'      => esc_html__('Add Event', 'event_espresso'), | 
                                                        |
| 282 | - 'order' => 5,  | 
                                                        |
| 283 | - 'persistent' => false,  | 
                                                        |
| 284 | - ),  | 
                                                        |
| 285 | -                'metaboxes'     => array('_register_event_editor_meta_boxes'), | 
                                                        |
| 286 | - 'help_tabs' => array(  | 
                                                        |
| 287 | - 'event_editor_help_tab' => array(  | 
                                                        |
| 288 | -                        'title'    => esc_html__('Event Editor', 'event_espresso'), | 
                                                        |
| 289 | - 'filename' => 'event_editor',  | 
                                                        |
| 290 | - ),  | 
                                                        |
| 291 | - 'event_editor_title_richtexteditor_help_tab' => array(  | 
                                                        |
| 292 | -                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), | 
                                                        |
| 293 | - 'filename' => 'event_editor_title_richtexteditor',  | 
                                                        |
| 294 | - ),  | 
                                                        |
| 295 | - 'event_editor_venue_details_help_tab' => array(  | 
                                                        |
| 296 | -                        'title'    => esc_html__('Event Venue Details', 'event_espresso'), | 
                                                        |
| 297 | - 'filename' => 'event_editor_venue_details',  | 
                                                        |
| 298 | - ),  | 
                                                        |
| 299 | - 'event_editor_event_datetimes_help_tab' => array(  | 
                                                        |
| 300 | -                        'title'    => esc_html__('Event Datetimes', 'event_espresso'), | 
                                                        |
| 301 | - 'filename' => 'event_editor_event_datetimes',  | 
                                                        |
| 302 | - ),  | 
                                                        |
| 303 | - 'event_editor_event_tickets_help_tab' => array(  | 
                                                        |
| 304 | -                        'title'    => esc_html__('Event Tickets', 'event_espresso'), | 
                                                        |
| 305 | - 'filename' => 'event_editor_event_tickets',  | 
                                                        |
| 306 | - ),  | 
                                                        |
| 307 | - 'event_editor_event_registration_options_help_tab' => array(  | 
                                                        |
| 308 | -                        'title'    => esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 309 | - 'filename' => 'event_editor_event_registration_options',  | 
                                                        |
| 310 | - ),  | 
                                                        |
| 311 | - 'event_editor_tags_categories_help_tab' => array(  | 
                                                        |
| 312 | -                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'), | 
                                                        |
| 313 | - 'filename' => 'event_editor_tags_categories',  | 
                                                        |
| 314 | - ),  | 
                                                        |
| 315 | - 'event_editor_questions_registrants_help_tab' => array(  | 
                                                        |
| 316 | -                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'), | 
                                                        |
| 317 | - 'filename' => 'event_editor_questions_registrants',  | 
                                                        |
| 318 | - ),  | 
                                                        |
| 319 | - 'event_editor_save_new_event_help_tab' => array(  | 
                                                        |
| 320 | -                        'title'    => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 321 | - 'filename' => 'event_editor_save_new_event',  | 
                                                        |
| 322 | - ),  | 
                                                        |
| 323 | - 'event_editor_other_help_tab' => array(  | 
                                                        |
| 324 | -                        'title'    => esc_html__('Event Other', 'event_espresso'), | 
                                                        |
| 325 | - 'filename' => 'event_editor_other',  | 
                                                        |
| 326 | - ),  | 
                                                        |
| 327 | - ),  | 
                                                        |
| 328 | - 'help_tour' => array(  | 
                                                        |
| 329 | - 'Event_Editor_Help_Tour',  | 
                                                        |
| 330 | - ),  | 
                                                        |
| 331 | -                'qtips'         => array('EE_Event_Editor_Decaf_Tips'), | 
                                                        |
| 332 | - 'require_nonce' => false,  | 
                                                        |
| 333 | - ),  | 
                                                        |
| 334 | - 'edit' => array(  | 
                                                        |
| 335 | - 'nav' => array(  | 
                                                        |
| 336 | -                    'label'      => esc_html__('Edit Event', 'event_espresso'), | 
                                                        |
| 337 | - 'order' => 5,  | 
                                                        |
| 338 | - 'persistent' => false,  | 
                                                        |
| 339 | - 'url' => isset($this->_req_data['post'])  | 
                                                        |
| 340 | - ? EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 341 | -                            array('post' => $this->_req_data['post'], 'action' => 'edit'), | 
                                                        |
| 342 | - $this->_current_page_view_url  | 
                                                        |
| 343 | - )  | 
                                                        |
| 344 | - : $this->_admin_base_url,  | 
                                                        |
| 345 | - ),  | 
                                                        |
| 346 | -                'metaboxes'     => array('_register_event_editor_meta_boxes'), | 
                                                        |
| 347 | - 'help_tabs' => array(  | 
                                                        |
| 348 | - 'event_editor_help_tab' => array(  | 
                                                        |
| 349 | -                        'title'    => esc_html__('Event Editor', 'event_espresso'), | 
                                                        |
| 350 | - 'filename' => 'event_editor',  | 
                                                        |
| 351 | - ),  | 
                                                        |
| 352 | - 'event_editor_title_richtexteditor_help_tab' => array(  | 
                                                        |
| 353 | -                        'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), | 
                                                        |
| 354 | - 'filename' => 'event_editor_title_richtexteditor',  | 
                                                        |
| 355 | - ),  | 
                                                        |
| 356 | - 'event_editor_venue_details_help_tab' => array(  | 
                                                        |
| 357 | -                        'title'    => esc_html__('Event Venue Details', 'event_espresso'), | 
                                                        |
| 358 | - 'filename' => 'event_editor_venue_details',  | 
                                                        |
| 359 | - ),  | 
                                                        |
| 360 | - 'event_editor_event_datetimes_help_tab' => array(  | 
                                                        |
| 361 | -                        'title'    => esc_html__('Event Datetimes', 'event_espresso'), | 
                                                        |
| 362 | - 'filename' => 'event_editor_event_datetimes',  | 
                                                        |
| 363 | - ),  | 
                                                        |
| 364 | - 'event_editor_event_tickets_help_tab' => array(  | 
                                                        |
| 365 | -                        'title'    => esc_html__('Event Tickets', 'event_espresso'), | 
                                                        |
| 366 | - 'filename' => 'event_editor_event_tickets',  | 
                                                        |
| 367 | - ),  | 
                                                        |
| 368 | - 'event_editor_event_registration_options_help_tab' => array(  | 
                                                        |
| 369 | -                        'title'    => esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 370 | - 'filename' => 'event_editor_event_registration_options',  | 
                                                        |
| 371 | - ),  | 
                                                        |
| 372 | - 'event_editor_tags_categories_help_tab' => array(  | 
                                                        |
| 373 | -                        'title'    => esc_html__('Event Tags & Categories', 'event_espresso'), | 
                                                        |
| 374 | - 'filename' => 'event_editor_tags_categories',  | 
                                                        |
| 375 | - ),  | 
                                                        |
| 376 | - 'event_editor_questions_registrants_help_tab' => array(  | 
                                                        |
| 377 | -                        'title'    => esc_html__('Questions for Registrants', 'event_espresso'), | 
                                                        |
| 378 | - 'filename' => 'event_editor_questions_registrants',  | 
                                                        |
| 379 | - ),  | 
                                                        |
| 380 | - 'event_editor_save_new_event_help_tab' => array(  | 
                                                        |
| 381 | -                        'title'    => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 382 | - 'filename' => 'event_editor_save_new_event',  | 
                                                        |
| 383 | - ),  | 
                                                        |
| 384 | - 'event_editor_other_help_tab' => array(  | 
                                                        |
| 385 | -                        'title'    => esc_html__('Event Other', 'event_espresso'), | 
                                                        |
| 386 | - 'filename' => 'event_editor_other',  | 
                                                        |
| 387 | - ),  | 
                                                        |
| 388 | - ),  | 
                                                        |
| 389 | -                'qtips'         => array('EE_Event_Editor_Decaf_Tips'), | 
                                                        |
| 390 | - 'require_nonce' => false,  | 
                                                        |
| 391 | - ),  | 
                                                        |
| 392 | - 'default_event_settings' => array(  | 
                                                        |
| 393 | - 'nav' => array(  | 
                                                        |
| 394 | -                    'label' => esc_html__('Default Settings', 'event_espresso'), | 
                                                        |
| 395 | - 'order' => 40,  | 
                                                        |
| 396 | - ),  | 
                                                        |
| 397 | -                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), | 
                                                        |
| 398 | - 'labels' => array(  | 
                                                        |
| 399 | -                    'publishbox' => esc_html__('Update Settings', 'event_espresso'), | 
                                                        |
| 400 | - ),  | 
                                                        |
| 401 | - 'help_tabs' => array(  | 
                                                        |
| 402 | - 'default_settings_help_tab' => array(  | 
                                                        |
| 403 | -                        'title'    => esc_html__('Default Event Settings', 'event_espresso'), | 
                                                        |
| 404 | - 'filename' => 'events_default_settings',  | 
                                                        |
| 405 | - ),  | 
                                                        |
| 406 | - 'default_settings_status_help_tab' => array(  | 
                                                        |
| 407 | -                        'title'    => esc_html__('Default Registration Status', 'event_espresso'), | 
                                                        |
| 408 | - 'filename' => 'events_default_settings_status',  | 
                                                        |
| 409 | - ),  | 
                                                        |
| 410 | - 'default_maximum_tickets_help_tab' => array(  | 
                                                        |
| 411 | -                        'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), | 
                                                        |
| 412 | - 'filename' => 'events_default_settings_max_tickets',  | 
                                                        |
| 413 | - ),  | 
                                                        |
| 414 | - ),  | 
                                                        |
| 415 | -                'help_tour'     => array('Event_Default_Settings_Help_Tour'), | 
                                                        |
| 416 | - 'require_nonce' => false,  | 
                                                        |
| 417 | - ),  | 
                                                        |
| 418 | - // template settings  | 
                                                        |
| 419 | - 'template_settings' => array(  | 
                                                        |
| 420 | - 'nav' => array(  | 
                                                        |
| 421 | -                    'label' => esc_html__('Templates', 'event_espresso'), | 
                                                        |
| 422 | - 'order' => 30,  | 
                                                        |
| 423 | - ),  | 
                                                        |
| 424 | - 'metaboxes' => $this->_default_espresso_metaboxes,  | 
                                                        |
| 425 | - 'help_tabs' => array(  | 
                                                        |
| 426 | - 'general_settings_templates_help_tab' => array(  | 
                                                        |
| 427 | -                        'title'    => esc_html__('Templates', 'event_espresso'), | 
                                                        |
| 428 | - 'filename' => 'general_settings_templates',  | 
                                                        |
| 429 | - ),  | 
                                                        |
| 430 | - ),  | 
                                                        |
| 431 | -                'help_tour'     => array('Templates_Help_Tour'), | 
                                                        |
| 432 | - 'require_nonce' => false,  | 
                                                        |
| 433 | - ),  | 
                                                        |
| 434 | - // event category stuff  | 
                                                        |
| 435 | - 'add_category' => array(  | 
                                                        |
| 436 | - 'nav' => array(  | 
                                                        |
| 437 | -                    'label'      => esc_html__('Add Category', 'event_espresso'), | 
                                                        |
| 438 | - 'order' => 15,  | 
                                                        |
| 439 | - 'persistent' => false,  | 
                                                        |
| 440 | - ),  | 
                                                        |
| 441 | - 'help_tabs' => array(  | 
                                                        |
| 442 | - 'add_category_help_tab' => array(  | 
                                                        |
| 443 | -                        'title'    => esc_html__('Add New Event Category', 'event_espresso'), | 
                                                        |
| 444 | - 'filename' => 'events_add_category',  | 
                                                        |
| 445 | - ),  | 
                                                        |
| 446 | - ),  | 
                                                        |
| 447 | -                'help_tour'     => array('Event_Add_Category_Help_Tour'), | 
                                                        |
| 448 | -                'metaboxes'     => array('_publish_post_box'), | 
                                                        |
| 449 | - 'require_nonce' => false,  | 
                                                        |
| 450 | - ),  | 
                                                        |
| 451 | - 'edit_category' => array(  | 
                                                        |
| 452 | - 'nav' => array(  | 
                                                        |
| 453 | -                    'label'      => esc_html__('Edit Category', 'event_espresso'), | 
                                                        |
| 454 | - 'order' => 15,  | 
                                                        |
| 455 | - 'persistent' => false,  | 
                                                        |
| 456 | - 'url' => isset($this->_req_data['EVT_CAT_ID'])  | 
                                                        |
| 457 | - ? add_query_arg(  | 
                                                        |
| 458 | -                            array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), | 
                                                        |
| 459 | - $this->_current_page_view_url  | 
                                                        |
| 460 | - )  | 
                                                        |
| 461 | - : $this->_admin_base_url,  | 
                                                        |
| 462 | - ),  | 
                                                        |
| 463 | - 'help_tabs' => array(  | 
                                                        |
| 464 | - 'edit_category_help_tab' => array(  | 
                                                        |
| 465 | -                        'title'    => esc_html__('Edit Event Category', 'event_espresso'), | 
                                                        |
| 466 | - 'filename' => 'events_edit_category',  | 
                                                        |
| 467 | - ),  | 
                                                        |
| 468 | - ),  | 
                                                        |
| 469 | -                /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ | 
                                                        |
| 470 | -                'metaboxes'     => array('_publish_post_box'), | 
                                                        |
| 471 | - 'require_nonce' => false,  | 
                                                        |
| 472 | - ),  | 
                                                        |
| 473 | - 'category_list' => array(  | 
                                                        |
| 474 | - 'nav' => array(  | 
                                                        |
| 475 | -                    'label' => esc_html__('Categories', 'event_espresso'), | 
                                                        |
| 476 | - 'order' => 20,  | 
                                                        |
| 477 | - ),  | 
                                                        |
| 478 | - 'list_table' => 'Event_Categories_Admin_List_Table',  | 
                                                        |
| 479 | - 'help_tabs' => array(  | 
                                                        |
| 480 | - 'events_categories_help_tab' => array(  | 
                                                        |
| 481 | -                        'title'    => esc_html__('Event Categories', 'event_espresso'), | 
                                                        |
| 482 | - 'filename' => 'events_categories',  | 
                                                        |
| 483 | - ),  | 
                                                        |
| 484 | - 'events_categories_table_column_headings_help_tab' => array(  | 
                                                        |
| 485 | -                        'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'), | 
                                                        |
| 486 | - 'filename' => 'events_categories_table_column_headings',  | 
                                                        |
| 487 | - ),  | 
                                                        |
| 488 | - 'events_categories_view_help_tab' => array(  | 
                                                        |
| 489 | -                        'title'    => esc_html__('Event Categories Views', 'event_espresso'), | 
                                                        |
| 490 | - 'filename' => 'events_categories_views',  | 
                                                        |
| 491 | - ),  | 
                                                        |
| 492 | - 'events_categories_other_help_tab' => array(  | 
                                                        |
| 493 | -                        'title'    => esc_html__('Event Categories Other', 'event_espresso'), | 
                                                        |
| 494 | - 'filename' => 'events_categories_other',  | 
                                                        |
| 495 | - ),  | 
                                                        |
| 496 | - ),  | 
                                                        |
| 497 | - 'help_tour' => array(  | 
                                                        |
| 498 | - 'Event_Categories_Help_Tour',  | 
                                                        |
| 499 | - ),  | 
                                                        |
| 500 | - 'metaboxes' => $this->_default_espresso_metaboxes,  | 
                                                        |
| 501 | - 'require_nonce' => false,  | 
                                                        |
| 502 | - ),  | 
                                                        |
| 503 | - );  | 
                                                        |
| 504 | - }  | 
                                                        |
| 505 | -  | 
                                                        |
| 506 | -  | 
                                                        |
| 507 | - /**  | 
                                                        |
| 508 | - * Used to register any global screen options if necessary for every route in this admin page group.  | 
                                                        |
| 509 | - */  | 
                                                        |
| 510 | - protected function _add_screen_options()  | 
                                                        |
| 511 | -    { | 
                                                        |
| 512 | - }  | 
                                                        |
| 513 | -  | 
                                                        |
| 514 | -  | 
                                                        |
| 515 | - /**  | 
                                                        |
| 516 | - * Implementing the screen options for the 'default' route.  | 
                                                        |
| 517 | - */  | 
                                                        |
| 518 | - protected function _add_screen_options_default()  | 
                                                        |
| 519 | -    { | 
                                                        |
| 520 | - $this->_per_page_screen_option();  | 
                                                        |
| 521 | - }  | 
                                                        |
| 522 | -  | 
                                                        |
| 523 | -  | 
                                                        |
| 524 | - /**  | 
                                                        |
| 525 | - * Implementing screen options for the category list route.  | 
                                                        |
| 526 | - */  | 
                                                        |
| 527 | - protected function _add_screen_options_category_list()  | 
                                                        |
| 528 | -    { | 
                                                        |
| 529 | - $page_title = $this->_admin_page_title;  | 
                                                        |
| 530 | -        $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 531 | - $this->_per_page_screen_option();  | 
                                                        |
| 532 | - $this->_admin_page_title = $page_title;  | 
                                                        |
| 533 | - }  | 
                                                        |
| 534 | -  | 
                                                        |
| 535 | -  | 
                                                        |
| 536 | - /**  | 
                                                        |
| 537 | - * Used to register any global feature pointers for the admin page group.  | 
                                                        |
| 538 | - */  | 
                                                        |
| 539 | - protected function _add_feature_pointers()  | 
                                                        |
| 540 | -    { | 
                                                        |
| 541 | - }  | 
                                                        |
| 542 | -  | 
                                                        |
| 543 | -  | 
                                                        |
| 544 | - /**  | 
                                                        |
| 545 | - * Registers and enqueues any global scripts and styles for the entire admin page group.  | 
                                                        |
| 546 | - */  | 
                                                        |
| 547 | - public function load_scripts_styles()  | 
                                                        |
| 548 | -    { | 
                                                        |
| 549 | - wp_register_style(  | 
                                                        |
| 550 | - 'events-admin-css',  | 
                                                        |
| 551 | - EVENTS_ASSETS_URL . 'events-admin-page.css',  | 
                                                        |
| 552 | - array(),  | 
                                                        |
| 553 | - EVENT_ESPRESSO_VERSION  | 
                                                        |
| 554 | - );  | 
                                                        |
| 555 | -        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); | 
                                                        |
| 556 | -        wp_enqueue_style('events-admin-css'); | 
                                                        |
| 557 | -        wp_enqueue_style('ee-cat-admin'); | 
                                                        |
| 558 | - // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details  | 
                                                        |
| 559 | - // registers for all views  | 
                                                        |
| 560 | - // scripts  | 
                                                        |
| 561 | - wp_register_script(  | 
                                                        |
| 562 | - 'event_editor_js',  | 
                                                        |
| 563 | - EVENTS_ASSETS_URL . 'event_editor.js',  | 
                                                        |
| 564 | -            array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), | 
                                                        |
| 565 | - EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 566 | - true  | 
                                                        |
| 567 | - );  | 
                                                        |
| 568 | - add_action(  | 
                                                        |
| 569 | - 'admin_footer',  | 
                                                        |
| 570 | -            function () { | 
                                                        |
| 571 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;  | 
                                                        |
| 572 | -                if ($eventId) { | 
                                                        |
| 573 | - echo '  | 
                                                        |
| 15 | + /**  | 
                                                        |
| 16 | + * This will hold the event object for event_details screen.  | 
                                                        |
| 17 | + *  | 
                                                        |
| 18 | + * @access protected  | 
                                                        |
| 19 | + * @var EE_Event $_event  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | + protected $_event;  | 
                                                        |
| 22 | +  | 
                                                        |
| 23 | +  | 
                                                        |
| 24 | + /**  | 
                                                        |
| 25 | + * This will hold the category object for category_details screen.  | 
                                                        |
| 26 | + *  | 
                                                        |
| 27 | + * @var stdClass $_category  | 
                                                        |
| 28 | + */  | 
                                                        |
| 29 | + protected $_category;  | 
                                                        |
| 30 | +  | 
                                                        |
| 31 | +  | 
                                                        |
| 32 | + /**  | 
                                                        |
| 33 | + * This will hold the event model instance  | 
                                                        |
| 34 | + *  | 
                                                        |
| 35 | + * @var EEM_Event $_event_model  | 
                                                        |
| 36 | + */  | 
                                                        |
| 37 | + protected $_event_model;  | 
                                                        |
| 38 | +  | 
                                                        |
| 39 | +  | 
                                                        |
| 40 | + /**  | 
                                                        |
| 41 | + * @var EE_Event  | 
                                                        |
| 42 | + */  | 
                                                        |
| 43 | + protected $_cpt_model_obj = false;  | 
                                                        |
| 44 | +  | 
                                                        |
| 45 | +  | 
                                                        |
| 46 | + /**  | 
                                                        |
| 47 | + * Initialize page props for this admin page group.  | 
                                                        |
| 48 | + */  | 
                                                        |
| 49 | + protected function _init_page_props()  | 
                                                        |
| 50 | +	{ | 
                                                        |
| 51 | + $this->page_slug = EVENTS_PG_SLUG;  | 
                                                        |
| 52 | + $this->page_label = EVENTS_LABEL;  | 
                                                        |
| 53 | + $this->_admin_base_url = EVENTS_ADMIN_URL;  | 
                                                        |
| 54 | + $this->_admin_base_path = EVENTS_ADMIN;  | 
                                                        |
| 55 | + $this->_cpt_model_names = array(  | 
                                                        |
| 56 | + 'create_new' => 'EEM_Event',  | 
                                                        |
| 57 | + 'edit' => 'EEM_Event',  | 
                                                        |
| 58 | + );  | 
                                                        |
| 59 | + $this->_cpt_edit_routes = array(  | 
                                                        |
| 60 | + 'espresso_events' => 'edit',  | 
                                                        |
| 61 | + );  | 
                                                        |
| 62 | + add_action(  | 
                                                        |
| 63 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object',  | 
                                                        |
| 64 | + array($this, 'verify_event_edit'),  | 
                                                        |
| 65 | + 10,  | 
                                                        |
| 66 | + 2  | 
                                                        |
| 67 | + );  | 
                                                        |
| 68 | + }  | 
                                                        |
| 69 | +  | 
                                                        |
| 70 | +  | 
                                                        |
| 71 | + /**  | 
                                                        |
| 72 | + * Sets the ajax hooks used for this admin page group.  | 
                                                        |
| 73 | + */  | 
                                                        |
| 74 | + protected function _ajax_hooks()  | 
                                                        |
| 75 | +	{ | 
                                                        |
| 76 | +		add_action('wp_ajax_ee_save_timezone_setting', array($this, 'save_timezonestring_setting')); | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | +  | 
                                                        |
| 79 | +  | 
                                                        |
| 80 | + /**  | 
                                                        |
| 81 | + * Sets the page properties for this admin page group.  | 
                                                        |
| 82 | + */  | 
                                                        |
| 83 | + protected function _define_page_props()  | 
                                                        |
| 84 | +	{ | 
                                                        |
| 85 | + $this->_admin_page_title = EVENTS_LABEL;  | 
                                                        |
| 86 | + $this->_labels = array(  | 
                                                        |
| 87 | + 'buttons' => array(  | 
                                                        |
| 88 | +				'add'             => esc_html__('Add New Event', 'event_espresso'), | 
                                                        |
| 89 | +				'edit'            => esc_html__('Edit Event', 'event_espresso'), | 
                                                        |
| 90 | +				'delete'          => esc_html__('Delete Event', 'event_espresso'), | 
                                                        |
| 91 | +				'add_category'    => esc_html__('Add New Category', 'event_espresso'), | 
                                                        |
| 92 | +				'edit_category'   => esc_html__('Edit Category', 'event_espresso'), | 
                                                        |
| 93 | +				'delete_category' => esc_html__('Delete Category', 'event_espresso'), | 
                                                        |
| 94 | + ),  | 
                                                        |
| 95 | + 'editor_title' => array(  | 
                                                        |
| 96 | +				'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), | 
                                                        |
| 97 | + ),  | 
                                                        |
| 98 | + 'publishbox' => array(  | 
                                                        |
| 99 | +				'create_new'        => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 100 | +				'edit'              => esc_html__('Update Event', 'event_espresso'), | 
                                                        |
| 101 | +				'add_category'      => esc_html__('Save New Category', 'event_espresso'), | 
                                                        |
| 102 | +				'edit_category'     => esc_html__('Update Category', 'event_espresso'), | 
                                                        |
| 103 | +				'template_settings' => esc_html__('Update Settings', 'event_espresso'), | 
                                                        |
| 104 | + ),  | 
                                                        |
| 105 | + );  | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | +  | 
                                                        |
| 108 | +  | 
                                                        |
| 109 | + /**  | 
                                                        |
| 110 | + * Sets the page routes property for this admin page group.  | 
                                                        |
| 111 | + */  | 
                                                        |
| 112 | + protected function _set_page_routes()  | 
                                                        |
| 113 | +	{ | 
                                                        |
| 114 | + // load formatter helper  | 
                                                        |
| 115 | + // load field generator helper  | 
                                                        |
| 116 | + // is there a evt_id in the request?  | 
                                                        |
| 117 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])  | 
                                                        |
| 118 | + ? $this->_req_data['EVT_ID']  | 
                                                        |
| 119 | + : 0;  | 
                                                        |
| 120 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;  | 
                                                        |
| 121 | + $this->_page_routes = array(  | 
                                                        |
| 122 | + 'default' => array(  | 
                                                        |
| 123 | + 'func' => '_events_overview_list_table',  | 
                                                        |
| 124 | + 'capability' => 'ee_read_events',  | 
                                                        |
| 125 | + ),  | 
                                                        |
| 126 | + 'create_new' => array(  | 
                                                        |
| 127 | + 'func' => '_create_new_cpt_item',  | 
                                                        |
| 128 | + 'capability' => 'ee_edit_events',  | 
                                                        |
| 129 | + ),  | 
                                                        |
| 130 | + 'edit' => array(  | 
                                                        |
| 131 | + 'func' => '_edit_cpt_item',  | 
                                                        |
| 132 | + 'capability' => 'ee_edit_event',  | 
                                                        |
| 133 | + 'obj_id' => $evt_id,  | 
                                                        |
| 134 | + ),  | 
                                                        |
| 135 | + 'copy_event' => array(  | 
                                                        |
| 136 | + 'func' => '_copy_events',  | 
                                                        |
| 137 | + 'capability' => 'ee_edit_event',  | 
                                                        |
| 138 | + 'obj_id' => $evt_id,  | 
                                                        |
| 139 | + 'noheader' => true,  | 
                                                        |
| 140 | + ),  | 
                                                        |
| 141 | + 'trash_event' => array(  | 
                                                        |
| 142 | + 'func' => '_trash_or_restore_event',  | 
                                                        |
| 143 | +				'args'       => array('event_status' => 'trash'), | 
                                                        |
| 144 | + 'capability' => 'ee_delete_event',  | 
                                                        |
| 145 | + 'obj_id' => $evt_id,  | 
                                                        |
| 146 | + 'noheader' => true,  | 
                                                        |
| 147 | + ),  | 
                                                        |
| 148 | + 'trash_events' => array(  | 
                                                        |
| 149 | + 'func' => '_trash_or_restore_events',  | 
                                                        |
| 150 | +				'args'       => array('event_status' => 'trash'), | 
                                                        |
| 151 | + 'capability' => 'ee_delete_events',  | 
                                                        |
| 152 | + 'noheader' => true,  | 
                                                        |
| 153 | + ),  | 
                                                        |
| 154 | + 'restore_event' => array(  | 
                                                        |
| 155 | + 'func' => '_trash_or_restore_event',  | 
                                                        |
| 156 | +				'args'       => array('event_status' => 'draft'), | 
                                                        |
| 157 | + 'capability' => 'ee_delete_event',  | 
                                                        |
| 158 | + 'obj_id' => $evt_id,  | 
                                                        |
| 159 | + 'noheader' => true,  | 
                                                        |
| 160 | + ),  | 
                                                        |
| 161 | + 'restore_events' => array(  | 
                                                        |
| 162 | + 'func' => '_trash_or_restore_events',  | 
                                                        |
| 163 | +				'args'       => array('event_status' => 'draft'), | 
                                                        |
| 164 | + 'capability' => 'ee_delete_events',  | 
                                                        |
| 165 | + 'noheader' => true,  | 
                                                        |
| 166 | + ),  | 
                                                        |
| 167 | + 'delete_event' => array(  | 
                                                        |
| 168 | + 'func' => '_delete_event',  | 
                                                        |
| 169 | + 'capability' => 'ee_delete_event',  | 
                                                        |
| 170 | + 'obj_id' => $evt_id,  | 
                                                        |
| 171 | + 'noheader' => true,  | 
                                                        |
| 172 | + ),  | 
                                                        |
| 173 | + 'delete_events' => array(  | 
                                                        |
| 174 | + 'func' => '_delete_events',  | 
                                                        |
| 175 | + 'capability' => 'ee_delete_events',  | 
                                                        |
| 176 | + 'noheader' => true,  | 
                                                        |
| 177 | + ),  | 
                                                        |
| 178 | + 'view_report' => array(  | 
                                                        |
| 179 | + 'func' => '_view_report',  | 
                                                        |
| 180 | + 'capablity' => 'ee_edit_events',  | 
                                                        |
| 181 | + ),  | 
                                                        |
| 182 | + 'default_event_settings' => array(  | 
                                                        |
| 183 | + 'func' => '_default_event_settings',  | 
                                                        |
| 184 | + 'capability' => 'manage_options',  | 
                                                        |
| 185 | + ),  | 
                                                        |
| 186 | + 'update_default_event_settings' => array(  | 
                                                        |
| 187 | + 'func' => '_update_default_event_settings',  | 
                                                        |
| 188 | + 'capability' => 'manage_options',  | 
                                                        |
| 189 | + 'noheader' => true,  | 
                                                        |
| 190 | + ),  | 
                                                        |
| 191 | + 'template_settings' => array(  | 
                                                        |
| 192 | + 'func' => '_template_settings',  | 
                                                        |
| 193 | + 'capability' => 'manage_options',  | 
                                                        |
| 194 | + ),  | 
                                                        |
| 195 | + // event category tab related  | 
                                                        |
| 196 | + 'add_category' => array(  | 
                                                        |
| 197 | + 'func' => '_category_details',  | 
                                                        |
| 198 | + 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 199 | +				'args'       => array('add'), | 
                                                        |
| 200 | + ),  | 
                                                        |
| 201 | + 'edit_category' => array(  | 
                                                        |
| 202 | + 'func' => '_category_details',  | 
                                                        |
| 203 | + 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 204 | +				'args'       => array('edit'), | 
                                                        |
| 205 | + ),  | 
                                                        |
| 206 | + 'delete_categories' => array(  | 
                                                        |
| 207 | + 'func' => '_delete_categories',  | 
                                                        |
| 208 | + 'capability' => 'ee_delete_event_category',  | 
                                                        |
| 209 | + 'noheader' => true,  | 
                                                        |
| 210 | + ),  | 
                                                        |
| 211 | + 'delete_category' => array(  | 
                                                        |
| 212 | + 'func' => '_delete_categories',  | 
                                                        |
| 213 | + 'capability' => 'ee_delete_event_category',  | 
                                                        |
| 214 | + 'noheader' => true,  | 
                                                        |
| 215 | + ),  | 
                                                        |
| 216 | + 'insert_category' => array(  | 
                                                        |
| 217 | + 'func' => '_insert_or_update_category',  | 
                                                        |
| 218 | +				'args'       => array('new_category' => true), | 
                                                        |
| 219 | + 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 220 | + 'noheader' => true,  | 
                                                        |
| 221 | + ),  | 
                                                        |
| 222 | + 'update_category' => array(  | 
                                                        |
| 223 | + 'func' => '_insert_or_update_category',  | 
                                                        |
| 224 | +				'args'       => array('new_category' => false), | 
                                                        |
| 225 | + 'capability' => 'ee_edit_event_category',  | 
                                                        |
| 226 | + 'noheader' => true,  | 
                                                        |
| 227 | + ),  | 
                                                        |
| 228 | + 'category_list' => array(  | 
                                                        |
| 229 | + 'func' => '_category_list_table',  | 
                                                        |
| 230 | + 'capability' => 'ee_manage_event_categories',  | 
                                                        |
| 231 | + ),  | 
                                                        |
| 232 | + );  | 
                                                        |
| 233 | + }  | 
                                                        |
| 234 | +  | 
                                                        |
| 235 | +  | 
                                                        |
| 236 | + /**  | 
                                                        |
| 237 | + * Set the _page_config property for this admin page group.  | 
                                                        |
| 238 | + */  | 
                                                        |
| 239 | + protected function _set_page_config()  | 
                                                        |
| 240 | +	{ | 
                                                        |
| 241 | + $this->_page_config = array(  | 
                                                        |
| 242 | + 'default' => array(  | 
                                                        |
| 243 | + 'nav' => array(  | 
                                                        |
| 244 | +					'label' => esc_html__('Overview', 'event_espresso'), | 
                                                        |
| 245 | + 'order' => 10,  | 
                                                        |
| 246 | + ),  | 
                                                        |
| 247 | + 'list_table' => 'Events_Admin_List_Table',  | 
                                                        |
| 248 | + 'help_tabs' => array(  | 
                                                        |
| 249 | + 'events_overview_help_tab' => array(  | 
                                                        |
| 250 | +						'title'    => esc_html__('Events Overview', 'event_espresso'), | 
                                                        |
| 251 | + 'filename' => 'events_overview',  | 
                                                        |
| 252 | + ),  | 
                                                        |
| 253 | + 'events_overview_table_column_headings_help_tab' => array(  | 
                                                        |
| 254 | +						'title'    => esc_html__('Events Overview Table Column Headings', 'event_espresso'), | 
                                                        |
| 255 | + 'filename' => 'events_overview_table_column_headings',  | 
                                                        |
| 256 | + ),  | 
                                                        |
| 257 | + 'events_overview_filters_help_tab' => array(  | 
                                                        |
| 258 | +						'title'    => esc_html__('Events Overview Filters', 'event_espresso'), | 
                                                        |
| 259 | + 'filename' => 'events_overview_filters',  | 
                                                        |
| 260 | + ),  | 
                                                        |
| 261 | + 'events_overview_view_help_tab' => array(  | 
                                                        |
| 262 | +						'title'    => esc_html__('Events Overview Views', 'event_espresso'), | 
                                                        |
| 263 | + 'filename' => 'events_overview_views',  | 
                                                        |
| 264 | + ),  | 
                                                        |
| 265 | + 'events_overview_other_help_tab' => array(  | 
                                                        |
| 266 | +						'title'    => esc_html__('Events Overview Other', 'event_espresso'), | 
                                                        |
| 267 | + 'filename' => 'events_overview_other',  | 
                                                        |
| 268 | + ),  | 
                                                        |
| 269 | + ),  | 
                                                        |
| 270 | + 'help_tour' => array(  | 
                                                        |
| 271 | + 'Event_Overview_Help_Tour',  | 
                                                        |
| 272 | + // 'New_Features_Test_Help_Tour' for testing multiple help tour  | 
                                                        |
| 273 | + ),  | 
                                                        |
| 274 | + 'qtips' => array(  | 
                                                        |
| 275 | + 'EE_Event_List_Table_Tips',  | 
                                                        |
| 276 | + ),  | 
                                                        |
| 277 | + 'require_nonce' => false,  | 
                                                        |
| 278 | + ),  | 
                                                        |
| 279 | + 'create_new' => array(  | 
                                                        |
| 280 | + 'nav' => array(  | 
                                                        |
| 281 | +					'label'      => esc_html__('Add Event', 'event_espresso'), | 
                                                        |
| 282 | + 'order' => 5,  | 
                                                        |
| 283 | + 'persistent' => false,  | 
                                                        |
| 284 | + ),  | 
                                                        |
| 285 | +				'metaboxes'     => array('_register_event_editor_meta_boxes'), | 
                                                        |
| 286 | + 'help_tabs' => array(  | 
                                                        |
| 287 | + 'event_editor_help_tab' => array(  | 
                                                        |
| 288 | +						'title'    => esc_html__('Event Editor', 'event_espresso'), | 
                                                        |
| 289 | + 'filename' => 'event_editor',  | 
                                                        |
| 290 | + ),  | 
                                                        |
| 291 | + 'event_editor_title_richtexteditor_help_tab' => array(  | 
                                                        |
| 292 | +						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), | 
                                                        |
| 293 | + 'filename' => 'event_editor_title_richtexteditor',  | 
                                                        |
| 294 | + ),  | 
                                                        |
| 295 | + 'event_editor_venue_details_help_tab' => array(  | 
                                                        |
| 296 | +						'title'    => esc_html__('Event Venue Details', 'event_espresso'), | 
                                                        |
| 297 | + 'filename' => 'event_editor_venue_details',  | 
                                                        |
| 298 | + ),  | 
                                                        |
| 299 | + 'event_editor_event_datetimes_help_tab' => array(  | 
                                                        |
| 300 | +						'title'    => esc_html__('Event Datetimes', 'event_espresso'), | 
                                                        |
| 301 | + 'filename' => 'event_editor_event_datetimes',  | 
                                                        |
| 302 | + ),  | 
                                                        |
| 303 | + 'event_editor_event_tickets_help_tab' => array(  | 
                                                        |
| 304 | +						'title'    => esc_html__('Event Tickets', 'event_espresso'), | 
                                                        |
| 305 | + 'filename' => 'event_editor_event_tickets',  | 
                                                        |
| 306 | + ),  | 
                                                        |
| 307 | + 'event_editor_event_registration_options_help_tab' => array(  | 
                                                        |
| 308 | +						'title'    => esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 309 | + 'filename' => 'event_editor_event_registration_options',  | 
                                                        |
| 310 | + ),  | 
                                                        |
| 311 | + 'event_editor_tags_categories_help_tab' => array(  | 
                                                        |
| 312 | +						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'), | 
                                                        |
| 313 | + 'filename' => 'event_editor_tags_categories',  | 
                                                        |
| 314 | + ),  | 
                                                        |
| 315 | + 'event_editor_questions_registrants_help_tab' => array(  | 
                                                        |
| 316 | +						'title'    => esc_html__('Questions for Registrants', 'event_espresso'), | 
                                                        |
| 317 | + 'filename' => 'event_editor_questions_registrants',  | 
                                                        |
| 318 | + ),  | 
                                                        |
| 319 | + 'event_editor_save_new_event_help_tab' => array(  | 
                                                        |
| 320 | +						'title'    => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 321 | + 'filename' => 'event_editor_save_new_event',  | 
                                                        |
| 322 | + ),  | 
                                                        |
| 323 | + 'event_editor_other_help_tab' => array(  | 
                                                        |
| 324 | +						'title'    => esc_html__('Event Other', 'event_espresso'), | 
                                                        |
| 325 | + 'filename' => 'event_editor_other',  | 
                                                        |
| 326 | + ),  | 
                                                        |
| 327 | + ),  | 
                                                        |
| 328 | + 'help_tour' => array(  | 
                                                        |
| 329 | + 'Event_Editor_Help_Tour',  | 
                                                        |
| 330 | + ),  | 
                                                        |
| 331 | +				'qtips'         => array('EE_Event_Editor_Decaf_Tips'), | 
                                                        |
| 332 | + 'require_nonce' => false,  | 
                                                        |
| 333 | + ),  | 
                                                        |
| 334 | + 'edit' => array(  | 
                                                        |
| 335 | + 'nav' => array(  | 
                                                        |
| 336 | +					'label'      => esc_html__('Edit Event', 'event_espresso'), | 
                                                        |
| 337 | + 'order' => 5,  | 
                                                        |
| 338 | + 'persistent' => false,  | 
                                                        |
| 339 | + 'url' => isset($this->_req_data['post'])  | 
                                                        |
| 340 | + ? EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 341 | +							array('post' => $this->_req_data['post'], 'action' => 'edit'), | 
                                                        |
| 342 | + $this->_current_page_view_url  | 
                                                        |
| 343 | + )  | 
                                                        |
| 344 | + : $this->_admin_base_url,  | 
                                                        |
| 345 | + ),  | 
                                                        |
| 346 | +				'metaboxes'     => array('_register_event_editor_meta_boxes'), | 
                                                        |
| 347 | + 'help_tabs' => array(  | 
                                                        |
| 348 | + 'event_editor_help_tab' => array(  | 
                                                        |
| 349 | +						'title'    => esc_html__('Event Editor', 'event_espresso'), | 
                                                        |
| 350 | + 'filename' => 'event_editor',  | 
                                                        |
| 351 | + ),  | 
                                                        |
| 352 | + 'event_editor_title_richtexteditor_help_tab' => array(  | 
                                                        |
| 353 | +						'title'    => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), | 
                                                        |
| 354 | + 'filename' => 'event_editor_title_richtexteditor',  | 
                                                        |
| 355 | + ),  | 
                                                        |
| 356 | + 'event_editor_venue_details_help_tab' => array(  | 
                                                        |
| 357 | +						'title'    => esc_html__('Event Venue Details', 'event_espresso'), | 
                                                        |
| 358 | + 'filename' => 'event_editor_venue_details',  | 
                                                        |
| 359 | + ),  | 
                                                        |
| 360 | + 'event_editor_event_datetimes_help_tab' => array(  | 
                                                        |
| 361 | +						'title'    => esc_html__('Event Datetimes', 'event_espresso'), | 
                                                        |
| 362 | + 'filename' => 'event_editor_event_datetimes',  | 
                                                        |
| 363 | + ),  | 
                                                        |
| 364 | + 'event_editor_event_tickets_help_tab' => array(  | 
                                                        |
| 365 | +						'title'    => esc_html__('Event Tickets', 'event_espresso'), | 
                                                        |
| 366 | + 'filename' => 'event_editor_event_tickets',  | 
                                                        |
| 367 | + ),  | 
                                                        |
| 368 | + 'event_editor_event_registration_options_help_tab' => array(  | 
                                                        |
| 369 | +						'title'    => esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 370 | + 'filename' => 'event_editor_event_registration_options',  | 
                                                        |
| 371 | + ),  | 
                                                        |
| 372 | + 'event_editor_tags_categories_help_tab' => array(  | 
                                                        |
| 373 | +						'title'    => esc_html__('Event Tags & Categories', 'event_espresso'), | 
                                                        |
| 374 | + 'filename' => 'event_editor_tags_categories',  | 
                                                        |
| 375 | + ),  | 
                                                        |
| 376 | + 'event_editor_questions_registrants_help_tab' => array(  | 
                                                        |
| 377 | +						'title'    => esc_html__('Questions for Registrants', 'event_espresso'), | 
                                                        |
| 378 | + 'filename' => 'event_editor_questions_registrants',  | 
                                                        |
| 379 | + ),  | 
                                                        |
| 380 | + 'event_editor_save_new_event_help_tab' => array(  | 
                                                        |
| 381 | +						'title'    => esc_html__('Save New Event', 'event_espresso'), | 
                                                        |
| 382 | + 'filename' => 'event_editor_save_new_event',  | 
                                                        |
| 383 | + ),  | 
                                                        |
| 384 | + 'event_editor_other_help_tab' => array(  | 
                                                        |
| 385 | +						'title'    => esc_html__('Event Other', 'event_espresso'), | 
                                                        |
| 386 | + 'filename' => 'event_editor_other',  | 
                                                        |
| 387 | + ),  | 
                                                        |
| 388 | + ),  | 
                                                        |
| 389 | +				'qtips'         => array('EE_Event_Editor_Decaf_Tips'), | 
                                                        |
| 390 | + 'require_nonce' => false,  | 
                                                        |
| 391 | + ),  | 
                                                        |
| 392 | + 'default_event_settings' => array(  | 
                                                        |
| 393 | + 'nav' => array(  | 
                                                        |
| 394 | +					'label' => esc_html__('Default Settings', 'event_espresso'), | 
                                                        |
| 395 | + 'order' => 40,  | 
                                                        |
| 396 | + ),  | 
                                                        |
| 397 | +				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), | 
                                                        |
| 398 | + 'labels' => array(  | 
                                                        |
| 399 | +					'publishbox' => esc_html__('Update Settings', 'event_espresso'), | 
                                                        |
| 400 | + ),  | 
                                                        |
| 401 | + 'help_tabs' => array(  | 
                                                        |
| 402 | + 'default_settings_help_tab' => array(  | 
                                                        |
| 403 | +						'title'    => esc_html__('Default Event Settings', 'event_espresso'), | 
                                                        |
| 404 | + 'filename' => 'events_default_settings',  | 
                                                        |
| 405 | + ),  | 
                                                        |
| 406 | + 'default_settings_status_help_tab' => array(  | 
                                                        |
| 407 | +						'title'    => esc_html__('Default Registration Status', 'event_espresso'), | 
                                                        |
| 408 | + 'filename' => 'events_default_settings_status',  | 
                                                        |
| 409 | + ),  | 
                                                        |
| 410 | + 'default_maximum_tickets_help_tab' => array(  | 
                                                        |
| 411 | +						'title'    => esc_html__('Default Maximum Tickets Per Order', 'event_espresso'), | 
                                                        |
| 412 | + 'filename' => 'events_default_settings_max_tickets',  | 
                                                        |
| 413 | + ),  | 
                                                        |
| 414 | + ),  | 
                                                        |
| 415 | +				'help_tour'     => array('Event_Default_Settings_Help_Tour'), | 
                                                        |
| 416 | + 'require_nonce' => false,  | 
                                                        |
| 417 | + ),  | 
                                                        |
| 418 | + // template settings  | 
                                                        |
| 419 | + 'template_settings' => array(  | 
                                                        |
| 420 | + 'nav' => array(  | 
                                                        |
| 421 | +					'label' => esc_html__('Templates', 'event_espresso'), | 
                                                        |
| 422 | + 'order' => 30,  | 
                                                        |
| 423 | + ),  | 
                                                        |
| 424 | + 'metaboxes' => $this->_default_espresso_metaboxes,  | 
                                                        |
| 425 | + 'help_tabs' => array(  | 
                                                        |
| 426 | + 'general_settings_templates_help_tab' => array(  | 
                                                        |
| 427 | +						'title'    => esc_html__('Templates', 'event_espresso'), | 
                                                        |
| 428 | + 'filename' => 'general_settings_templates',  | 
                                                        |
| 429 | + ),  | 
                                                        |
| 430 | + ),  | 
                                                        |
| 431 | +				'help_tour'     => array('Templates_Help_Tour'), | 
                                                        |
| 432 | + 'require_nonce' => false,  | 
                                                        |
| 433 | + ),  | 
                                                        |
| 434 | + // event category stuff  | 
                                                        |
| 435 | + 'add_category' => array(  | 
                                                        |
| 436 | + 'nav' => array(  | 
                                                        |
| 437 | +					'label'      => esc_html__('Add Category', 'event_espresso'), | 
                                                        |
| 438 | + 'order' => 15,  | 
                                                        |
| 439 | + 'persistent' => false,  | 
                                                        |
| 440 | + ),  | 
                                                        |
| 441 | + 'help_tabs' => array(  | 
                                                        |
| 442 | + 'add_category_help_tab' => array(  | 
                                                        |
| 443 | +						'title'    => esc_html__('Add New Event Category', 'event_espresso'), | 
                                                        |
| 444 | + 'filename' => 'events_add_category',  | 
                                                        |
| 445 | + ),  | 
                                                        |
| 446 | + ),  | 
                                                        |
| 447 | +				'help_tour'     => array('Event_Add_Category_Help_Tour'), | 
                                                        |
| 448 | +				'metaboxes'     => array('_publish_post_box'), | 
                                                        |
| 449 | + 'require_nonce' => false,  | 
                                                        |
| 450 | + ),  | 
                                                        |
| 451 | + 'edit_category' => array(  | 
                                                        |
| 452 | + 'nav' => array(  | 
                                                        |
| 453 | +					'label'      => esc_html__('Edit Category', 'event_espresso'), | 
                                                        |
| 454 | + 'order' => 15,  | 
                                                        |
| 455 | + 'persistent' => false,  | 
                                                        |
| 456 | + 'url' => isset($this->_req_data['EVT_CAT_ID'])  | 
                                                        |
| 457 | + ? add_query_arg(  | 
                                                        |
| 458 | +							array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), | 
                                                        |
| 459 | + $this->_current_page_view_url  | 
                                                        |
| 460 | + )  | 
                                                        |
| 461 | + : $this->_admin_base_url,  | 
                                                        |
| 462 | + ),  | 
                                                        |
| 463 | + 'help_tabs' => array(  | 
                                                        |
| 464 | + 'edit_category_help_tab' => array(  | 
                                                        |
| 465 | +						'title'    => esc_html__('Edit Event Category', 'event_espresso'), | 
                                                        |
| 466 | + 'filename' => 'events_edit_category',  | 
                                                        |
| 467 | + ),  | 
                                                        |
| 468 | + ),  | 
                                                        |
| 469 | +				/*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ | 
                                                        |
| 470 | +				'metaboxes'     => array('_publish_post_box'), | 
                                                        |
| 471 | + 'require_nonce' => false,  | 
                                                        |
| 472 | + ),  | 
                                                        |
| 473 | + 'category_list' => array(  | 
                                                        |
| 474 | + 'nav' => array(  | 
                                                        |
| 475 | +					'label' => esc_html__('Categories', 'event_espresso'), | 
                                                        |
| 476 | + 'order' => 20,  | 
                                                        |
| 477 | + ),  | 
                                                        |
| 478 | + 'list_table' => 'Event_Categories_Admin_List_Table',  | 
                                                        |
| 479 | + 'help_tabs' => array(  | 
                                                        |
| 480 | + 'events_categories_help_tab' => array(  | 
                                                        |
| 481 | +						'title'    => esc_html__('Event Categories', 'event_espresso'), | 
                                                        |
| 482 | + 'filename' => 'events_categories',  | 
                                                        |
| 483 | + ),  | 
                                                        |
| 484 | + 'events_categories_table_column_headings_help_tab' => array(  | 
                                                        |
| 485 | +						'title'    => esc_html__('Event Categories Table Column Headings', 'event_espresso'), | 
                                                        |
| 486 | + 'filename' => 'events_categories_table_column_headings',  | 
                                                        |
| 487 | + ),  | 
                                                        |
| 488 | + 'events_categories_view_help_tab' => array(  | 
                                                        |
| 489 | +						'title'    => esc_html__('Event Categories Views', 'event_espresso'), | 
                                                        |
| 490 | + 'filename' => 'events_categories_views',  | 
                                                        |
| 491 | + ),  | 
                                                        |
| 492 | + 'events_categories_other_help_tab' => array(  | 
                                                        |
| 493 | +						'title'    => esc_html__('Event Categories Other', 'event_espresso'), | 
                                                        |
| 494 | + 'filename' => 'events_categories_other',  | 
                                                        |
| 495 | + ),  | 
                                                        |
| 496 | + ),  | 
                                                        |
| 497 | + 'help_tour' => array(  | 
                                                        |
| 498 | + 'Event_Categories_Help_Tour',  | 
                                                        |
| 499 | + ),  | 
                                                        |
| 500 | + 'metaboxes' => $this->_default_espresso_metaboxes,  | 
                                                        |
| 501 | + 'require_nonce' => false,  | 
                                                        |
| 502 | + ),  | 
                                                        |
| 503 | + );  | 
                                                        |
| 504 | + }  | 
                                                        |
| 505 | +  | 
                                                        |
| 506 | +  | 
                                                        |
| 507 | + /**  | 
                                                        |
| 508 | + * Used to register any global screen options if necessary for every route in this admin page group.  | 
                                                        |
| 509 | + */  | 
                                                        |
| 510 | + protected function _add_screen_options()  | 
                                                        |
| 511 | +	{ | 
                                                        |
| 512 | + }  | 
                                                        |
| 513 | +  | 
                                                        |
| 514 | +  | 
                                                        |
| 515 | + /**  | 
                                                        |
| 516 | + * Implementing the screen options for the 'default' route.  | 
                                                        |
| 517 | + */  | 
                                                        |
| 518 | + protected function _add_screen_options_default()  | 
                                                        |
| 519 | +	{ | 
                                                        |
| 520 | + $this->_per_page_screen_option();  | 
                                                        |
| 521 | + }  | 
                                                        |
| 522 | +  | 
                                                        |
| 523 | +  | 
                                                        |
| 524 | + /**  | 
                                                        |
| 525 | + * Implementing screen options for the category list route.  | 
                                                        |
| 526 | + */  | 
                                                        |
| 527 | + protected function _add_screen_options_category_list()  | 
                                                        |
| 528 | +	{ | 
                                                        |
| 529 | + $page_title = $this->_admin_page_title;  | 
                                                        |
| 530 | +		$this->_admin_page_title = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 531 | + $this->_per_page_screen_option();  | 
                                                        |
| 532 | + $this->_admin_page_title = $page_title;  | 
                                                        |
| 533 | + }  | 
                                                        |
| 534 | +  | 
                                                        |
| 535 | +  | 
                                                        |
| 536 | + /**  | 
                                                        |
| 537 | + * Used to register any global feature pointers for the admin page group.  | 
                                                        |
| 538 | + */  | 
                                                        |
| 539 | + protected function _add_feature_pointers()  | 
                                                        |
| 540 | +	{ | 
                                                        |
| 541 | + }  | 
                                                        |
| 542 | +  | 
                                                        |
| 543 | +  | 
                                                        |
| 544 | + /**  | 
                                                        |
| 545 | + * Registers and enqueues any global scripts and styles for the entire admin page group.  | 
                                                        |
| 546 | + */  | 
                                                        |
| 547 | + public function load_scripts_styles()  | 
                                                        |
| 548 | +	{ | 
                                                        |
| 549 | + wp_register_style(  | 
                                                        |
| 550 | + 'events-admin-css',  | 
                                                        |
| 551 | + EVENTS_ASSETS_URL . 'events-admin-page.css',  | 
                                                        |
| 552 | + array(),  | 
                                                        |
| 553 | + EVENT_ESPRESSO_VERSION  | 
                                                        |
| 554 | + );  | 
                                                        |
| 555 | +		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); | 
                                                        |
| 556 | +		wp_enqueue_style('events-admin-css'); | 
                                                        |
| 557 | +		wp_enqueue_style('ee-cat-admin'); | 
                                                        |
| 558 | + // todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details  | 
                                                        |
| 559 | + // registers for all views  | 
                                                        |
| 560 | + // scripts  | 
                                                        |
| 561 | + wp_register_script(  | 
                                                        |
| 562 | + 'event_editor_js',  | 
                                                        |
| 563 | + EVENTS_ASSETS_URL . 'event_editor.js',  | 
                                                        |
| 564 | +			array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), | 
                                                        |
| 565 | + EVENT_ESPRESSO_VERSION,  | 
                                                        |
| 566 | + true  | 
                                                        |
| 567 | + );  | 
                                                        |
| 568 | + add_action(  | 
                                                        |
| 569 | + 'admin_footer',  | 
                                                        |
| 570 | +			function () { | 
                                                        |
| 571 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0;  | 
                                                        |
| 572 | +				if ($eventId) { | 
                                                        |
| 573 | + echo '  | 
                                                        |
| 574 | 574 | <script type="text/javascript">  | 
                                                        
| 575 | 575 | /* <![CDATA[ */ var eeEditorEventId = ' . $eventId . ' /* ]]> */  | 
                                                        
| 576 | 576 | </script>';  | 
                                                        
| 577 | - }  | 
                                                        |
| 578 | - }  | 
                                                        |
| 579 | - );  | 
                                                        |
| 580 | - }  | 
                                                        |
| 581 | -  | 
                                                        |
| 582 | -  | 
                                                        |
| 583 | - /**  | 
                                                        |
| 584 | - * Enqueuing scripts and styles specific to this view  | 
                                                        |
| 585 | - */  | 
                                                        |
| 586 | - public function load_scripts_styles_create_new()  | 
                                                        |
| 587 | -    { | 
                                                        |
| 588 | - $this->load_scripts_styles_edit();  | 
                                                        |
| 589 | - }  | 
                                                        |
| 590 | -  | 
                                                        |
| 591 | -  | 
                                                        |
| 592 | - /**  | 
                                                        |
| 593 | - * Enqueuing scripts and styles specific to this view  | 
                                                        |
| 594 | - */  | 
                                                        |
| 595 | - public function load_scripts_styles_edit()  | 
                                                        |
| 596 | -    { | 
                                                        |
| 597 | - // styles  | 
                                                        |
| 598 | -        wp_enqueue_style('espresso-ui-theme'); | 
                                                        |
| 599 | - wp_register_style(  | 
                                                        |
| 600 | - 'event-editor-css',  | 
                                                        |
| 601 | - EVENTS_ASSETS_URL . 'event-editor.css',  | 
                                                        |
| 602 | -            array('ee-admin-css'), | 
                                                        |
| 603 | - EVENT_ESPRESSO_VERSION  | 
                                                        |
| 604 | - );  | 
                                                        |
| 605 | -        wp_enqueue_style('event-editor-css'); | 
                                                        |
| 606 | - // scripts  | 
                                                        |
| 607 | - wp_register_script(  | 
                                                        |
| 608 | - 'event-datetime-metabox',  | 
                                                        |
| 609 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js',  | 
                                                        |
| 610 | -            array('event_editor_js', 'ee-datepicker'), | 
                                                        |
| 611 | - EVENT_ESPRESSO_VERSION  | 
                                                        |
| 612 | - );  | 
                                                        |
| 613 | -        wp_enqueue_script('event-datetime-metabox'); | 
                                                        |
| 614 | - }  | 
                                                        |
| 615 | -  | 
                                                        |
| 616 | -  | 
                                                        |
| 617 | - /**  | 
                                                        |
| 618 | - * Populating the _views property for the category list table view.  | 
                                                        |
| 619 | - */  | 
                                                        |
| 620 | - protected function _set_list_table_views_category_list()  | 
                                                        |
| 621 | -    { | 
                                                        |
| 622 | - $this->_views = array(  | 
                                                        |
| 623 | - 'all' => array(  | 
                                                        |
| 624 | - 'slug' => 'all',  | 
                                                        |
| 625 | -                'label'       => esc_html__('All', 'event_espresso'), | 
                                                        |
| 626 | - 'count' => 0,  | 
                                                        |
| 627 | - 'bulk_action' => array(  | 
                                                        |
| 628 | -                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), | 
                                                        |
| 629 | - ),  | 
                                                        |
| 630 | - ),  | 
                                                        |
| 631 | - );  | 
                                                        |
| 632 | - }  | 
                                                        |
| 633 | -  | 
                                                        |
| 634 | -  | 
                                                        |
| 635 | - /**  | 
                                                        |
| 636 | - * For adding anything that fires on the admin_init hook for any route within this admin page group.  | 
                                                        |
| 637 | - */  | 
                                                        |
| 638 | - public function admin_init()  | 
                                                        |
| 639 | -    { | 
                                                        |
| 640 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(  | 
                                                        |
| 641 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.',  | 
                                                        |
| 642 | - 'event_espresso'  | 
                                                        |
| 643 | - );  | 
                                                        |
| 644 | - }  | 
                                                        |
| 645 | -  | 
                                                        |
| 646 | -  | 
                                                        |
| 647 | - /**  | 
                                                        |
| 648 | - * For adding anything that should be triggered on the admin_notices hook for any route within this admin page  | 
                                                        |
| 649 | - * group.  | 
                                                        |
| 650 | - */  | 
                                                        |
| 651 | - public function admin_notices()  | 
                                                        |
| 652 | -    { | 
                                                        |
| 653 | - }  | 
                                                        |
| 654 | -  | 
                                                        |
| 655 | -  | 
                                                        |
| 656 | - /**  | 
                                                        |
| 657 | - * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within  | 
                                                        |
| 658 | - * this admin page group.  | 
                                                        |
| 659 | - */  | 
                                                        |
| 660 | - public function admin_footer_scripts()  | 
                                                        |
| 661 | -    { | 
                                                        |
| 662 | - }  | 
                                                        |
| 663 | -  | 
                                                        |
| 664 | -  | 
                                                        |
| 665 | - /**  | 
                                                        |
| 666 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a  | 
                                                        |
| 667 | - * warning (via EE_Error::add_error());  | 
                                                        |
| 668 | - *  | 
                                                        |
| 669 | - * @param EE_Event $event Event object  | 
                                                        |
| 670 | - * @param string $req_type  | 
                                                        |
| 671 | - * @return void  | 
                                                        |
| 672 | - * @throws EE_Error  | 
                                                        |
| 673 | - * @access public  | 
                                                        |
| 674 | - */  | 
                                                        |
| 675 | - public function verify_event_edit($event = null, $req_type = '')  | 
                                                        |
| 676 | -    { | 
                                                        |
| 677 | - // don't need to do this when processing  | 
                                                        |
| 678 | -        if (! empty($req_type)) { | 
                                                        |
| 679 | - return;  | 
                                                        |
| 680 | - }  | 
                                                        |
| 681 | - // no event?  | 
                                                        |
| 682 | -        if (empty($event)) { | 
                                                        |
| 683 | - // set event  | 
                                                        |
| 684 | - $event = $this->_cpt_model_obj;  | 
                                                        |
| 685 | - }  | 
                                                        |
| 686 | - // STILL no event?  | 
                                                        |
| 687 | -        if (! $event instanceof EE_Event) { | 
                                                        |
| 688 | - return;  | 
                                                        |
| 689 | - }  | 
                                                        |
| 690 | - $orig_status = $event->status();  | 
                                                        |
| 691 | - // first check if event is active.  | 
                                                        |
| 692 | - if ($orig_status === EEM_Event::cancelled  | 
                                                        |
| 693 | - || $orig_status === EEM_Event::postponed  | 
                                                        |
| 694 | - || $event->is_expired()  | 
                                                        |
| 695 | - || $event->is_inactive()  | 
                                                        |
| 696 | -        ) { | 
                                                        |
| 697 | - return;  | 
                                                        |
| 698 | - }  | 
                                                        |
| 699 | - // made it here so it IS active... next check that any of the tickets are sold.  | 
                                                        |
| 700 | -        if ($event->is_sold_out(true)) { | 
                                                        |
| 701 | -            if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { | 
                                                        |
| 702 | - EE_Error::add_attention(  | 
                                                        |
| 703 | - sprintf(  | 
                                                        |
| 704 | - esc_html__(  | 
                                                        |
| 705 | - '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.',  | 
                                                        |
| 706 | - 'event_espresso'  | 
                                                        |
| 707 | - ),  | 
                                                        |
| 708 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')  | 
                                                        |
| 709 | - )  | 
                                                        |
| 710 | - );  | 
                                                        |
| 711 | - }  | 
                                                        |
| 712 | - return;  | 
                                                        |
| 713 | -        } elseif ($orig_status === EEM_Event::sold_out) { | 
                                                        |
| 714 | - EE_Error::add_attention(  | 
                                                        |
| 715 | - sprintf(  | 
                                                        |
| 716 | - esc_html__(  | 
                                                        |
| 717 | - '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.',  | 
                                                        |
| 718 | - 'event_espresso'  | 
                                                        |
| 719 | - ),  | 
                                                        |
| 720 | - EEH_Template::pretty_status($event->status(), false, 'sentence')  | 
                                                        |
| 721 | - )  | 
                                                        |
| 722 | - );  | 
                                                        |
| 723 | - }  | 
                                                        |
| 724 | - // now we need to determine if the event has any tickets on sale. If not then we dont' show the error  | 
                                                        |
| 725 | -        if (! $event->tickets_on_sale()) { | 
                                                        |
| 726 | - return;  | 
                                                        |
| 727 | - }  | 
                                                        |
| 728 | - // made it here so show warning  | 
                                                        |
| 729 | - $this->_edit_event_warning();  | 
                                                        |
| 730 | - }  | 
                                                        |
| 731 | -  | 
                                                        |
| 732 | -  | 
                                                        |
| 733 | - /**  | 
                                                        |
| 734 | - * This is the text used for when an event is being edited that is public and has tickets for sale.  | 
                                                        |
| 735 | - * When needed, hook this into a EE_Error::add_error() notice.  | 
                                                        |
| 736 | - *  | 
                                                        |
| 737 | - * @access protected  | 
                                                        |
| 738 | - * @return void  | 
                                                        |
| 739 | - */  | 
                                                        |
| 740 | - protected function _edit_event_warning()  | 
                                                        |
| 741 | -    { | 
                                                        |
| 742 | - // we don't want to add warnings during these requests  | 
                                                        |
| 743 | -        if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { | 
                                                        |
| 744 | - return;  | 
                                                        |
| 745 | - }  | 
                                                        |
| 746 | - EE_Error::add_attention(  | 
                                                        |
| 747 | - sprintf(  | 
                                                        |
| 748 | - esc_html__(  | 
                                                        |
| 749 | - 'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',  | 
                                                        |
| 750 | - 'event_espresso'  | 
                                                        |
| 751 | - ),  | 
                                                        |
| 752 | - '<a class="espresso-help-tab-lnk">',  | 
                                                        |
| 753 | - '</a>'  | 
                                                        |
| 754 | - )  | 
                                                        |
| 755 | - );  | 
                                                        |
| 756 | - }  | 
                                                        |
| 757 | -  | 
                                                        |
| 758 | -  | 
                                                        |
| 759 | - /**  | 
                                                        |
| 760 | - * When a user is creating a new event, notify them if they haven't set their timezone.  | 
                                                        |
| 761 | - * Otherwise, do the normal logic  | 
                                                        |
| 762 | - *  | 
                                                        |
| 763 | - * @return string  | 
                                                        |
| 764 | - * @throws \EE_Error  | 
                                                        |
| 765 | - */  | 
                                                        |
| 766 | - protected function _create_new_cpt_item()  | 
                                                        |
| 767 | -    { | 
                                                        |
| 768 | -        $has_timezone_string = get_option('timezone_string'); | 
                                                        |
| 769 | - // only nag them about setting their timezone if it's their first event, and they haven't already done it  | 
                                                        |
| 770 | -        if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { | 
                                                        |
| 771 | - EE_Error::add_attention(  | 
                                                        |
| 772 | - sprintf(  | 
                                                        |
| 773 | - __(  | 
                                                        |
| 774 | - 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',  | 
                                                        |
| 775 | - 'event_espresso'  | 
                                                        |
| 776 | - ),  | 
                                                        |
| 777 | - '<br>',  | 
                                                        |
| 778 | - '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'  | 
                                                        |
| 779 | -                    . EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) | 
                                                        |
| 780 | - . '</select>',  | 
                                                        |
| 781 | - '<button class="button button-secondary timezone-submit">',  | 
                                                        |
| 782 | - '</button><span class="spinner"></span>'  | 
                                                        |
| 783 | - ),  | 
                                                        |
| 784 | - __FILE__,  | 
                                                        |
| 785 | - __FUNCTION__,  | 
                                                        |
| 786 | - __LINE__  | 
                                                        |
| 787 | - );  | 
                                                        |
| 788 | - }  | 
                                                        |
| 789 | - return parent::_create_new_cpt_item();  | 
                                                        |
| 790 | - }  | 
                                                        |
| 791 | -  | 
                                                        |
| 792 | -  | 
                                                        |
| 793 | - /**  | 
                                                        |
| 794 | - * Sets the _views property for the default route in this admin page group.  | 
                                                        |
| 795 | - */  | 
                                                        |
| 796 | - protected function _set_list_table_views_default()  | 
                                                        |
| 797 | -    { | 
                                                        |
| 798 | - $this->_views = array(  | 
                                                        |
| 799 | - 'all' => array(  | 
                                                        |
| 800 | - 'slug' => 'all',  | 
                                                        |
| 801 | -                'label'       => esc_html__('View All Events', 'event_espresso'), | 
                                                        |
| 802 | - 'count' => 0,  | 
                                                        |
| 803 | - 'bulk_action' => array(  | 
                                                        |
| 804 | -                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'), | 
                                                        |
| 805 | - ),  | 
                                                        |
| 806 | - ),  | 
                                                        |
| 807 | - 'draft' => array(  | 
                                                        |
| 808 | - 'slug' => 'draft',  | 
                                                        |
| 809 | -                'label'       => esc_html__('Draft', 'event_espresso'), | 
                                                        |
| 810 | - 'count' => 0,  | 
                                                        |
| 811 | - 'bulk_action' => array(  | 
                                                        |
| 812 | -                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'), | 
                                                        |
| 813 | - ),  | 
                                                        |
| 814 | - ),  | 
                                                        |
| 815 | - );  | 
                                                        |
| 816 | -        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { | 
                                                        |
| 817 | - $this->_views['trash'] = array(  | 
                                                        |
| 818 | - 'slug' => 'trash',  | 
                                                        |
| 819 | -                'label'       => esc_html__('Trash', 'event_espresso'), | 
                                                        |
| 820 | - 'count' => 0,  | 
                                                        |
| 821 | - 'bulk_action' => array(  | 
                                                        |
| 822 | -                    'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), | 
                                                        |
| 823 | -                    'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'), | 
                                                        |
| 824 | - ),  | 
                                                        |
| 825 | - );  | 
                                                        |
| 826 | - }  | 
                                                        |
| 827 | - }  | 
                                                        |
| 828 | -  | 
                                                        |
| 829 | -  | 
                                                        |
| 830 | - /**  | 
                                                        |
| 831 | - * Provides the legend item array for the default list table view.  | 
                                                        |
| 832 | - *  | 
                                                        |
| 833 | - * @return array  | 
                                                        |
| 834 | - */  | 
                                                        |
| 835 | - protected function _event_legend_items()  | 
                                                        |
| 836 | -    { | 
                                                        |
| 837 | - $items = array(  | 
                                                        |
| 838 | - 'view_details' => array(  | 
                                                        |
| 839 | - 'class' => 'dashicons dashicons-search',  | 
                                                        |
| 840 | -                'desc'  => esc_html__('View Event', 'event_espresso'), | 
                                                        |
| 841 | - ),  | 
                                                        |
| 842 | - 'edit_event' => array(  | 
                                                        |
| 843 | - 'class' => 'ee-icon ee-icon-calendar-edit',  | 
                                                        |
| 844 | -                'desc'  => esc_html__('Edit Event Details', 'event_espresso'), | 
                                                        |
| 845 | - ),  | 
                                                        |
| 846 | - 'view_attendees' => array(  | 
                                                        |
| 847 | - 'class' => 'dashicons dashicons-groups',  | 
                                                        |
| 848 | -                'desc'  => esc_html__('View Registrations for Event', 'event_espresso'), | 
                                                        |
| 849 | - ),  | 
                                                        |
| 850 | - );  | 
                                                        |
| 851 | -        $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); | 
                                                        |
| 852 | - $statuses = array(  | 
                                                        |
| 853 | - 'sold_out_status' => array(  | 
                                                        |
| 854 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,  | 
                                                        |
| 855 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),  | 
                                                        |
| 856 | - ),  | 
                                                        |
| 857 | - 'active_status' => array(  | 
                                                        |
| 858 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,  | 
                                                        |
| 859 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),  | 
                                                        |
| 860 | - ),  | 
                                                        |
| 861 | - 'upcoming_status' => array(  | 
                                                        |
| 862 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,  | 
                                                        |
| 863 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),  | 
                                                        |
| 864 | - ),  | 
                                                        |
| 865 | - 'postponed_status' => array(  | 
                                                        |
| 866 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,  | 
                                                        |
| 867 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),  | 
                                                        |
| 868 | - ),  | 
                                                        |
| 869 | - 'cancelled_status' => array(  | 
                                                        |
| 870 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,  | 
                                                        |
| 871 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),  | 
                                                        |
| 872 | - ),  | 
                                                        |
| 873 | - 'expired_status' => array(  | 
                                                        |
| 874 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,  | 
                                                        |
| 875 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),  | 
                                                        |
| 876 | - ),  | 
                                                        |
| 877 | - 'inactive_status' => array(  | 
                                                        |
| 878 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,  | 
                                                        |
| 879 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),  | 
                                                        |
| 880 | - ),  | 
                                                        |
| 881 | - );  | 
                                                        |
| 882 | -        $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); | 
                                                        |
| 883 | - return array_merge($items, $statuses);  | 
                                                        |
| 884 | - }  | 
                                                        |
| 885 | -  | 
                                                        |
| 886 | -  | 
                                                        |
| 887 | - /**  | 
                                                        |
| 888 | - * @return EEM_Event  | 
                                                        |
| 889 | - */  | 
                                                        |
| 890 | - private function _event_model()  | 
                                                        |
| 891 | -    { | 
                                                        |
| 892 | -        if (! $this->_event_model instanceof EEM_Event) { | 
                                                        |
| 893 | -            $this->_event_model = EE_Registry::instance()->load_model('Event'); | 
                                                        |
| 894 | - }  | 
                                                        |
| 895 | - return $this->_event_model;  | 
                                                        |
| 896 | - }  | 
                                                        |
| 897 | -  | 
                                                        |
| 898 | -  | 
                                                        |
| 899 | - /**  | 
                                                        |
| 900 | - * Adds extra buttons to the WP CPT permalink field row.  | 
                                                        |
| 901 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.  | 
                                                        |
| 902 | - *  | 
                                                        |
| 903 | - * @param string $return the current html  | 
                                                        |
| 904 | - * @param int $id the post id for the page  | 
                                                        |
| 905 | - * @param string $new_title What the title is  | 
                                                        |
| 906 | - * @param string $new_slug what the slug is  | 
                                                        |
| 907 | - * @return string The new html string for the permalink area  | 
                                                        |
| 908 | - */  | 
                                                        |
| 909 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)  | 
                                                        |
| 910 | -    { | 
                                                        |
| 911 | - // make sure this is only when editing  | 
                                                        |
| 912 | -        if (! empty($id)) { | 
                                                        |
| 913 | - $post = get_post($id);  | 
                                                        |
| 914 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'  | 
                                                        |
| 915 | -                       . esc_html__('Shortcode', 'event_espresso') | 
                                                        |
| 916 | - . '</a> ';  | 
                                                        |
| 917 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='  | 
                                                        |
| 918 | - . $post->ID  | 
                                                        |
| 919 | - . ']">';  | 
                                                        |
| 920 | - }  | 
                                                        |
| 921 | - return $return;  | 
                                                        |
| 922 | - }  | 
                                                        |
| 923 | -  | 
                                                        |
| 924 | -  | 
                                                        |
| 925 | - /**  | 
                                                        |
| 926 | - * _events_overview_list_table  | 
                                                        |
| 927 | - * This contains the logic for showing the events_overview list  | 
                                                        |
| 928 | - *  | 
                                                        |
| 929 | - * @access protected  | 
                                                        |
| 930 | - * @return void  | 
                                                        |
| 931 | - * @throws \EE_Error  | 
                                                        |
| 932 | - */  | 
                                                        |
| 933 | - protected function _events_overview_list_table()  | 
                                                        |
| 934 | -    { | 
                                                        |
| 935 | -        do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 936 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])  | 
                                                        |
| 937 | - ? (array) $this->_template_args['after_list_table']  | 
                                                        |
| 938 | - : array();  | 
                                                        |
| 939 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()  | 
                                                        |
| 940 | - . EEH_Template::get_button_or_link(  | 
                                                        |
| 941 | -                    get_post_type_archive_link('espresso_events'), | 
                                                        |
| 942 | -                    esc_html__("View Event Archive Page", "event_espresso"), | 
                                                        |
| 943 | - 'button'  | 
                                                        |
| 944 | - );  | 
                                                        |
| 945 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());  | 
                                                        |
| 946 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 947 | - 'create_new',  | 
                                                        |
| 948 | - 'add',  | 
                                                        |
| 949 | - array(),  | 
                                                        |
| 950 | - 'add-new-h2'  | 
                                                        |
| 951 | - );  | 
                                                        |
| 952 | - $this->display_admin_list_table_page_with_no_sidebar();  | 
                                                        |
| 953 | - }  | 
                                                        |
| 954 | -  | 
                                                        |
| 955 | -  | 
                                                        |
| 956 | - /**  | 
                                                        |
| 957 | - * this allows for extra misc actions in the default WP publish box  | 
                                                        |
| 958 | - *  | 
                                                        |
| 959 | - * @return void  | 
                                                        |
| 960 | - */  | 
                                                        |
| 961 | - public function extra_misc_actions_publish_box()  | 
                                                        |
| 962 | -    { | 
                                                        |
| 963 | - $this->_generate_publish_box_extra_content();  | 
                                                        |
| 964 | - }  | 
                                                        |
| 965 | -  | 
                                                        |
| 966 | -  | 
                                                        |
| 967 | - /**  | 
                                                        |
| 968 | -     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been | 
                                                        |
| 969 | - * saved.  | 
                                                        |
| 970 | - * Typically you would use this to save any additional data.  | 
                                                        |
| 971 | - * Keep in mind also that "save_post" runs on EVERY post update to the database.  | 
                                                        |
| 972 | - * ALSO very important. When a post transitions from scheduled to published,  | 
                                                        |
| 973 | - * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from  | 
                                                        |
| 974 | - * other meta saves. So MAKE sure that you handle this accordingly.  | 
                                                        |
| 975 | - *  | 
                                                        |
| 976 | - * @access protected  | 
                                                        |
| 977 | - * @abstract  | 
                                                        |
| 978 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally)  | 
                                                        |
| 979 | - * @param object $post The post object of the cpt that was saved.  | 
                                                        |
| 980 | - * @return void  | 
                                                        |
| 981 | - * @throws \EE_Error  | 
                                                        |
| 982 | - */  | 
                                                        |
| 983 | - protected function _insert_update_cpt_item($post_id, $post)  | 
                                                        |
| 984 | -    { | 
                                                        |
| 985 | -        if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { | 
                                                        |
| 986 | - // get out we're not processing an event save.  | 
                                                        |
| 987 | - return;  | 
                                                        |
| 988 | - }  | 
                                                        |
| 989 | - $event_values = array(  | 
                                                        |
| 990 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,  | 
                                                        |
| 991 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,  | 
                                                        |
| 992 | - 'EVT_additional_limit' => min(  | 
                                                        |
| 993 | -                apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), | 
                                                        |
| 994 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null  | 
                                                        |
| 995 | - ),  | 
                                                        |
| 996 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])  | 
                                                        |
| 997 | - ? $this->_req_data['EVT_default_registration_status']  | 
                                                        |
| 998 | - : EE_Registry::instance()->CFG->registration->default_STS_ID,  | 
                                                        |
| 999 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,  | 
                                                        |
| 1000 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,  | 
                                                        |
| 1001 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string'])  | 
                                                        |
| 1002 | - ? $this->_req_data['timezone_string'] : null,  | 
                                                        |
| 1003 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL'])  | 
                                                        |
| 1004 | - ? $this->_req_data['externalURL'] : null,  | 
                                                        |
| 1005 | - 'EVT_phone' => ! empty($this->_req_data['event_phone'])  | 
                                                        |
| 1006 | - ? $this->_req_data['event_phone'] : null,  | 
                                                        |
| 1007 | - );  | 
                                                        |
| 1008 | - // update event  | 
                                                        |
| 1009 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id);  | 
                                                        |
| 1010 | - // 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!  | 
                                                        |
| 1011 | - $get_one_where = array(  | 
                                                        |
| 1012 | - $this->_event_model()->primary_key_name() => $post_id,  | 
                                                        |
| 1013 | - 'OR' => array(  | 
                                                        |
| 1014 | - 'status' => $post->post_status,  | 
                                                        |
| 1015 | - // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,  | 
                                                        |
| 1016 | - // but the returned object here has a status of "publish", so use the original post status as well  | 
                                                        |
| 1017 | - 'status*1' => $this->_req_data['original_post_status'],  | 
                                                        |
| 1018 | - ),  | 
                                                        |
| 1019 | - );  | 
                                                        |
| 1020 | - $event = $this->_event_model()->get_one(array($get_one_where));  | 
                                                        |
| 1021 | - // the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.  | 
                                                        |
| 1022 | - $event_update_callbacks = apply_filters(  | 
                                                        |
| 1023 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',  | 
                                                        |
| 1024 | - array(  | 
                                                        |
| 1025 | - array($this, '_default_venue_update'),  | 
                                                        |
| 1026 | - array($this, '_default_tickets_update'),  | 
                                                        |
| 1027 | - )  | 
                                                        |
| 1028 | - );  | 
                                                        |
| 1029 | - $att_success = true;  | 
                                                        |
| 1030 | -        foreach ($event_update_callbacks as $e_callback) { | 
                                                        |
| 1031 | - $_success = is_callable($e_callback)  | 
                                                        |
| 1032 | - ? call_user_func($e_callback, $event, $this->_req_data)  | 
                                                        |
| 1033 | - : false;  | 
                                                        |
| 1034 | - // if ANY of these updates fail then we want the appropriate global error message  | 
                                                        |
| 1035 | - $att_success = ! $att_success ? $att_success : $_success;  | 
                                                        |
| 1036 | - }  | 
                                                        |
| 1037 | - // any errors?  | 
                                                        |
| 1038 | -        if ($success && false === $att_success) { | 
                                                        |
| 1039 | - EE_Error::add_error(  | 
                                                        |
| 1040 | - esc_html__(  | 
                                                        |
| 1041 | - 'Event Details saved successfully but something went wrong with saving attachments.',  | 
                                                        |
| 1042 | - 'event_espresso'  | 
                                                        |
| 1043 | - ),  | 
                                                        |
| 1044 | - __FILE__,  | 
                                                        |
| 1045 | - __FUNCTION__,  | 
                                                        |
| 1046 | - __LINE__  | 
                                                        |
| 1047 | - );  | 
                                                        |
| 1048 | -        } elseif ($success === false) { | 
                                                        |
| 1049 | - EE_Error::add_error(  | 
                                                        |
| 1050 | -                esc_html__('Event Details did not save successfully.', 'event_espresso'), | 
                                                        |
| 1051 | - __FILE__,  | 
                                                        |
| 1052 | - __FUNCTION__,  | 
                                                        |
| 1053 | - __LINE__  | 
                                                        |
| 1054 | - );  | 
                                                        |
| 1055 | - }  | 
                                                        |
| 1056 | - }  | 
                                                        |
| 1057 | -  | 
                                                        |
| 1058 | -  | 
                                                        |
| 1059 | - /**  | 
                                                        |
| 1060 | - * @see parent::restore_item()  | 
                                                        |
| 1061 | - * @param int $post_id  | 
                                                        |
| 1062 | - * @param int $revision_id  | 
                                                        |
| 1063 | - */  | 
                                                        |
| 1064 | - protected function _restore_cpt_item($post_id, $revision_id)  | 
                                                        |
| 1065 | -    { | 
                                                        |
| 1066 | - // copy existing event meta to new post  | 
                                                        |
| 1067 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id);  | 
                                                        |
| 1068 | -        if ($post_evt instanceof EE_Event) { | 
                                                        |
| 1069 | - // meta revision restore  | 
                                                        |
| 1070 | - $post_evt->restore_revision($revision_id);  | 
                                                        |
| 1071 | - // related objs restore  | 
                                                        |
| 1072 | -            $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); | 
                                                        |
| 1073 | - }  | 
                                                        |
| 1074 | - }  | 
                                                        |
| 1075 | -  | 
                                                        |
| 1076 | -  | 
                                                        |
| 1077 | - /**  | 
                                                        |
| 1078 | - * Attach the venue to the Event  | 
                                                        |
| 1079 | - *  | 
                                                        |
| 1080 | - * @param \EE_Event $evtobj Event Object to add the venue to  | 
                                                        |
| 1081 | - * @param array $data The request data from the form  | 
                                                        |
| 1082 | - * @return bool Success or fail.  | 
                                                        |
| 1083 | - */  | 
                                                        |
| 1084 | - protected function _default_venue_update(\EE_Event $evtobj, $data)  | 
                                                        |
| 1085 | -    { | 
                                                        |
| 1086 | - require_once(EE_MODELS . 'EEM_Venue.model.php');  | 
                                                        |
| 1087 | -        $venue_model = EE_Registry::instance()->load_model('Venue'); | 
                                                        |
| 1088 | - $rows_affected = null;  | 
                                                        |
| 1089 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;  | 
                                                        |
| 1090 | - // very important. If we don't have a venue name...  | 
                                                        |
| 1091 | - // then we'll get out because not necessary to create empty venue  | 
                                                        |
| 1092 | -        if (empty($data['venue_title'])) { | 
                                                        |
| 1093 | - return false;  | 
                                                        |
| 1094 | - }  | 
                                                        |
| 1095 | - $venue_array = array(  | 
                                                        |
| 1096 | -            'VNU_wp_user'         => $evtobj->get('EVT_wp_user'), | 
                                                        |
| 1097 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null,  | 
                                                        |
| 1098 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null,  | 
                                                        |
| 1099 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,  | 
                                                        |
| 1100 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description']  | 
                                                        |
| 1101 | - : null,  | 
                                                        |
| 1102 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null,  | 
                                                        |
| 1103 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null,  | 
                                                        |
| 1104 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null,  | 
                                                        |
| 1105 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null,  | 
                                                        |
| 1106 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null,  | 
                                                        |
| 1107 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null,  | 
                                                        |
| 1108 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,  | 
                                                        |
| 1109 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,  | 
                                                        |
| 1110 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null,  | 
                                                        |
| 1111 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,  | 
                                                        |
| 1112 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,  | 
                                                        |
| 1113 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,  | 
                                                        |
| 1114 | - 'status' => 'publish',  | 
                                                        |
| 1115 | - );  | 
                                                        |
| 1116 | - // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.  | 
                                                        |
| 1117 | -        if (! empty($venue_id)) { | 
                                                        |
| 1118 | - $update_where = array($venue_model->primary_key_name() => $venue_id);  | 
                                                        |
| 1119 | - $rows_affected = $venue_model->update($venue_array, array($update_where));  | 
                                                        |
| 1120 | - // 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.  | 
                                                        |
| 1121 | - $evtobj->_add_relation_to($venue_id, 'Venue');  | 
                                                        |
| 1122 | - return $rows_affected > 0 ? true : false;  | 
                                                        |
| 1123 | -        } else { | 
                                                        |
| 1124 | - // we insert the venue  | 
                                                        |
| 1125 | - $venue_id = $venue_model->insert($venue_array);  | 
                                                        |
| 1126 | - $evtobj->_add_relation_to($venue_id, 'Venue');  | 
                                                        |
| 1127 | - return ! empty($venue_id) ? true : false;  | 
                                                        |
| 1128 | - }  | 
                                                        |
| 1129 | - // when we have the ancestor come in it's already been handled by the revision save.  | 
                                                        |
| 1130 | - }  | 
                                                        |
| 1131 | -  | 
                                                        |
| 1132 | -  | 
                                                        |
| 1133 | - /**  | 
                                                        |
| 1134 | - * Handles saving everything related to Tickets (datetimes, tickets, prices)  | 
                                                        |
| 1135 | - *  | 
                                                        |
| 1136 | - * @param EE_Event $evtobj The Event object we're attaching data to  | 
                                                        |
| 1137 | - * @param array $data The request data from the form  | 
                                                        |
| 1138 | - * @return array  | 
                                                        |
| 1139 | - */  | 
                                                        |
| 1140 | - protected function _default_tickets_update(EE_Event $evtobj, $data)  | 
                                                        |
| 1141 | -    { | 
                                                        |
| 1142 | - $success = true;  | 
                                                        |
| 1143 | - $saved_dtt = null;  | 
                                                        |
| 1144 | - $saved_tickets = array();  | 
                                                        |
| 1145 | -        $incoming_date_formats = array('Y-m-d', 'h:i a'); | 
                                                        |
| 1146 | -        foreach ($data['edit_event_datetimes'] as $row => $dtt) { | 
                                                        |
| 1147 | - // trim all values to ensure any excess whitespace is removed.  | 
                                                        |
| 1148 | -            $dtt = array_map('trim', $dtt); | 
                                                        |
| 1149 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']  | 
                                                        |
| 1150 | - : $dtt['DTT_EVT_start'];  | 
                                                        |
| 1151 | - $datetime_values = array(  | 
                                                        |
| 1152 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,  | 
                                                        |
| 1153 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'],  | 
                                                        |
| 1154 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'],  | 
                                                        |
| 1155 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],  | 
                                                        |
| 1156 | - 'DTT_order' => $row,  | 
                                                        |
| 1157 | - );  | 
                                                        |
| 1158 | - // 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.  | 
                                                        |
| 1159 | -            if (! empty($dtt['DTT_ID'])) { | 
                                                        |
| 1160 | - $DTM = EE_Registry::instance()  | 
                                                        |
| 1161 | -                                  ->load_model('Datetime', array($evtobj->get_timezone())) | 
                                                        |
| 1162 | - ->get_one_by_ID($dtt['DTT_ID']);  | 
                                                        |
| 1163 | - $DTM->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1164 | - $DTM->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1165 | -                foreach ($datetime_values as $field => $value) { | 
                                                        |
| 1166 | - $DTM->set($field, $value);  | 
                                                        |
| 1167 | - }  | 
                                                        |
| 1168 | - // 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.  | 
                                                        |
| 1169 | - $saved_dtts[ $DTM->ID() ] = $DTM;  | 
                                                        |
| 1170 | -            } else { | 
                                                        |
| 1171 | - $DTM = EE_Registry::instance()->load_class(  | 
                                                        |
| 1172 | - 'Datetime',  | 
                                                        |
| 1173 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),  | 
                                                        |
| 1174 | - false,  | 
                                                        |
| 1175 | - false  | 
                                                        |
| 1176 | - );  | 
                                                        |
| 1177 | -                foreach ($datetime_values as $field => $value) { | 
                                                        |
| 1178 | - $DTM->set($field, $value);  | 
                                                        |
| 1179 | - }  | 
                                                        |
| 1180 | - }  | 
                                                        |
| 1181 | - $DTM->save();  | 
                                                        |
| 1182 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');  | 
                                                        |
| 1183 | - // load DTT helper  | 
                                                        |
| 1184 | - // 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.  | 
                                                        |
| 1185 | -            if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { | 
                                                        |
| 1186 | -                $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); | 
                                                        |
| 1187 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');  | 
                                                        |
| 1188 | - $DTT->save();  | 
                                                        |
| 1189 | - }  | 
                                                        |
| 1190 | - // 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.  | 
                                                        |
| 1191 | - $saved_dtt = $DTT;  | 
                                                        |
| 1192 | - $success = ! $success ? $success : $DTT;  | 
                                                        |
| 1193 | - // if ANY of these updates fail then we want the appropriate global error message.  | 
                                                        |
| 1194 | - // //todo this is actually sucky we need a better error message but this is what it is for now.  | 
                                                        |
| 1195 | - }  | 
                                                        |
| 1196 | - // no dtts get deleted so we don't do any of that logic here.  | 
                                                        |
| 1197 | - // update tickets next  | 
                                                        |
| 1198 | -        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); | 
                                                        |
| 1199 | -        foreach ($data['edit_tickets'] as $row => $tkt) { | 
                                                        |
| 1200 | -            $incoming_date_formats = array('Y-m-d', 'h:i a'); | 
                                                        |
| 1201 | - $update_prices = false;  | 
                                                        |
| 1202 | - $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])  | 
                                                        |
| 1203 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;  | 
                                                        |
| 1204 | - // trim inputs to ensure any excess whitespace is removed.  | 
                                                        |
| 1205 | -            $tkt = array_map('trim', $tkt); | 
                                                        |
| 1206 | -            if (empty($tkt['TKT_start_date'])) { | 
                                                        |
| 1207 | - // let's use now in the set timezone.  | 
                                                        |
| 1208 | -                $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); | 
                                                        |
| 1209 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);  | 
                                                        |
| 1210 | - }  | 
                                                        |
| 1211 | -            if (empty($tkt['TKT_end_date'])) { | 
                                                        |
| 1212 | - // use the start date of the first datetime  | 
                                                        |
| 1213 | - $dtt = $evtobj->first_datetime();  | 
                                                        |
| 1214 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time(  | 
                                                        |
| 1215 | - $incoming_date_formats[0],  | 
                                                        |
| 1216 | - $incoming_date_formats[1]  | 
                                                        |
| 1217 | - );  | 
                                                        |
| 1218 | - }  | 
                                                        |
| 1219 | - $TKT_values = array(  | 
                                                        |
| 1220 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,  | 
                                                        |
| 1221 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,  | 
                                                        |
| 1222 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',  | 
                                                        |
| 1223 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',  | 
                                                        |
| 1224 | - 'TKT_start_date' => $tkt['TKT_start_date'],  | 
                                                        |
| 1225 | - 'TKT_end_date' => $tkt['TKT_end_date'],  | 
                                                        |
| 1226 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],  | 
                                                        |
| 1227 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],  | 
                                                        |
| 1228 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],  | 
                                                        |
| 1229 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],  | 
                                                        |
| 1230 | - 'TKT_row' => $row,  | 
                                                        |
| 1231 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,  | 
                                                        |
| 1232 | - 'TKT_price' => $ticket_price,  | 
                                                        |
| 1233 | - );  | 
                                                        |
| 1234 | - // 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.  | 
                                                        |
| 1235 | -            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { | 
                                                        |
| 1236 | - $TKT_values['TKT_ID'] = 0;  | 
                                                        |
| 1237 | - $TKT_values['TKT_is_default'] = 0;  | 
                                                        |
| 1238 | - $TKT_values['TKT_price'] = $ticket_price;  | 
                                                        |
| 1239 | - $update_prices = true;  | 
                                                        |
| 1240 | - }  | 
                                                        |
| 1241 | - // if we have a TKT_ID then we need to get that existing TKT_obj and update it  | 
                                                        |
| 1242 | - // 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.  | 
                                                        |
| 1243 | - // 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.  | 
                                                        |
| 1244 | -            if (! empty($tkt['TKT_ID'])) { | 
                                                        |
| 1245 | - $TKT = EE_Registry::instance()  | 
                                                        |
| 1246 | -                                  ->load_model('Ticket', array($evtobj->get_timezone())) | 
                                                        |
| 1247 | - ->get_one_by_ID($tkt['TKT_ID']);  | 
                                                        |
| 1248 | -                if ($TKT instanceof EE_Ticket) { | 
                                                        |
| 1249 | - $ticket_sold = $TKT->count_related(  | 
                                                        |
| 1250 | - 'Registration',  | 
                                                        |
| 1251 | - array(  | 
                                                        |
| 1252 | - array(  | 
                                                        |
| 1253 | - 'STS_ID' => array(  | 
                                                        |
| 1254 | - 'NOT IN',  | 
                                                        |
| 1255 | - array(EEM_Registration::status_id_incomplete),  | 
                                                        |
| 1256 | - ),  | 
                                                        |
| 1257 | - ),  | 
                                                        |
| 1258 | - )  | 
                                                        |
| 1259 | - ) > 0 ? true : false;  | 
                                                        |
| 1260 | - // 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.  | 
                                                        |
| 1261 | -                    $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') | 
                                                        |
| 1262 | -                                      && ! $TKT->get('TKT_deleted'); | 
                                                        |
| 1263 | - $TKT->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1264 | - $TKT->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1265 | - // set new values  | 
                                                        |
| 1266 | -                    foreach ($TKT_values as $field => $value) { | 
                                                        |
| 1267 | -                        if ($field == 'TKT_qty') { | 
                                                        |
| 1268 | - $TKT->set_qty($value);  | 
                                                        |
| 1269 | -                        } else { | 
                                                        |
| 1270 | - $TKT->set($field, $value);  | 
                                                        |
| 1271 | - }  | 
                                                        |
| 1272 | - }  | 
                                                        |
| 1273 | - // if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket.  | 
                                                        |
| 1274 | -                    if ($create_new_TKT) { | 
                                                        |
| 1275 | - // archive the old ticket first  | 
                                                        |
| 1276 | -                        $TKT->set('TKT_deleted', 1); | 
                                                        |
| 1277 | - $TKT->save();  | 
                                                        |
| 1278 | - // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.  | 
                                                        |
| 1279 | - $saved_tickets[ $TKT->ID() ] = $TKT;  | 
                                                        |
| 1280 | - // 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.  | 
                                                        |
| 1281 | - $TKT = clone $TKT;  | 
                                                        |
| 1282 | -                        $TKT->set('TKT_ID', 0); | 
                                                        |
| 1283 | -                        $TKT->set('TKT_deleted', 0); | 
                                                        |
| 1284 | -                        $TKT->set('TKT_price', $ticket_price); | 
                                                        |
| 1285 | -                        $TKT->set('TKT_sold', 0); | 
                                                        |
| 1286 | - // now we need to make sure that $new prices are created as well and attached to new ticket.  | 
                                                        |
| 1287 | - $update_prices = true;  | 
                                                        |
| 1288 | - }  | 
                                                        |
| 1289 | - // make sure price is set if it hasn't been already  | 
                                                        |
| 1290 | -                    $TKT->set('TKT_price', $ticket_price); | 
                                                        |
| 1291 | - }  | 
                                                        |
| 1292 | -            } else { | 
                                                        |
| 1293 | - // no TKT_id so a new TKT  | 
                                                        |
| 1294 | - $TKT_values['TKT_price'] = $ticket_price;  | 
                                                        |
| 1295 | -                $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); | 
                                                        |
| 1296 | -                if ($TKT instanceof EE_Ticket) { | 
                                                        |
| 1297 | - // need to reset values to properly account for the date formats  | 
                                                        |
| 1298 | - $TKT->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1299 | - $TKT->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1300 | - $TKT->set_timezone($evtobj->get_timezone());  | 
                                                        |
| 1301 | - // set new values  | 
                                                        |
| 1302 | -                    foreach ($TKT_values as $field => $value) { | 
                                                        |
| 1303 | -                        if ($field == 'TKT_qty') { | 
                                                        |
| 1304 | - $TKT->set_qty($value);  | 
                                                        |
| 1305 | -                        } else { | 
                                                        |
| 1306 | - $TKT->set($field, $value);  | 
                                                        |
| 1307 | - }  | 
                                                        |
| 1308 | - }  | 
                                                        |
| 1309 | - $update_prices = true;  | 
                                                        |
| 1310 | - }  | 
                                                        |
| 1311 | - }  | 
                                                        |
| 1312 | - // cap ticket qty by datetime reg limits  | 
                                                        |
| 1313 | -            $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); | 
                                                        |
| 1314 | - // update ticket.  | 
                                                        |
| 1315 | - $TKT->save();  | 
                                                        |
| 1316 | - // 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.  | 
                                                        |
| 1317 | -            if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { | 
                                                        |
| 1318 | -                $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); | 
                                                        |
| 1319 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');  | 
                                                        |
| 1320 | - $TKT->save();  | 
                                                        |
| 1321 | - }  | 
                                                        |
| 1322 | - // initially let's add the ticket to the dtt  | 
                                                        |
| 1323 | - $saved_dtt->_add_relation_to($TKT, 'Ticket');  | 
                                                        |
| 1324 | - $saved_tickets[ $TKT->ID() ] = $TKT;  | 
                                                        |
| 1325 | - // add prices to ticket  | 
                                                        |
| 1326 | - $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);  | 
                                                        |
| 1327 | - }  | 
                                                        |
| 1328 | - // 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.  | 
                                                        |
| 1329 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;  | 
                                                        |
| 1330 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));  | 
                                                        |
| 1331 | -        foreach ($tickets_removed as $id) { | 
                                                        |
| 1332 | - $id = absint($id);  | 
                                                        |
| 1333 | - // get the ticket for this id  | 
                                                        |
| 1334 | -            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); | 
                                                        |
| 1335 | - // 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)  | 
                                                        |
| 1336 | -            $dtts = $tkt_to_remove->get_many_related('Datetime'); | 
                                                        |
| 1337 | -            foreach ($dtts as $dtt) { | 
                                                        |
| 1338 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');  | 
                                                        |
| 1339 | - }  | 
                                                        |
| 1340 | - // 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))  | 
                                                        |
| 1341 | -            $tkt_to_remove->delete_related_permanently('Price'); | 
                                                        |
| 1342 | - // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)  | 
                                                        |
| 1343 | - $tkt_to_remove->delete_permanently();  | 
                                                        |
| 1344 | - }  | 
                                                        |
| 1345 | - return array($saved_dtt, $saved_tickets);  | 
                                                        |
| 1346 | - }  | 
                                                        |
| 1347 | -  | 
                                                        |
| 1348 | -  | 
                                                        |
| 1349 | - /**  | 
                                                        |
| 1350 | - * This attaches a list of given prices to a ticket.  | 
                                                        |
| 1351 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change  | 
                                                        |
| 1352 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old  | 
                                                        |
| 1353 | - * price info and prices are automatically "archived" via the ticket.  | 
                                                        |
| 1354 | - *  | 
                                                        |
| 1355 | - * @access private  | 
                                                        |
| 1356 | - * @param array $prices Array of prices from the form.  | 
                                                        |
| 1357 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to.  | 
                                                        |
| 1358 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones.  | 
                                                        |
| 1359 | - * @return void  | 
                                                        |
| 1360 | - */  | 
                                                        |
| 1361 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)  | 
                                                        |
| 1362 | -    { | 
                                                        |
| 1363 | -        foreach ($prices as $row => $prc) { | 
                                                        |
| 1364 | - $PRC_values = array(  | 
                                                        |
| 1365 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,  | 
                                                        |
| 1366 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,  | 
                                                        |
| 1367 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,  | 
                                                        |
| 1368 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',  | 
                                                        |
| 1369 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',  | 
                                                        |
| 1370 | - 'PRC_is_default' => 0, // make sure prices are NOT set as default from this context  | 
                                                        |
| 1371 | - 'PRC_order' => $row,  | 
                                                        |
| 1372 | - );  | 
                                                        |
| 1373 | -            if ($new_prices || empty($PRC_values['PRC_ID'])) { | 
                                                        |
| 1374 | - $PRC_values['PRC_ID'] = 0;  | 
                                                        |
| 1375 | -                $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); | 
                                                        |
| 1376 | -            } else { | 
                                                        |
| 1377 | -                $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); | 
                                                        |
| 1378 | - // update this price with new values  | 
                                                        |
| 1379 | -                foreach ($PRC_values as $field => $newprc) { | 
                                                        |
| 1380 | - $PRC->set($field, $newprc);  | 
                                                        |
| 1381 | - }  | 
                                                        |
| 1382 | - $PRC->save();  | 
                                                        |
| 1383 | - }  | 
                                                        |
| 1384 | - $ticket->_add_relation_to($PRC, 'Price');  | 
                                                        |
| 1385 | - }  | 
                                                        |
| 1386 | - }  | 
                                                        |
| 1387 | -  | 
                                                        |
| 1388 | -  | 
                                                        |
| 1389 | - /**  | 
                                                        |
| 1390 | - * Add in our autosave ajax handlers  | 
                                                        |
| 1391 | - *  | 
                                                        |
| 1392 | - */  | 
                                                        |
| 1393 | - protected function _ee_autosave_create_new()  | 
                                                        |
| 1394 | -    { | 
                                                        |
| 1395 | - }  | 
                                                        |
| 1396 | -  | 
                                                        |
| 1397 | -  | 
                                                        |
| 1398 | - /**  | 
                                                        |
| 1399 | - * More autosave handlers.  | 
                                                        |
| 1400 | - */  | 
                                                        |
| 1401 | - protected function _ee_autosave_edit()  | 
                                                        |
| 1402 | -    { | 
                                                        |
| 1403 | - return; // TEMPORARILY EXITING CAUSE THIS IS A TODO  | 
                                                        |
| 1404 | - }  | 
                                                        |
| 1405 | -  | 
                                                        |
| 1406 | -  | 
                                                        |
| 1407 | - /**  | 
                                                        |
| 1408 | - * _generate_publish_box_extra_content  | 
                                                        |
| 1409 | - */  | 
                                                        |
| 1410 | - private function _generate_publish_box_extra_content()  | 
                                                        |
| 1411 | -    { | 
                                                        |
| 1412 | - // load formatter helper  | 
                                                        |
| 1413 | - // args for getting related registrations  | 
                                                        |
| 1414 | - $approved_query_args = array(  | 
                                                        |
| 1415 | - array(  | 
                                                        |
| 1416 | - 'REG_deleted' => 0,  | 
                                                        |
| 1417 | - 'STS_ID' => EEM_Registration::status_id_approved,  | 
                                                        |
| 1418 | - ),  | 
                                                        |
| 1419 | - );  | 
                                                        |
| 1420 | - $not_approved_query_args = array(  | 
                                                        |
| 1421 | - array(  | 
                                                        |
| 1422 | - 'REG_deleted' => 0,  | 
                                                        |
| 1423 | - 'STS_ID' => EEM_Registration::status_id_not_approved,  | 
                                                        |
| 1424 | - ),  | 
                                                        |
| 1425 | - );  | 
                                                        |
| 1426 | - $pending_payment_query_args = array(  | 
                                                        |
| 1427 | - array(  | 
                                                        |
| 1428 | - 'REG_deleted' => 0,  | 
                                                        |
| 1429 | - 'STS_ID' => EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 1430 | - ),  | 
                                                        |
| 1431 | - );  | 
                                                        |
| 1432 | - // publish box  | 
                                                        |
| 1433 | - $publish_box_extra_args = array(  | 
                                                        |
| 1434 | - 'view_approved_reg_url' => add_query_arg(  | 
                                                        |
| 1435 | - array(  | 
                                                        |
| 1436 | - 'action' => 'default',  | 
                                                        |
| 1437 | - 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1438 | - '_reg_status' => EEM_Registration::status_id_approved,  | 
                                                        |
| 1439 | - ),  | 
                                                        |
| 1440 | - REG_ADMIN_URL  | 
                                                        |
| 1441 | - ),  | 
                                                        |
| 1442 | - 'view_not_approved_reg_url' => add_query_arg(  | 
                                                        |
| 1443 | - array(  | 
                                                        |
| 1444 | - 'action' => 'default',  | 
                                                        |
| 1445 | - 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1446 | - '_reg_status' => EEM_Registration::status_id_not_approved,  | 
                                                        |
| 1447 | - ),  | 
                                                        |
| 1448 | - REG_ADMIN_URL  | 
                                                        |
| 1449 | - ),  | 
                                                        |
| 1450 | - 'view_pending_payment_reg_url' => add_query_arg(  | 
                                                        |
| 1451 | - array(  | 
                                                        |
| 1452 | - 'action' => 'default',  | 
                                                        |
| 1453 | - 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1454 | - '_reg_status' => EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 1455 | - ),  | 
                                                        |
| 1456 | - REG_ADMIN_URL  | 
                                                        |
| 1457 | - ),  | 
                                                        |
| 1458 | - 'approved_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1459 | - 'Registration',  | 
                                                        |
| 1460 | - $approved_query_args  | 
                                                        |
| 1461 | - ),  | 
                                                        |
| 1462 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1463 | - 'Registration',  | 
                                                        |
| 1464 | - $not_approved_query_args  | 
                                                        |
| 1465 | - ),  | 
                                                        |
| 1466 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1467 | - 'Registration',  | 
                                                        |
| 1468 | - $pending_payment_query_args  | 
                                                        |
| 1469 | - ),  | 
                                                        |
| 1470 | - 'misc_pub_section_class' => apply_filters(  | 
                                                        |
| 1471 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',  | 
                                                        |
| 1472 | - 'misc-pub-section'  | 
                                                        |
| 1473 | - ),  | 
                                                        |
| 1474 | - );  | 
                                                        |
| 1475 | - ob_start();  | 
                                                        |
| 1476 | - do_action(  | 
                                                        |
| 1477 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',  | 
                                                        |
| 1478 | - $this->_cpt_model_obj  | 
                                                        |
| 1479 | - );  | 
                                                        |
| 1480 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();  | 
                                                        |
| 1481 | - // load template  | 
                                                        |
| 1482 | - EEH_Template::display_template(  | 
                                                        |
| 1483 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',  | 
                                                        |
| 1484 | - $publish_box_extra_args  | 
                                                        |
| 1485 | - );  | 
                                                        |
| 1486 | - }  | 
                                                        |
| 1487 | -  | 
                                                        |
| 1488 | -  | 
                                                        |
| 1489 | - /**  | 
                                                        |
| 1490 | - * @return EE_Event  | 
                                                        |
| 1491 | - */  | 
                                                        |
| 1492 | - public function get_event_object()  | 
                                                        |
| 1493 | -    { | 
                                                        |
| 1494 | - return $this->_cpt_model_obj;  | 
                                                        |
| 1495 | - }  | 
                                                        |
| 1496 | -  | 
                                                        |
| 1497 | -  | 
                                                        |
| 1498 | -  | 
                                                        |
| 1499 | -  | 
                                                        |
| 1500 | - /** METABOXES * */  | 
                                                        |
| 1501 | - /**  | 
                                                        |
| 1502 | - * _register_event_editor_meta_boxes  | 
                                                        |
| 1503 | - * add all metaboxes related to the event_editor  | 
                                                        |
| 1504 | - *  | 
                                                        |
| 1505 | - * @return void  | 
                                                        |
| 1506 | - */  | 
                                                        |
| 1507 | - protected function _register_event_editor_meta_boxes()  | 
                                                        |
| 1508 | -    { | 
                                                        |
| 1509 | - $this->verify_cpt_object();  | 
                                                        |
| 1510 | - // add_meta_box(  | 
                                                        |
| 1511 | - // 'espresso_event_editor_tickets',  | 
                                                        |
| 1512 | -        //     esc_html__('Event Datetime & Ticket', 'event_espresso'), | 
                                                        |
| 1513 | - // array($this, 'ticket_metabox'),  | 
                                                        |
| 1514 | - // $this->page_slug,  | 
                                                        |
| 1515 | - // 'normal',  | 
                                                        |
| 1516 | - // 'high'  | 
                                                        |
| 1517 | - // );  | 
                                                        |
| 1518 | - add_meta_box(  | 
                                                        |
| 1519 | - 'espresso_event_editor_event_options',  | 
                                                        |
| 1520 | -            esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 1521 | - array($this, 'registration_options_meta_box'),  | 
                                                        |
| 1522 | - $this->page_slug,  | 
                                                        |
| 1523 | - 'side',  | 
                                                        |
| 1524 | - 'default'  | 
                                                        |
| 1525 | - );  | 
                                                        |
| 1526 | - // NOTE: if you're looking for other metaboxes in here,  | 
                                                        |
| 1527 | - // where a metabox has a related management page in the admin  | 
                                                        |
| 1528 | - // you will find it setup in the related management page's "_Hooks" file.  | 
                                                        |
| 1529 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".  | 
                                                        |
| 1530 | - }  | 
                                                        |
| 1531 | -  | 
                                                        |
| 1532 | -  | 
                                                        |
| 1533 | - /**  | 
                                                        |
| 1534 | - * @throws DomainException  | 
                                                        |
| 1535 | - * @throws EE_Error  | 
                                                        |
| 1536 | - */  | 
                                                        |
| 1537 | - public function ticket_metabox()  | 
                                                        |
| 1538 | -    { | 
                                                        |
| 1539 | - $existing_datetime_ids = $existing_ticket_ids = array();  | 
                                                        |
| 1540 | - // defaults for template args  | 
                                                        |
| 1541 | - $template_args = array(  | 
                                                        |
| 1542 | - 'existing_datetime_ids' => '',  | 
                                                        |
| 1543 | - 'event_datetime_help_link' => '',  | 
                                                        |
| 1544 | - 'ticket_options_help_link' => '',  | 
                                                        |
| 1545 | - 'time' => null,  | 
                                                        |
| 1546 | - 'ticket_rows' => '',  | 
                                                        |
| 1547 | - 'existing_ticket_ids' => '',  | 
                                                        |
| 1548 | - 'total_ticket_rows' => 1,  | 
                                                        |
| 1549 | - 'ticket_js_structure' => '',  | 
                                                        |
| 1550 | - 'trash_icon' => 'ee-lock-icon',  | 
                                                        |
| 1551 | - 'disabled' => '',  | 
                                                        |
| 1552 | - );  | 
                                                        |
| 1553 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;  | 
                                                        |
| 1554 | -        do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 1555 | - /**  | 
                                                        |
| 1556 | - * 1. Start with retrieving Datetimes  | 
                                                        |
| 1557 | - * 2. Fore each datetime get related tickets  | 
                                                        |
| 1558 | - * 3. For each ticket get related prices  | 
                                                        |
| 1559 | - */  | 
                                                        |
| 1560 | -        $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); | 
                                                        |
| 1561 | - /** @type EE_Datetime $first_datetime */  | 
                                                        |
| 1562 | - $first_datetime = reset($times);  | 
                                                        |
| 1563 | - // do we get related tickets?  | 
                                                        |
| 1564 | - if ($first_datetime instanceof EE_Datetime  | 
                                                        |
| 1565 | - && $first_datetime->ID() !== 0  | 
                                                        |
| 1566 | -        ) { | 
                                                        |
| 1567 | -            $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); | 
                                                        |
| 1568 | - $template_args['time'] = $first_datetime;  | 
                                                        |
| 1569 | - $related_tickets = $first_datetime->tickets(  | 
                                                        |
| 1570 | - array(  | 
                                                        |
| 1571 | -                    array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), | 
                                                        |
| 1572 | - 'default_where_conditions' => 'none',  | 
                                                        |
| 1573 | - )  | 
                                                        |
| 1574 | - );  | 
                                                        |
| 1575 | -            if (! empty($related_tickets)) { | 
                                                        |
| 1576 | - $template_args['total_ticket_rows'] = count($related_tickets);  | 
                                                        |
| 1577 | - $row = 0;  | 
                                                        |
| 1578 | -                foreach ($related_tickets as $ticket) { | 
                                                        |
| 1579 | -                    $existing_ticket_ids[] = $ticket->get('TKT_ID'); | 
                                                        |
| 1580 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);  | 
                                                        |
| 1581 | - $row++;  | 
                                                        |
| 1582 | - }  | 
                                                        |
| 1583 | -            } else { | 
                                                        |
| 1584 | - $template_args['total_ticket_rows'] = 1;  | 
                                                        |
| 1585 | - /** @type EE_Ticket $ticket */  | 
                                                        |
| 1586 | -                $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); | 
                                                        |
| 1587 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);  | 
                                                        |
| 1588 | - }  | 
                                                        |
| 1589 | -        } else { | 
                                                        |
| 1590 | - $template_args['time'] = $times[0];  | 
                                                        |
| 1591 | - /** @type EE_Ticket $ticket */  | 
                                                        |
| 1592 | -            $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); | 
                                                        |
| 1593 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);  | 
                                                        |
| 1594 | - // NOTE: we're just sending the first default row  | 
                                                        |
| 1595 | - // (decaf can't manage default tickets so this should be sufficient);  | 
                                                        |
| 1596 | - }  | 
                                                        |
| 1597 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(  | 
                                                        |
| 1598 | - 'event_editor_event_datetimes_help_tab'  | 
                                                        |
| 1599 | - );  | 
                                                        |
| 1600 | -        $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); | 
                                                        |
| 1601 | -        $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); | 
                                                        |
| 1602 | -        $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); | 
                                                        |
| 1603 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row(  | 
                                                        |
| 1604 | -            EE_Registry::instance()->load_model('Ticket')->create_default_object(), | 
                                                        |
| 1605 | - true  | 
                                                        |
| 1606 | - );  | 
                                                        |
| 1607 | - $template = apply_filters(  | 
                                                        |
| 1608 | - 'FHEE__Events_Admin_Page__ticket_metabox__template',  | 
                                                        |
| 1609 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'  | 
                                                        |
| 1610 | - );  | 
                                                        |
| 1611 | - EEH_Template::display_template($template, $template_args);  | 
                                                        |
| 1612 | - }  | 
                                                        |
| 1613 | -  | 
                                                        |
| 1614 | -  | 
                                                        |
| 1615 | - /**  | 
                                                        |
| 1616 | - * Setup an individual ticket form for the decaf event editor page  | 
                                                        |
| 1617 | - *  | 
                                                        |
| 1618 | - * @access private  | 
                                                        |
| 1619 | - * @param EE_Ticket $ticket the ticket object  | 
                                                        |
| 1620 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation  | 
                                                        |
| 1621 | - * @param int $row  | 
                                                        |
| 1622 | - * @return string generated html for the ticket row.  | 
                                                        |
| 1623 | - */  | 
                                                        |
| 1624 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0)  | 
                                                        |
| 1625 | -    { | 
                                                        |
| 1626 | - $template_args = array(  | 
                                                        |
| 1627 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),  | 
                                                        |
| 1628 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'  | 
                                                        |
| 1629 | - : '',  | 
                                                        |
| 1630 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row,  | 
                                                        |
| 1631 | -            'TKT_ID'              => $ticket->get('TKT_ID'), | 
                                                        |
| 1632 | -            'TKT_name'            => $ticket->get('TKT_name'), | 
                                                        |
| 1633 | -            'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), | 
                                                        |
| 1634 | -            'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), | 
                                                        |
| 1635 | -            'TKT_is_default'      => $ticket->get('TKT_is_default'), | 
                                                        |
| 1636 | -            'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'), | 
                                                        |
| 1637 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',  | 
                                                        |
| 1638 | -            'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'), | 
                                                        |
| 1639 | -            'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted'))) | 
                                                        |
| 1640 | -                                     && (! empty($ticket) && $ticket->get('TKT_sold') === 0) | 
                                                        |
| 1641 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',  | 
                                                        |
| 1642 | -            'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' | 
                                                        |
| 1643 | - : ' disabled=disabled',  | 
                                                        |
| 1644 | - );  | 
                                                        |
| 1645 | - $price = $ticket->ID() !== 0  | 
                                                        |
| 1646 | -            ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) | 
                                                        |
| 1647 | -            : EE_Registry::instance()->load_model('Price')->create_default_object(); | 
                                                        |
| 1648 | - $price_args = array(  | 
                                                        |
| 1649 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,  | 
                                                        |
| 1650 | -            'PRC_amount'            => $price->get('PRC_amount'), | 
                                                        |
| 1651 | -            'PRT_ID'                => $price->get('PRT_ID'), | 
                                                        |
| 1652 | -            'PRC_ID'                => $price->get('PRC_ID'), | 
                                                        |
| 1653 | -            'PRC_is_default'        => $price->get('PRC_is_default'), | 
                                                        |
| 1654 | - );  | 
                                                        |
| 1655 | - // make sure we have default start and end dates if skeleton  | 
                                                        |
| 1656 | - // handle rows that should NOT be empty  | 
                                                        |
| 1657 | -        if (empty($template_args['TKT_start_date'])) { | 
                                                        |
| 1658 | - // if empty then the start date will be now.  | 
                                                        |
| 1659 | -            $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); | 
                                                        |
| 1660 | - }  | 
                                                        |
| 1661 | -        if (empty($template_args['TKT_end_date'])) { | 
                                                        |
| 1662 | - // get the earliest datetime (if present);  | 
                                                        |
| 1663 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0  | 
                                                        |
| 1664 | - ? $this->_cpt_model_obj->get_first_related(  | 
                                                        |
| 1665 | - 'Datetime',  | 
                                                        |
| 1666 | -                    array('order_by' => array('DTT_EVT_start' => 'ASC')) | 
                                                        |
| 1667 | - )  | 
                                                        |
| 1668 | - : null;  | 
                                                        |
| 1669 | -            if (! empty($earliest_dtt)) { | 
                                                        |
| 1670 | -                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); | 
                                                        |
| 1671 | -            } else { | 
                                                        |
| 1672 | - $template_args['TKT_end_date'] = date(  | 
                                                        |
| 1673 | - 'Y-m-d h:i a',  | 
                                                        |
| 1674 | -                    mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) | 
                                                        |
| 1675 | - );  | 
                                                        |
| 1676 | - }  | 
                                                        |
| 1677 | - }  | 
                                                        |
| 1678 | - $template_args = array_merge($template_args, $price_args);  | 
                                                        |
| 1679 | - $template = apply_filters(  | 
                                                        |
| 1680 | - 'FHEE__Events_Admin_Page__get_ticket_row__template',  | 
                                                        |
| 1681 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',  | 
                                                        |
| 1682 | - $ticket  | 
                                                        |
| 1683 | - );  | 
                                                        |
| 1684 | - return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 1685 | - }  | 
                                                        |
| 1686 | -  | 
                                                        |
| 1687 | -  | 
                                                        |
| 1688 | - /**  | 
                                                        |
| 1689 | - * @throws DomainException  | 
                                                        |
| 1690 | - */  | 
                                                        |
| 1691 | - public function registration_options_meta_box()  | 
                                                        |
| 1692 | -    { | 
                                                        |
| 1693 | - $yes_no_values = array(  | 
                                                        |
| 1694 | -            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), | 
                                                        |
| 1695 | -            array('id' => false, 'text' => esc_html__('No', 'event_espresso')), | 
                                                        |
| 1696 | - );  | 
                                                        |
| 1697 | - $default_reg_status_values = EEM_Registration::reg_status_array(  | 
                                                        |
| 1698 | - array(  | 
                                                        |
| 1699 | - EEM_Registration::status_id_cancelled,  | 
                                                        |
| 1700 | - EEM_Registration::status_id_declined,  | 
                                                        |
| 1701 | - EEM_Registration::status_id_incomplete,  | 
                                                        |
| 1702 | - ),  | 
                                                        |
| 1703 | - true  | 
                                                        |
| 1704 | - );  | 
                                                        |
| 1705 | -        // $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); | 
                                                        |
| 1706 | - $template_args['_event'] = $this->_cpt_model_obj;  | 
                                                        |
| 1707 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);  | 
                                                        |
| 1708 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();  | 
                                                        |
| 1709 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1710 | - 'default_reg_status',  | 
                                                        |
| 1711 | - $default_reg_status_values,  | 
                                                        |
| 1712 | - $this->_cpt_model_obj->default_registration_status()  | 
                                                        |
| 1713 | - );  | 
                                                        |
| 1714 | - $template_args['display_description'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1715 | - 'display_desc',  | 
                                                        |
| 1716 | - $yes_no_values,  | 
                                                        |
| 1717 | - $this->_cpt_model_obj->display_description()  | 
                                                        |
| 1718 | - );  | 
                                                        |
| 1719 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1720 | - 'display_ticket_selector',  | 
                                                        |
| 1721 | - $yes_no_values,  | 
                                                        |
| 1722 | - $this->_cpt_model_obj->display_ticket_selector(),  | 
                                                        |
| 1723 | - '',  | 
                                                        |
| 1724 | - '',  | 
                                                        |
| 1725 | - false  | 
                                                        |
| 1726 | - );  | 
                                                        |
| 1727 | - $template_args['additional_registration_options'] = apply_filters(  | 
                                                        |
| 1728 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',  | 
                                                        |
| 1729 | - '',  | 
                                                        |
| 1730 | - $template_args,  | 
                                                        |
| 1731 | - $yes_no_values,  | 
                                                        |
| 1732 | - $default_reg_status_values  | 
                                                        |
| 1733 | - );  | 
                                                        |
| 1734 | - EEH_Template::display_template(  | 
                                                        |
| 1735 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',  | 
                                                        |
| 1736 | - $template_args  | 
                                                        |
| 1737 | - );  | 
                                                        |
| 1738 | - }  | 
                                                        |
| 1739 | -  | 
                                                        |
| 1740 | -  | 
                                                        |
| 1741 | - /**  | 
                                                        |
| 1742 | - * _get_events()  | 
                                                        |
| 1743 | - * This method simply returns all the events (for the given _view and paging)  | 
                                                        |
| 1744 | - *  | 
                                                        |
| 1745 | - * @access public  | 
                                                        |
| 1746 | - * @param int $per_page count of items per page (20 default);  | 
                                                        |
| 1747 | - * @param int $current_page what is the current page being viewed.  | 
                                                        |
| 1748 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view.  | 
                                                        |
| 1749 | - * If FALSE then we return an array of event objects  | 
                                                        |
| 1750 | - * that match the given _view and paging parameters.  | 
                                                        |
| 1751 | - * @return array an array of event objects.  | 
                                                        |
| 1752 | - */  | 
                                                        |
| 1753 | - public function get_events($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 1754 | -    { | 
                                                        |
| 1755 | - $EEME = $this->_event_model();  | 
                                                        |
| 1756 | - $offset = ($current_page - 1) * $per_page;  | 
                                                        |
| 1757 | - $limit = $count ? null : $offset . ',' . $per_page;  | 
                                                        |
| 1758 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';  | 
                                                        |
| 1759 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";  | 
                                                        |
| 1760 | -        if (isset($this->_req_data['month_range'])) { | 
                                                        |
| 1761 | -            $pieces = explode(' ', $this->_req_data['month_range'], 3); | 
                                                        |
| 1762 | - // simulate the FIRST day of the month, that fixes issues for months like February  | 
                                                        |
| 1763 | - // where PHP doesn't know what to assume for date.  | 
                                                        |
| 1764 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437  | 
                                                        |
| 1765 | -            $month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; | 
                                                        |
| 1766 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : '';  | 
                                                        |
| 1767 | - }  | 
                                                        |
| 1768 | - $where = array();  | 
                                                        |
| 1769 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;  | 
                                                        |
| 1770 | - // determine what post_status our condition will have for the query.  | 
                                                        |
| 1771 | -        switch ($status) { | 
                                                        |
| 1772 | - case 'month':  | 
                                                        |
| 1773 | - case 'today':  | 
                                                        |
| 1774 | - case null:  | 
                                                        |
| 1775 | - case 'all':  | 
                                                        |
| 1776 | - break;  | 
                                                        |
| 1777 | - case 'draft':  | 
                                                        |
| 1778 | -                $where['status'] = array('IN', array('draft', 'auto-draft')); | 
                                                        |
| 1779 | - break;  | 
                                                        |
| 1780 | - default:  | 
                                                        |
| 1781 | - $where['status'] = $status;  | 
                                                        |
| 1782 | - }  | 
                                                        |
| 1783 | - // categories?  | 
                                                        |
| 1784 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0  | 
                                                        |
| 1785 | - ? $this->_req_data['EVT_CAT'] : null;  | 
                                                        |
| 1786 | -        if (! empty($category)) { | 
                                                        |
| 1787 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';  | 
                                                        |
| 1788 | - $where['Term_Taxonomy.term_id'] = $category;  | 
                                                        |
| 1789 | - }  | 
                                                        |
| 1790 | - // date where conditions  | 
                                                        |
| 1791 | -        $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); | 
                                                        |
| 1792 | -        if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { | 
                                                        |
| 1793 | - $DateTime = new DateTime(  | 
                                                        |
| 1794 | - $year_r . '-' . $month_r . '-01 00:00:00',  | 
                                                        |
| 1795 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone())  | 
                                                        |
| 1796 | - );  | 
                                                        |
| 1797 | -            $start = $DateTime->format(implode(' ', $start_formats)); | 
                                                        |
| 1798 | - $end = $DateTime->setDate(  | 
                                                        |
| 1799 | - $year_r,  | 
                                                        |
| 1800 | - $month_r,  | 
                                                        |
| 1801 | - $DateTime  | 
                                                        |
| 1802 | -                    ->format('t') | 
                                                        |
| 1803 | - )->setTime(23, 59, 59)  | 
                                                        |
| 1804 | -                            ->format(implode(' ', $start_formats)); | 
                                                        |
| 1805 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1806 | -        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { | 
                                                        |
| 1807 | -            $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); | 
                                                        |
| 1808 | -            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1809 | -            $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); | 
                                                        |
| 1810 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1811 | -        } elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { | 
                                                        |
| 1812 | -            $now = date('Y-m-01'); | 
                                                        |
| 1813 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));  | 
                                                        |
| 1814 | -            $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1815 | -            $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) | 
                                                        |
| 1816 | - ->setTime(23, 59, 59)  | 
                                                        |
| 1817 | -                            ->format(implode(' ', $start_formats)); | 
                                                        |
| 1818 | -            $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1819 | - }  | 
                                                        |
| 1820 | -        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { | 
                                                        |
| 1821 | - $where['EVT_wp_user'] = get_current_user_id();  | 
                                                        |
| 1822 | -        } else { | 
                                                        |
| 1823 | -            if (! isset($where['status'])) { | 
                                                        |
| 1824 | -                if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { | 
                                                        |
| 1825 | - $where['OR'] = array(  | 
                                                        |
| 1826 | -                        'status*restrict_private' => array('!=', 'private'), | 
                                                        |
| 1827 | - 'AND' => array(  | 
                                                        |
| 1828 | -                            'status*inclusive' => array('=', 'private'), | 
                                                        |
| 1829 | - 'EVT_wp_user' => get_current_user_id(),  | 
                                                        |
| 1830 | - ),  | 
                                                        |
| 1831 | - );  | 
                                                        |
| 1832 | - }  | 
                                                        |
| 1833 | - }  | 
                                                        |
| 1834 | - }  | 
                                                        |
| 1835 | -        if (isset($this->_req_data['EVT_wp_user'])) { | 
                                                        |
| 1836 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id()  | 
                                                        |
| 1837 | -                && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') | 
                                                        |
| 1838 | -            ) { | 
                                                        |
| 1839 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];  | 
                                                        |
| 1840 | - }  | 
                                                        |
| 1841 | - }  | 
                                                        |
| 1842 | - // search query handling  | 
                                                        |
| 1843 | -        if (isset($this->_req_data['s'])) { | 
                                                        |
| 1844 | - $search_string = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 1845 | - $where['OR'] = array(  | 
                                                        |
| 1846 | -                'EVT_name'       => array('LIKE', $search_string), | 
                                                        |
| 1847 | -                'EVT_desc'       => array('LIKE', $search_string), | 
                                                        |
| 1848 | -                'EVT_short_desc' => array('LIKE', $search_string), | 
                                                        |
| 1849 | - );  | 
                                                        |
| 1850 | - }  | 
                                                        |
| 1851 | -        $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); | 
                                                        |
| 1852 | - $query_params = apply_filters(  | 
                                                        |
| 1853 | - 'FHEE__Events_Admin_Page__get_events__query_params',  | 
                                                        |
| 1854 | - array(  | 
                                                        |
| 1855 | - $where,  | 
                                                        |
| 1856 | - 'limit' => $limit,  | 
                                                        |
| 1857 | - 'order_by' => $orderby,  | 
                                                        |
| 1858 | - 'order' => $order,  | 
                                                        |
| 1859 | - 'group_by' => 'EVT_ID',  | 
                                                        |
| 1860 | - ),  | 
                                                        |
| 1861 | - $this->_req_data  | 
                                                        |
| 1862 | - );  | 
                                                        |
| 1863 | - // let's first check if we have special requests coming in.  | 
                                                        |
| 1864 | -        if (isset($this->_req_data['active_status'])) { | 
                                                        |
| 1865 | -            switch ($this->_req_data['active_status']) { | 
                                                        |
| 1866 | - case 'upcoming':  | 
                                                        |
| 1867 | - return $EEME->get_upcoming_events($query_params, $count);  | 
                                                        |
| 1868 | - break;  | 
                                                        |
| 1869 | - case 'expired':  | 
                                                        |
| 1870 | - return $EEME->get_expired_events($query_params, $count);  | 
                                                        |
| 1871 | - break;  | 
                                                        |
| 1872 | - case 'active':  | 
                                                        |
| 1873 | - return $EEME->get_active_events($query_params, $count);  | 
                                                        |
| 1874 | - break;  | 
                                                        |
| 1875 | - case 'inactive':  | 
                                                        |
| 1876 | - return $EEME->get_inactive_events($query_params, $count);  | 
                                                        |
| 1877 | - break;  | 
                                                        |
| 1878 | - }  | 
                                                        |
| 1879 | - }  | 
                                                        |
| 1880 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);  | 
                                                        |
| 1881 | - return $events;  | 
                                                        |
| 1882 | - }  | 
                                                        |
| 1883 | -  | 
                                                        |
| 1884 | -  | 
                                                        |
| 1885 | - /**  | 
                                                        |
| 1886 | - * handling for WordPress CPT actions (trash, restore, delete)  | 
                                                        |
| 1887 | - *  | 
                                                        |
| 1888 | - * @param string $post_id  | 
                                                        |
| 1889 | - */  | 
                                                        |
| 1890 | - public function trash_cpt_item($post_id)  | 
                                                        |
| 1891 | -    { | 
                                                        |
| 1892 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1893 | -        $this->_trash_or_restore_event('trash', false); | 
                                                        |
| 1894 | - }  | 
                                                        |
| 1895 | -  | 
                                                        |
| 1896 | -  | 
                                                        |
| 1897 | - /**  | 
                                                        |
| 1898 | - * @param string $post_id  | 
                                                        |
| 1899 | - */  | 
                                                        |
| 1900 | - public function restore_cpt_item($post_id)  | 
                                                        |
| 1901 | -    { | 
                                                        |
| 1902 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1903 | -        $this->_trash_or_restore_event('draft', false); | 
                                                        |
| 1904 | - }  | 
                                                        |
| 1905 | -  | 
                                                        |
| 1906 | -  | 
                                                        |
| 1907 | - /**  | 
                                                        |
| 1908 | - * @param string $post_id  | 
                                                        |
| 1909 | - */  | 
                                                        |
| 1910 | - public function delete_cpt_item($post_id)  | 
                                                        |
| 1911 | -    { | 
                                                        |
| 1912 | - $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1913 | - $this->_delete_event(false);  | 
                                                        |
| 1914 | - }  | 
                                                        |
| 1915 | -  | 
                                                        |
| 1916 | -  | 
                                                        |
| 1917 | - /**  | 
                                                        |
| 1918 | - * _trash_or_restore_event  | 
                                                        |
| 1919 | - *  | 
                                                        |
| 1920 | - * @access protected  | 
                                                        |
| 1921 | - * @param string $event_status  | 
                                                        |
| 1922 | - * @param bool $redirect_after  | 
                                                        |
| 1923 | - */  | 
                                                        |
| 1924 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)  | 
                                                        |
| 1925 | -    { | 
                                                        |
| 1926 | - // determine the event id and set to array.  | 
                                                        |
| 1927 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;  | 
                                                        |
| 1928 | - // loop thru events  | 
                                                        |
| 1929 | -        if ($EVT_ID) { | 
                                                        |
| 1930 | - // clean status  | 
                                                        |
| 1931 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 1932 | - // grab status  | 
                                                        |
| 1933 | -            if (! empty($event_status)) { | 
                                                        |
| 1934 | - $success = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1935 | -            } else { | 
                                                        |
| 1936 | - $success = false;  | 
                                                        |
| 1937 | - $msg = esc_html__(  | 
                                                        |
| 1938 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1939 | - 'event_espresso'  | 
                                                        |
| 1940 | - );  | 
                                                        |
| 1941 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1942 | - }  | 
                                                        |
| 1943 | -        } else { | 
                                                        |
| 1944 | - $success = false;  | 
                                                        |
| 1945 | - $msg = esc_html__(  | 
                                                        |
| 1946 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1947 | - 'event_espresso'  | 
                                                        |
| 1948 | - );  | 
                                                        |
| 1949 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1950 | - }  | 
                                                        |
| 1951 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 1952 | -        if ($redirect_after) { | 
                                                        |
| 1953 | -            $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); | 
                                                        |
| 1954 | - }  | 
                                                        |
| 1955 | - }  | 
                                                        |
| 1956 | -  | 
                                                        |
| 1957 | -  | 
                                                        |
| 1958 | - /**  | 
                                                        |
| 1959 | - * _trash_or_restore_events  | 
                                                        |
| 1960 | - *  | 
                                                        |
| 1961 | - * @access protected  | 
                                                        |
| 1962 | - * @param string $event_status  | 
                                                        |
| 1963 | - * @return void  | 
                                                        |
| 1964 | - */  | 
                                                        |
| 1965 | - protected function _trash_or_restore_events($event_status = 'trash')  | 
                                                        |
| 1966 | -    { | 
                                                        |
| 1967 | - // clean status  | 
                                                        |
| 1968 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 1969 | - // grab status  | 
                                                        |
| 1970 | -        if (! empty($event_status)) { | 
                                                        |
| 1971 | - $success = true;  | 
                                                        |
| 1972 | - // determine the event id and set to array.  | 
                                                        |
| 1973 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 1974 | - // loop thru events  | 
                                                        |
| 1975 | -            foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 1976 | -                if ($EVT_ID = absint($EVT_ID)) { | 
                                                        |
| 1977 | - $results = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1978 | - $success = $results !== false ? $success : false;  | 
                                                        |
| 1979 | -                } else { | 
                                                        |
| 1980 | - $msg = sprintf(  | 
                                                        |
| 1981 | - esc_html__(  | 
                                                        |
| 1982 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1983 | - 'event_espresso'  | 
                                                        |
| 1984 | - ),  | 
                                                        |
| 1985 | - $EVT_ID  | 
                                                        |
| 1986 | - );  | 
                                                        |
| 1987 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1988 | - $success = false;  | 
                                                        |
| 1989 | - }  | 
                                                        |
| 1990 | - }  | 
                                                        |
| 1991 | -        } else { | 
                                                        |
| 1992 | - $success = false;  | 
                                                        |
| 1993 | - $msg = esc_html__(  | 
                                                        |
| 1994 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1995 | - 'event_espresso'  | 
                                                        |
| 1996 | - );  | 
                                                        |
| 1997 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1998 | - }  | 
                                                        |
| 1999 | - // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2000 | - $success = $success ? 2 : false;  | 
                                                        |
| 2001 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 2002 | -        $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); | 
                                                        |
| 2003 | - }  | 
                                                        |
| 2004 | -  | 
                                                        |
| 2005 | -  | 
                                                        |
| 2006 | - /**  | 
                                                        |
| 2007 | - * _trash_or_restore_events  | 
                                                        |
| 2008 | - *  | 
                                                        |
| 2009 | - * @access private  | 
                                                        |
| 2010 | - * @param int $EVT_ID  | 
                                                        |
| 2011 | - * @param string $event_status  | 
                                                        |
| 2012 | - * @return bool  | 
                                                        |
| 2013 | - */  | 
                                                        |
| 2014 | - private function _change_event_status($EVT_ID = 0, $event_status = '')  | 
                                                        |
| 2015 | -    { | 
                                                        |
| 2016 | - // grab event id  | 
                                                        |
| 2017 | -        if (! $EVT_ID) { | 
                                                        |
| 2018 | - $msg = esc_html__(  | 
                                                        |
| 2019 | - 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2020 | - 'event_espresso'  | 
                                                        |
| 2021 | - );  | 
                                                        |
| 2022 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2023 | - return false;  | 
                                                        |
| 2024 | - }  | 
                                                        |
| 2025 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2026 | - // clean status  | 
                                                        |
| 2027 | - $event_status = sanitize_key($event_status);  | 
                                                        |
| 2028 | - // grab status  | 
                                                        |
| 2029 | -        if (empty($event_status)) { | 
                                                        |
| 2030 | - $msg = esc_html__(  | 
                                                        |
| 2031 | - 'An error occurred. No Event Status or an invalid Event Status was received.',  | 
                                                        |
| 2032 | - 'event_espresso'  | 
                                                        |
| 2033 | - );  | 
                                                        |
| 2034 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2035 | - return false;  | 
                                                        |
| 2036 | - }  | 
                                                        |
| 2037 | - // was event trashed or restored ?  | 
                                                        |
| 2038 | -        switch ($event_status) { | 
                                                        |
| 2039 | - case 'draft':  | 
                                                        |
| 2040 | - $action = 'restored from the trash';  | 
                                                        |
| 2041 | - $hook = 'AHEE_event_restored_from_trash';  | 
                                                        |
| 2042 | - break;  | 
                                                        |
| 2043 | - case 'trash':  | 
                                                        |
| 2044 | - $action = 'moved to the trash';  | 
                                                        |
| 2045 | - $hook = 'AHEE_event_moved_to_trash';  | 
                                                        |
| 2046 | - break;  | 
                                                        |
| 2047 | - default:  | 
                                                        |
| 2048 | - $action = 'updated';  | 
                                                        |
| 2049 | - $hook = false;  | 
                                                        |
| 2050 | - }  | 
                                                        |
| 2051 | - // use class to change status  | 
                                                        |
| 2052 | - $this->_cpt_model_obj->set_status($event_status);  | 
                                                        |
| 2053 | - $success = $this->_cpt_model_obj->save();  | 
                                                        |
| 2054 | -        if ($success === false) { | 
                                                        |
| 2055 | -            $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); | 
                                                        |
| 2056 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2057 | - return false;  | 
                                                        |
| 2058 | - }  | 
                                                        |
| 2059 | -        if ($hook) { | 
                                                        |
| 2060 | - do_action($hook);  | 
                                                        |
| 2061 | - }  | 
                                                        |
| 2062 | - return true;  | 
                                                        |
| 2063 | - }  | 
                                                        |
| 2064 | -  | 
                                                        |
| 2065 | -  | 
                                                        |
| 2066 | - /**  | 
                                                        |
| 2067 | - * _delete_event  | 
                                                        |
| 2068 | - *  | 
                                                        |
| 2069 | - * @access protected  | 
                                                        |
| 2070 | - * @param bool $redirect_after  | 
                                                        |
| 2071 | - */  | 
                                                        |
| 2072 | - protected function _delete_event($redirect_after = true)  | 
                                                        |
| 2073 | -    { | 
                                                        |
| 2074 | - // determine the event id and set to array.  | 
                                                        |
| 2075 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;  | 
                                                        |
| 2076 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;  | 
                                                        |
| 2077 | - // loop thru events  | 
                                                        |
| 2078 | -        if ($EVT_ID) { | 
                                                        |
| 2079 | - $success = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2080 | - // get list of events with no prices  | 
                                                        |
| 2081 | -            $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2082 | - // remove this event from the list of events with no prices  | 
                                                        |
| 2083 | -            if (isset($espresso_no_ticket_prices[ $EVT_ID ])) { | 
                                                        |
| 2084 | - unset($espresso_no_ticket_prices[ $EVT_ID ]);  | 
                                                        |
| 2085 | - }  | 
                                                        |
| 2086 | -            update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2087 | -        } else { | 
                                                        |
| 2088 | - $success = false;  | 
                                                        |
| 2089 | - $msg = esc_html__(  | 
                                                        |
| 2090 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2091 | - 'event_espresso'  | 
                                                        |
| 2092 | - );  | 
                                                        |
| 2093 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2094 | - }  | 
                                                        |
| 2095 | -        if ($redirect_after) { | 
                                                        |
| 2096 | - $this->_redirect_after_action(  | 
                                                        |
| 2097 | - $success,  | 
                                                        |
| 2098 | - 'Event',  | 
                                                        |
| 2099 | - 'deleted',  | 
                                                        |
| 2100 | -                array('action' => 'default', 'status' => 'trash') | 
                                                        |
| 2101 | - );  | 
                                                        |
| 2102 | - }  | 
                                                        |
| 2103 | - }  | 
                                                        |
| 2104 | -  | 
                                                        |
| 2105 | -  | 
                                                        |
| 2106 | - /**  | 
                                                        |
| 2107 | - * _delete_events  | 
                                                        |
| 2108 | - *  | 
                                                        |
| 2109 | - * @access protected  | 
                                                        |
| 2110 | - * @return void  | 
                                                        |
| 2111 | - */  | 
                                                        |
| 2112 | - protected function _delete_events()  | 
                                                        |
| 2113 | -    { | 
                                                        |
| 2114 | - $success = true;  | 
                                                        |
| 2115 | - // get list of events with no prices  | 
                                                        |
| 2116 | -        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2117 | - // determine the event id and set to array.  | 
                                                        |
| 2118 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 2119 | - // loop thru events  | 
                                                        |
| 2120 | -        foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 2121 | - $EVT_ID = absint($EVT_ID);  | 
                                                        |
| 2122 | -            if ($EVT_ID) { | 
                                                        |
| 2123 | - $results = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2124 | - $success = $results !== false ? $success : false;  | 
                                                        |
| 2125 | - // remove this event from the list of events with no prices  | 
                                                        |
| 2126 | - unset($espresso_no_ticket_prices[ $EVT_ID ]);  | 
                                                        |
| 2127 | -            } else { | 
                                                        |
| 2128 | - $success = false;  | 
                                                        |
| 2129 | - $msg = esc_html__(  | 
                                                        |
| 2130 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2131 | - 'event_espresso'  | 
                                                        |
| 2132 | - );  | 
                                                        |
| 2133 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2134 | - }  | 
                                                        |
| 2135 | - }  | 
                                                        |
| 2136 | -        update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2137 | - // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2138 | - $success = $success ? 2 : false;  | 
                                                        |
| 2139 | -        $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); | 
                                                        |
| 2140 | - }  | 
                                                        |
| 2141 | -  | 
                                                        |
| 2142 | -  | 
                                                        |
| 2143 | - /**  | 
                                                        |
| 2144 | - * _permanently_delete_event  | 
                                                        |
| 2145 | - *  | 
                                                        |
| 2146 | - * @access private  | 
                                                        |
| 2147 | - * @param int $EVT_ID  | 
                                                        |
| 2148 | - * @return bool  | 
                                                        |
| 2149 | - */  | 
                                                        |
| 2150 | - private function _permanently_delete_event($EVT_ID = 0)  | 
                                                        |
| 2151 | -    { | 
                                                        |
| 2152 | - // grab event id  | 
                                                        |
| 2153 | -        if (! $EVT_ID) { | 
                                                        |
| 2154 | - $msg = esc_html__(  | 
                                                        |
| 2155 | - 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2156 | - 'event_espresso'  | 
                                                        |
| 2157 | - );  | 
                                                        |
| 2158 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2159 | - return false;  | 
                                                        |
| 2160 | - }  | 
                                                        |
| 2161 | - if (! $this->_cpt_model_obj instanceof EE_Event  | 
                                                        |
| 2162 | - || $this->_cpt_model_obj->ID() !== $EVT_ID  | 
                                                        |
| 2163 | -        ) { | 
                                                        |
| 2164 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2165 | - }  | 
                                                        |
| 2166 | -        if (! $this->_cpt_model_obj instanceof EE_Event) { | 
                                                        |
| 2167 | - return false;  | 
                                                        |
| 2168 | - }  | 
                                                        |
| 2169 | - // need to delete related tickets and prices first.  | 
                                                        |
| 2170 | -        $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); | 
                                                        |
| 2171 | -        foreach ($datetimes as $datetime) { | 
                                                        |
| 2172 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2173 | -            $tickets = $datetime->get_many_related('Ticket'); | 
                                                        |
| 2174 | -            foreach ($tickets as $ticket) { | 
                                                        |
| 2175 | - $ticket->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2176 | -                $ticket->delete_related_permanently('Price'); | 
                                                        |
| 2177 | - $ticket->delete_permanently();  | 
                                                        |
| 2178 | - }  | 
                                                        |
| 2179 | - $datetime->delete();  | 
                                                        |
| 2180 | - }  | 
                                                        |
| 2181 | - // what about related venues or terms?  | 
                                                        |
| 2182 | -        $venues = $this->_cpt_model_obj->get_many_related('Venue'); | 
                                                        |
| 2183 | -        foreach ($venues as $venue) { | 
                                                        |
| 2184 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');  | 
                                                        |
| 2185 | - }  | 
                                                        |
| 2186 | - // any attached question groups?  | 
                                                        |
| 2187 | -        $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); | 
                                                        |
| 2188 | -        if (! empty($question_groups)) { | 
                                                        |
| 2189 | -            foreach ($question_groups as $question_group) { | 
                                                        |
| 2190 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');  | 
                                                        |
| 2191 | - }  | 
                                                        |
| 2192 | - }  | 
                                                        |
| 2193 | - // Message Template Groups  | 
                                                        |
| 2194 | -        $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); | 
                                                        |
| 2195 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */  | 
                                                        |
| 2196 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();  | 
                                                        |
| 2197 | -        foreach ($term_taxonomies as $term_taxonomy) { | 
                                                        |
| 2198 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);  | 
                                                        |
| 2199 | - }  | 
                                                        |
| 2200 | - $success = $this->_cpt_model_obj->delete_permanently();  | 
                                                        |
| 2201 | - // did it all go as planned ?  | 
                                                        |
| 2202 | -        if ($success) { | 
                                                        |
| 2203 | -            $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); | 
                                                        |
| 2204 | - EE_Error::add_success($msg);  | 
                                                        |
| 2205 | -        } else { | 
                                                        |
| 2206 | - $msg = sprintf(  | 
                                                        |
| 2207 | -                esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), | 
                                                        |
| 2208 | - $EVT_ID  | 
                                                        |
| 2209 | - );  | 
                                                        |
| 2210 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2211 | - return false;  | 
                                                        |
| 2212 | - }  | 
                                                        |
| 2213 | -        do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); | 
                                                        |
| 2214 | - return true;  | 
                                                        |
| 2215 | - }  | 
                                                        |
| 2216 | -  | 
                                                        |
| 2217 | -  | 
                                                        |
| 2218 | - /**  | 
                                                        |
| 2219 | - * get total number of events  | 
                                                        |
| 2220 | - *  | 
                                                        |
| 2221 | - * @access public  | 
                                                        |
| 2222 | - * @return int  | 
                                                        |
| 2223 | - */  | 
                                                        |
| 2224 | - public function total_events()  | 
                                                        |
| 2225 | -    { | 
                                                        |
| 2226 | -        $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); | 
                                                        |
| 2227 | - return $count;  | 
                                                        |
| 2228 | - }  | 
                                                        |
| 2229 | -  | 
                                                        |
| 2230 | -  | 
                                                        |
| 2231 | - /**  | 
                                                        |
| 2232 | - * get total number of draft events  | 
                                                        |
| 2233 | - *  | 
                                                        |
| 2234 | - * @access public  | 
                                                        |
| 2235 | - * @return int  | 
                                                        |
| 2236 | - */  | 
                                                        |
| 2237 | - public function total_events_draft()  | 
                                                        |
| 2238 | -    { | 
                                                        |
| 2239 | - $where = array(  | 
                                                        |
| 2240 | -            'status' => array('IN', array('draft', 'auto-draft')), | 
                                                        |
| 2241 | - );  | 
                                                        |
| 2242 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2243 | - return $count;  | 
                                                        |
| 2244 | - }  | 
                                                        |
| 2245 | -  | 
                                                        |
| 2246 | -  | 
                                                        |
| 2247 | - /**  | 
                                                        |
| 2248 | - * get total number of trashed events  | 
                                                        |
| 2249 | - *  | 
                                                        |
| 2250 | - * @access public  | 
                                                        |
| 2251 | - * @return int  | 
                                                        |
| 2252 | - */  | 
                                                        |
| 2253 | - public function total_trashed_events()  | 
                                                        |
| 2254 | -    { | 
                                                        |
| 2255 | - $where = array(  | 
                                                        |
| 2256 | - 'status' => 'trash',  | 
                                                        |
| 2257 | - );  | 
                                                        |
| 2258 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2259 | - return $count;  | 
                                                        |
| 2260 | - }  | 
                                                        |
| 2261 | -  | 
                                                        |
| 2262 | -  | 
                                                        |
| 2263 | - /**  | 
                                                        |
| 2264 | - * _default_event_settings  | 
                                                        |
| 2265 | - * This generates the Default Settings Tab  | 
                                                        |
| 2266 | - *  | 
                                                        |
| 2267 | - * @return void  | 
                                                        |
| 2268 | - * @throws EE_Error  | 
                                                        |
| 2269 | - */  | 
                                                        |
| 2270 | - protected function _default_event_settings()  | 
                                                        |
| 2271 | -    { | 
                                                        |
| 2272 | -        $this->_set_add_edit_form_tags('update_default_event_settings'); | 
                                                        |
| 2273 | - $this->_set_publish_post_box_vars(null, false, false, null, false);  | 
                                                        |
| 2274 | - $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();  | 
                                                        |
| 2275 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2276 | - }  | 
                                                        |
| 2277 | -  | 
                                                        |
| 2278 | -  | 
                                                        |
| 2279 | - /**  | 
                                                        |
| 2280 | - * Return the form for event settings.  | 
                                                        |
| 2281 | - *  | 
                                                        |
| 2282 | - * @return EE_Form_Section_Proper  | 
                                                        |
| 2283 | - * @throws EE_Error  | 
                                                        |
| 2284 | - */  | 
                                                        |
| 2285 | - protected function _default_event_settings_form()  | 
                                                        |
| 2286 | -    { | 
                                                        |
| 2287 | - $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2288 | - $registration_stati_for_selection = EEM_Registration::reg_status_array(  | 
                                                        |
| 2289 | - // exclude  | 
                                                        |
| 2290 | - array(  | 
                                                        |
| 2291 | - EEM_Registration::status_id_cancelled,  | 
                                                        |
| 2292 | - EEM_Registration::status_id_declined,  | 
                                                        |
| 2293 | - EEM_Registration::status_id_incomplete,  | 
                                                        |
| 2294 | - EEM_Registration::status_id_wait_list,  | 
                                                        |
| 2295 | - ),  | 
                                                        |
| 2296 | - true  | 
                                                        |
| 2297 | - );  | 
                                                        |
| 2298 | - return new EE_Form_Section_Proper(  | 
                                                        |
| 2299 | - array(  | 
                                                        |
| 2300 | - 'name' => 'update_default_event_settings',  | 
                                                        |
| 2301 | - 'html_id' => 'update_default_event_settings',  | 
                                                        |
| 2302 | - 'html_class' => 'form-table',  | 
                                                        |
| 2303 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 2304 | - 'subsections' => apply_filters(  | 
                                                        |
| 2305 | - 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',  | 
                                                        |
| 2306 | - array(  | 
                                                        |
| 2307 | - 'default_reg_status' => new EE_Select_Input(  | 
                                                        |
| 2308 | - $registration_stati_for_selection,  | 
                                                        |
| 2309 | - array(  | 
                                                        |
| 2310 | - 'default' => isset($registration_config->default_STS_ID)  | 
                                                        |
| 2311 | - && array_key_exists(  | 
                                                        |
| 2312 | - $registration_config->default_STS_ID,  | 
                                                        |
| 2313 | - $registration_stati_for_selection  | 
                                                        |
| 2314 | - )  | 
                                                        |
| 2315 | - ? sanitize_text_field($registration_config->default_STS_ID)  | 
                                                        |
| 2316 | - : EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 2317 | -                                'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') | 
                                                        |
| 2318 | - . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2319 | - 'default_settings_status_help_tab'  | 
                                                        |
| 2320 | - ),  | 
                                                        |
| 2321 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 2322 | - 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.',  | 
                                                        |
| 2323 | - 'event_espresso'  | 
                                                        |
| 2324 | - ),  | 
                                                        |
| 2325 | - )  | 
                                                        |
| 2326 | - ),  | 
                                                        |
| 2327 | - 'default_max_tickets' => new EE_Integer_Input(  | 
                                                        |
| 2328 | - array(  | 
                                                        |
| 2329 | - 'default' => isset($registration_config->default_maximum_number_of_tickets)  | 
                                                        |
| 2330 | - ? $registration_config->default_maximum_number_of_tickets  | 
                                                        |
| 2331 | - : EEM_Event::get_default_additional_limit(),  | 
                                                        |
| 2332 | - 'html_label_text' => esc_html__(  | 
                                                        |
| 2333 | - 'Default Maximum Tickets Allowed Per Order:',  | 
                                                        |
| 2334 | - 'event_espresso'  | 
                                                        |
| 2335 | - )  | 
                                                        |
| 2336 | - . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2337 | - 'default_maximum_tickets_help_tab"'  | 
                                                        |
| 2338 | - ),  | 
                                                        |
| 2339 | - 'html_help_text' => esc_html__(  | 
                                                        |
| 2340 | - 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',  | 
                                                        |
| 2341 | - 'event_espresso'  | 
                                                        |
| 2342 | - ),  | 
                                                        |
| 2343 | - )  | 
                                                        |
| 2344 | - ),  | 
                                                        |
| 2345 | - )  | 
                                                        |
| 2346 | - ),  | 
                                                        |
| 2347 | - )  | 
                                                        |
| 2348 | - );  | 
                                                        |
| 2349 | - }  | 
                                                        |
| 2350 | -  | 
                                                        |
| 2351 | -  | 
                                                        |
| 2352 | - /**  | 
                                                        |
| 2353 | - * _update_default_event_settings  | 
                                                        |
| 2354 | - *  | 
                                                        |
| 2355 | - * @access protected  | 
                                                        |
| 2356 | - * @return void  | 
                                                        |
| 2357 | - * @throws EE_Error  | 
                                                        |
| 2358 | - */  | 
                                                        |
| 2359 | - protected function _update_default_event_settings()  | 
                                                        |
| 2360 | -    { | 
                                                        |
| 2361 | - $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2362 | - $form = $this->_default_event_settings_form();  | 
                                                        |
| 2363 | -        if ($form->was_submitted()) { | 
                                                        |
| 2364 | - $form->receive_form_submission();  | 
                                                        |
| 2365 | -            if ($form->is_valid()) { | 
                                                        |
| 2366 | - $valid_data = $form->valid_data();  | 
                                                        |
| 2367 | -                if (isset($valid_data['default_reg_status'])) { | 
                                                        |
| 2368 | - $registration_config->default_STS_ID = $valid_data['default_reg_status'];  | 
                                                        |
| 2369 | - }  | 
                                                        |
| 2370 | -                if (isset($valid_data['default_max_tickets'])) { | 
                                                        |
| 2371 | - $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];  | 
                                                        |
| 2372 | - }  | 
                                                        |
| 2373 | - // update because data was valid!  | 
                                                        |
| 2374 | - EE_Registry::instance()->CFG->update_espresso_config();  | 
                                                        |
| 2375 | - EE_Error::overwrite_success();  | 
                                                        |
| 2376 | - EE_Error::add_success(  | 
                                                        |
| 2377 | -                    __('Default Event Settings were updated', 'event_espresso') | 
                                                        |
| 2378 | - );  | 
                                                        |
| 2379 | - }  | 
                                                        |
| 2380 | - }  | 
                                                        |
| 2381 | -        $this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); | 
                                                        |
| 2382 | - }  | 
                                                        |
| 2383 | -  | 
                                                        |
| 2384 | -  | 
                                                        |
| 2385 | - /************* Templates *************/  | 
                                                        |
| 2386 | - protected function _template_settings()  | 
                                                        |
| 2387 | -    { | 
                                                        |
| 2388 | -        $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); | 
                                                        |
| 2389 | - $this->_template_args['preview_img'] = '<img src="'  | 
                                                        |
| 2390 | - . EVENTS_ASSETS_URL  | 
                                                        |
| 2391 | - . DS  | 
                                                        |
| 2392 | - . 'images'  | 
                                                        |
| 2393 | - . DS  | 
                                                        |
| 2394 | - . 'caffeinated_template_features.jpg" alt="'  | 
                                                        |
| 2395 | -                                               . esc_attr__('Template Settings Preview screenshot', 'event_espresso') | 
                                                        |
| 2396 | - . '" />';  | 
                                                        |
| 2397 | - $this->_template_args['preview_text'] = '<strong>'  | 
                                                        |
| 2398 | - . esc_html__(  | 
                                                        |
| 2399 | - 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',  | 
                                                        |
| 2400 | - 'event_espresso'  | 
                                                        |
| 2401 | - ) . '</strong>';  | 
                                                        |
| 2402 | -        $this->display_admin_caf_preview_page('template_settings_tab'); | 
                                                        |
| 2403 | - }  | 
                                                        |
| 2404 | -  | 
                                                        |
| 2405 | -  | 
                                                        |
| 2406 | - /** Event Category Stuff **/  | 
                                                        |
| 2407 | - /**  | 
                                                        |
| 2408 | - * set the _category property with the category object for the loaded page.  | 
                                                        |
| 2409 | - *  | 
                                                        |
| 2410 | - * @access private  | 
                                                        |
| 2411 | - * @return void  | 
                                                        |
| 2412 | - */  | 
                                                        |
| 2413 | - private function _set_category_object()  | 
                                                        |
| 2414 | -    { | 
                                                        |
| 2415 | -        if (isset($this->_category->id) && ! empty($this->_category->id)) { | 
                                                        |
| 2416 | - return;  | 
                                                        |
| 2417 | - } //already have the category object so get out.  | 
                                                        |
| 2418 | - // set default category object  | 
                                                        |
| 2419 | - $this->_set_empty_category_object();  | 
                                                        |
| 2420 | - // only set if we've got an id  | 
                                                        |
| 2421 | -        if (! isset($this->_req_data['EVT_CAT_ID'])) { | 
                                                        |
| 2422 | - return;  | 
                                                        |
| 2423 | - }  | 
                                                        |
| 2424 | - $category_id = absint($this->_req_data['EVT_CAT_ID']);  | 
                                                        |
| 2425 | - $term = get_term($category_id, 'espresso_event_categories');  | 
                                                        |
| 2426 | -        if (! empty($term)) { | 
                                                        |
| 2427 | - $this->_category->category_name = $term->name;  | 
                                                        |
| 2428 | - $this->_category->category_identifier = $term->slug;  | 
                                                        |
| 2429 | - $this->_category->category_desc = $term->description;  | 
                                                        |
| 2430 | - $this->_category->id = $term->term_id;  | 
                                                        |
| 2431 | - $this->_category->parent = $term->parent;  | 
                                                        |
| 2432 | - }  | 
                                                        |
| 2433 | - }  | 
                                                        |
| 2434 | -  | 
                                                        |
| 2435 | -  | 
                                                        |
| 2436 | - /**  | 
                                                        |
| 2437 | - * Clears out category properties.  | 
                                                        |
| 2438 | - */  | 
                                                        |
| 2439 | - private function _set_empty_category_object()  | 
                                                        |
| 2440 | -    { | 
                                                        |
| 2441 | - $this->_category = new stdClass();  | 
                                                        |
| 2442 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';  | 
                                                        |
| 2443 | - $this->_category->id = $this->_category->parent = 0;  | 
                                                        |
| 2444 | - }  | 
                                                        |
| 2445 | -  | 
                                                        |
| 2446 | -  | 
                                                        |
| 2447 | - /**  | 
                                                        |
| 2448 | - * @throws EE_Error  | 
                                                        |
| 2449 | - */  | 
                                                        |
| 2450 | - protected function _category_list_table()  | 
                                                        |
| 2451 | -    { | 
                                                        |
| 2452 | -        do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 2453 | -        $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 2454 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 2455 | - 'add_category',  | 
                                                        |
| 2456 | - 'add_category',  | 
                                                        |
| 2457 | - array(),  | 
                                                        |
| 2458 | - 'add-new-h2'  | 
                                                        |
| 2459 | - );  | 
                                                        |
| 2460 | - $this->display_admin_list_table_page_with_sidebar();  | 
                                                        |
| 2461 | - }  | 
                                                        |
| 2462 | -  | 
                                                        |
| 2463 | -  | 
                                                        |
| 2464 | - /**  | 
                                                        |
| 2465 | - * Output category details view.  | 
                                                        |
| 2466 | - */  | 
                                                        |
| 2467 | - protected function _category_details($view)  | 
                                                        |
| 2468 | -    { | 
                                                        |
| 2469 | - // load formatter helper  | 
                                                        |
| 2470 | - // load field generator helper  | 
                                                        |
| 2471 | - $route = $view == 'edit' ? 'update_category' : 'insert_category';  | 
                                                        |
| 2472 | - $this->_set_add_edit_form_tags($route);  | 
                                                        |
| 2473 | - $this->_set_category_object();  | 
                                                        |
| 2474 | - $id = ! empty($this->_category->id) ? $this->_category->id : '';  | 
                                                        |
| 2475 | - $delete_action = 'delete_category';  | 
                                                        |
| 2476 | - // custom redirect  | 
                                                        |
| 2477 | - $redirect = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 2478 | -            array('action' => 'category_list'), | 
                                                        |
| 2479 | - $this->_admin_base_url  | 
                                                        |
| 2480 | - );  | 
                                                        |
| 2481 | -        $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); | 
                                                        |
| 2482 | - // take care of contents  | 
                                                        |
| 2483 | - $this->_template_args['admin_page_content'] = $this->_category_details_content();  | 
                                                        |
| 2484 | - $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2485 | - }  | 
                                                        |
| 2486 | -  | 
                                                        |
| 2487 | -  | 
                                                        |
| 2488 | - /**  | 
                                                        |
| 2489 | - * Output category details content.  | 
                                                        |
| 2490 | - */  | 
                                                        |
| 2491 | - protected function _category_details_content()  | 
                                                        |
| 2492 | -    { | 
                                                        |
| 2493 | - $editor_args['category_desc'] = array(  | 
                                                        |
| 2494 | - 'type' => 'wp_editor',  | 
                                                        |
| 2495 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),  | 
                                                        |
| 2496 | - 'class' => 'my_editor_custom',  | 
                                                        |
| 2497 | -            'wpeditor_args' => array('media_buttons' => false), | 
                                                        |
| 2498 | - );  | 
                                                        |
| 2499 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');  | 
                                                        |
| 2500 | - $all_terms = get_terms(  | 
                                                        |
| 2501 | -            array('espresso_event_categories'), | 
                                                        |
| 2502 | -            array('hide_empty' => 0, 'exclude' => array($this->_category->id)) | 
                                                        |
| 2503 | - );  | 
                                                        |
| 2504 | - // setup category select for term parents.  | 
                                                        |
| 2505 | - $category_select_values[] = array(  | 
                                                        |
| 2506 | -            'text' => esc_html__('No Parent', 'event_espresso'), | 
                                                        |
| 2507 | - 'id' => 0,  | 
                                                        |
| 2508 | - );  | 
                                                        |
| 2509 | -        foreach ($all_terms as $term) { | 
                                                        |
| 2510 | - $category_select_values[] = array(  | 
                                                        |
| 2511 | - 'text' => $term->name,  | 
                                                        |
| 2512 | - 'id' => $term->term_id,  | 
                                                        |
| 2513 | - );  | 
                                                        |
| 2514 | - }  | 
                                                        |
| 2515 | - $category_select = EEH_Form_Fields::select_input(  | 
                                                        |
| 2516 | - 'category_parent',  | 
                                                        |
| 2517 | - $category_select_values,  | 
                                                        |
| 2518 | - $this->_category->parent  | 
                                                        |
| 2519 | - );  | 
                                                        |
| 2520 | - $template_args = array(  | 
                                                        |
| 2521 | - 'category' => $this->_category,  | 
                                                        |
| 2522 | - 'category_select' => $category_select,  | 
                                                        |
| 2523 | -            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), | 
                                                        |
| 2524 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'],  | 
                                                        |
| 2525 | - 'disable' => '',  | 
                                                        |
| 2526 | - 'disabled_message' => false,  | 
                                                        |
| 2527 | - );  | 
                                                        |
| 2528 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';  | 
                                                        |
| 2529 | - return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 2530 | - }  | 
                                                        |
| 2531 | -  | 
                                                        |
| 2532 | -  | 
                                                        |
| 2533 | - /**  | 
                                                        |
| 2534 | - * Handles deleting categories.  | 
                                                        |
| 2535 | - */  | 
                                                        |
| 2536 | - protected function _delete_categories()  | 
                                                        |
| 2537 | -    { | 
                                                        |
| 2538 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']  | 
                                                        |
| 2539 | - : (array) $this->_req_data['category_id'];  | 
                                                        |
| 2540 | -        foreach ($cat_ids as $cat_id) { | 
                                                        |
| 2541 | - $this->_delete_category($cat_id);  | 
                                                        |
| 2542 | - }  | 
                                                        |
| 2543 | - // doesn't matter what page we're coming from... we're going to the same place after delete.  | 
                                                        |
| 2544 | - $query_args = array(  | 
                                                        |
| 2545 | - 'action' => 'category_list',  | 
                                                        |
| 2546 | - );  | 
                                                        |
| 2547 | - $this->_redirect_after_action(0, '', '', $query_args);  | 
                                                        |
| 2548 | - }  | 
                                                        |
| 2549 | -  | 
                                                        |
| 2550 | -  | 
                                                        |
| 2551 | - /**  | 
                                                        |
| 2552 | - * Handles deleting specific category.  | 
                                                        |
| 2553 | - *  | 
                                                        |
| 2554 | - * @param int $cat_id  | 
                                                        |
| 2555 | - */  | 
                                                        |
| 2556 | - protected function _delete_category($cat_id)  | 
                                                        |
| 2557 | -    { | 
                                                        |
| 2558 | - $cat_id = absint($cat_id);  | 
                                                        |
| 2559 | - wp_delete_term($cat_id, 'espresso_event_categories');  | 
                                                        |
| 2560 | - }  | 
                                                        |
| 2561 | -  | 
                                                        |
| 2562 | -  | 
                                                        |
| 2563 | - /**  | 
                                                        |
| 2564 | - * Handles triggering the update or insertion of a new category.  | 
                                                        |
| 2565 | - *  | 
                                                        |
| 2566 | - * @param bool $new_category true means we're triggering the insert of a new category.  | 
                                                        |
| 2567 | - */  | 
                                                        |
| 2568 | - protected function _insert_or_update_category($new_category)  | 
                                                        |
| 2569 | -    { | 
                                                        |
| 2570 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);  | 
                                                        |
| 2571 | - $success = 0; // we already have a success message so lets not send another.  | 
                                                        |
| 2572 | -        if ($cat_id) { | 
                                                        |
| 2573 | - $query_args = array(  | 
                                                        |
| 2574 | - 'action' => 'edit_category',  | 
                                                        |
| 2575 | - 'EVT_CAT_ID' => $cat_id,  | 
                                                        |
| 2576 | - );  | 
                                                        |
| 2577 | -        } else { | 
                                                        |
| 2578 | -            $query_args = array('action' => 'add_category'); | 
                                                        |
| 2579 | - }  | 
                                                        |
| 2580 | - $this->_redirect_after_action($success, '', '', $query_args, true);  | 
                                                        |
| 2581 | - }  | 
                                                        |
| 2582 | -  | 
                                                        |
| 2583 | -  | 
                                                        |
| 2584 | - /**  | 
                                                        |
| 2585 | - * Inserts or updates category  | 
                                                        |
| 2586 | - *  | 
                                                        |
| 2587 | - * @param bool $update (true indicates we're updating a category).  | 
                                                        |
| 2588 | - * @return bool|mixed|string  | 
                                                        |
| 2589 | - */  | 
                                                        |
| 2590 | - private function _insert_category($update = false)  | 
                                                        |
| 2591 | -    { | 
                                                        |
| 2592 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';  | 
                                                        |
| 2593 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';  | 
                                                        |
| 2594 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';  | 
                                                        |
| 2595 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;  | 
                                                        |
| 2596 | -        if (empty($category_name)) { | 
                                                        |
| 2597 | -            $msg = esc_html__('You must add a name for the category.', 'event_espresso'); | 
                                                        |
| 2598 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2599 | - return false;  | 
                                                        |
| 2600 | - }  | 
                                                        |
| 2601 | - $term_args = array(  | 
                                                        |
| 2602 | - 'name' => $category_name,  | 
                                                        |
| 2603 | - 'description' => $category_desc,  | 
                                                        |
| 2604 | - 'parent' => $category_parent,  | 
                                                        |
| 2605 | - );  | 
                                                        |
| 2606 | - // was the category_identifier input disabled?  | 
                                                        |
| 2607 | -        if (isset($this->_req_data['category_identifier'])) { | 
                                                        |
| 2608 | - $term_args['slug'] = $this->_req_data['category_identifier'];  | 
                                                        |
| 2609 | - }  | 
                                                        |
| 2610 | - $insert_ids = $update  | 
                                                        |
| 2611 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)  | 
                                                        |
| 2612 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args);  | 
                                                        |
| 2613 | -        if (! is_array($insert_ids)) { | 
                                                        |
| 2614 | - $msg = esc_html__(  | 
                                                        |
| 2615 | - 'An error occurred and the category has not been saved to the database.',  | 
                                                        |
| 2616 | - 'event_espresso'  | 
                                                        |
| 2617 | - );  | 
                                                        |
| 2618 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2619 | -        } else { | 
                                                        |
| 2620 | - $cat_id = $insert_ids['term_id'];  | 
                                                        |
| 2621 | -            $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); | 
                                                        |
| 2622 | - EE_Error::add_success($msg);  | 
                                                        |
| 2623 | - }  | 
                                                        |
| 2624 | - return $cat_id;  | 
                                                        |
| 2625 | - }  | 
                                                        |
| 2626 | -  | 
                                                        |
| 2627 | -  | 
                                                        |
| 2628 | - /**  | 
                                                        |
| 2629 | - * Gets categories or count of categories matching the arguments in the request.  | 
                                                        |
| 2630 | - *  | 
                                                        |
| 2631 | - * @param int $per_page  | 
                                                        |
| 2632 | - * @param int $current_page  | 
                                                        |
| 2633 | - * @param bool $count  | 
                                                        |
| 2634 | - * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int  | 
                                                        |
| 2635 | - */  | 
                                                        |
| 2636 | - public function get_categories($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 2637 | -    { | 
                                                        |
| 2638 | - // testing term stuff  | 
                                                        |
| 2639 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';  | 
                                                        |
| 2640 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';  | 
                                                        |
| 2641 | - $limit = ($current_page - 1) * $per_page;  | 
                                                        |
| 2642 | -        $where = array('taxonomy' => 'espresso_event_categories'); | 
                                                        |
| 2643 | -        if (isset($this->_req_data['s'])) { | 
                                                        |
| 2644 | - $sstr = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 2645 | - $where['OR'] = array(  | 
                                                        |
| 2646 | -                'Term.name'   => array('LIKE', $sstr), | 
                                                        |
| 2647 | -                'description' => array('LIKE', $sstr), | 
                                                        |
| 2648 | - );  | 
                                                        |
| 2649 | - }  | 
                                                        |
| 2650 | - $query_params = array(  | 
                                                        |
| 2651 | - $where,  | 
                                                        |
| 2652 | - 'order_by' => array($orderby => $order),  | 
                                                        |
| 2653 | - 'limit' => $limit . ',' . $per_page,  | 
                                                        |
| 2654 | -            'force_join' => array('Term'), | 
                                                        |
| 2655 | - );  | 
                                                        |
| 2656 | - $categories = $count  | 
                                                        |
| 2657 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')  | 
                                                        |
| 2658 | - : EEM_Term_Taxonomy::instance()->get_all($query_params);  | 
                                                        |
| 2659 | - return $categories;  | 
                                                        |
| 2660 | - }  | 
                                                        |
| 2661 | -  | 
                                                        |
| 2662 | - /* end category stuff */  | 
                                                        |
| 2663 | - /**************/  | 
                                                        |
| 2664 | -  | 
                                                        |
| 2665 | -  | 
                                                        |
| 2666 | - /**  | 
                                                        |
| 2667 | - * Callback for the `ee_save_timezone_setting` ajax action.  | 
                                                        |
| 2668 | - *  | 
                                                        |
| 2669 | - * @throws EE_Error  | 
                                                        |
| 2670 | - */  | 
                                                        |
| 2671 | - public function save_timezonestring_setting()  | 
                                                        |
| 2672 | -    { | 
                                                        |
| 2673 | - $timezone_string = isset($this->_req_data['timezone_selected'])  | 
                                                        |
| 2674 | - ? $this->_req_data['timezone_selected']  | 
                                                        |
| 2675 | - : '';  | 
                                                        |
| 2676 | -        if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) { | 
                                                        |
| 2677 | - EE_Error::add_error(  | 
                                                        |
| 2678 | -                esc_html__('An invalid timezone string submitted.', 'event_espresso'), | 
                                                        |
| 2679 | - __FILE__,  | 
                                                        |
| 2680 | - __FUNCTION__,  | 
                                                        |
| 2681 | - __LINE__  | 
                                                        |
| 2682 | - );  | 
                                                        |
| 2683 | - $this->_template_args['error'] = true;  | 
                                                        |
| 2684 | - $this->_return_json();  | 
                                                        |
| 2685 | - }  | 
                                                        |
| 2686 | -  | 
                                                        |
| 2687 | -        update_option('timezone_string', $timezone_string); | 
                                                        |
| 2688 | - EE_Error::add_success(  | 
                                                        |
| 2689 | -            esc_html__('Your timezone string was updated.', 'event_espresso') | 
                                                        |
| 2690 | - );  | 
                                                        |
| 2691 | - $this->_template_args['success'] = true;  | 
                                                        |
| 2692 | -        $this->_return_json(true, array('action' => 'create_new')); | 
                                                        |
| 2693 | - }  | 
                                                        |
| 577 | + }  | 
                                                        |
| 578 | + }  | 
                                                        |
| 579 | + );  | 
                                                        |
| 580 | + }  | 
                                                        |
| 581 | +  | 
                                                        |
| 582 | +  | 
                                                        |
| 583 | + /**  | 
                                                        |
| 584 | + * Enqueuing scripts and styles specific to this view  | 
                                                        |
| 585 | + */  | 
                                                        |
| 586 | + public function load_scripts_styles_create_new()  | 
                                                        |
| 587 | +	{ | 
                                                        |
| 588 | + $this->load_scripts_styles_edit();  | 
                                                        |
| 589 | + }  | 
                                                        |
| 590 | +  | 
                                                        |
| 591 | +  | 
                                                        |
| 592 | + /**  | 
                                                        |
| 593 | + * Enqueuing scripts and styles specific to this view  | 
                                                        |
| 594 | + */  | 
                                                        |
| 595 | + public function load_scripts_styles_edit()  | 
                                                        |
| 596 | +	{ | 
                                                        |
| 597 | + // styles  | 
                                                        |
| 598 | +		wp_enqueue_style('espresso-ui-theme'); | 
                                                        |
| 599 | + wp_register_style(  | 
                                                        |
| 600 | + 'event-editor-css',  | 
                                                        |
| 601 | + EVENTS_ASSETS_URL . 'event-editor.css',  | 
                                                        |
| 602 | +			array('ee-admin-css'), | 
                                                        |
| 603 | + EVENT_ESPRESSO_VERSION  | 
                                                        |
| 604 | + );  | 
                                                        |
| 605 | +		wp_enqueue_style('event-editor-css'); | 
                                                        |
| 606 | + // scripts  | 
                                                        |
| 607 | + wp_register_script(  | 
                                                        |
| 608 | + 'event-datetime-metabox',  | 
                                                        |
| 609 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js',  | 
                                                        |
| 610 | +			array('event_editor_js', 'ee-datepicker'), | 
                                                        |
| 611 | + EVENT_ESPRESSO_VERSION  | 
                                                        |
| 612 | + );  | 
                                                        |
| 613 | +		wp_enqueue_script('event-datetime-metabox'); | 
                                                        |
| 614 | + }  | 
                                                        |
| 615 | +  | 
                                                        |
| 616 | +  | 
                                                        |
| 617 | + /**  | 
                                                        |
| 618 | + * Populating the _views property for the category list table view.  | 
                                                        |
| 619 | + */  | 
                                                        |
| 620 | + protected function _set_list_table_views_category_list()  | 
                                                        |
| 621 | +	{ | 
                                                        |
| 622 | + $this->_views = array(  | 
                                                        |
| 623 | + 'all' => array(  | 
                                                        |
| 624 | + 'slug' => 'all',  | 
                                                        |
| 625 | +				'label'       => esc_html__('All', 'event_espresso'), | 
                                                        |
| 626 | + 'count' => 0,  | 
                                                        |
| 627 | + 'bulk_action' => array(  | 
                                                        |
| 628 | +					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), | 
                                                        |
| 629 | + ),  | 
                                                        |
| 630 | + ),  | 
                                                        |
| 631 | + );  | 
                                                        |
| 632 | + }  | 
                                                        |
| 633 | +  | 
                                                        |
| 634 | +  | 
                                                        |
| 635 | + /**  | 
                                                        |
| 636 | + * For adding anything that fires on the admin_init hook for any route within this admin page group.  | 
                                                        |
| 637 | + */  | 
                                                        |
| 638 | + public function admin_init()  | 
                                                        |
| 639 | +	{ | 
                                                        |
| 640 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__(  | 
                                                        |
| 641 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.',  | 
                                                        |
| 642 | + 'event_espresso'  | 
                                                        |
| 643 | + );  | 
                                                        |
| 644 | + }  | 
                                                        |
| 645 | +  | 
                                                        |
| 646 | +  | 
                                                        |
| 647 | + /**  | 
                                                        |
| 648 | + * For adding anything that should be triggered on the admin_notices hook for any route within this admin page  | 
                                                        |
| 649 | + * group.  | 
                                                        |
| 650 | + */  | 
                                                        |
| 651 | + public function admin_notices()  | 
                                                        |
| 652 | +	{ | 
                                                        |
| 653 | + }  | 
                                                        |
| 654 | +  | 
                                                        |
| 655 | +  | 
                                                        |
| 656 | + /**  | 
                                                        |
| 657 | + * For adding anything that should be triggered on the `admin_print_footer_scripts` hook for any route within  | 
                                                        |
| 658 | + * this admin page group.  | 
                                                        |
| 659 | + */  | 
                                                        |
| 660 | + public function admin_footer_scripts()  | 
                                                        |
| 661 | +	{ | 
                                                        |
| 662 | + }  | 
                                                        |
| 663 | +  | 
                                                        |
| 664 | +  | 
                                                        |
| 665 | + /**  | 
                                                        |
| 666 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a  | 
                                                        |
| 667 | + * warning (via EE_Error::add_error());  | 
                                                        |
| 668 | + *  | 
                                                        |
| 669 | + * @param EE_Event $event Event object  | 
                                                        |
| 670 | + * @param string $req_type  | 
                                                        |
| 671 | + * @return void  | 
                                                        |
| 672 | + * @throws EE_Error  | 
                                                        |
| 673 | + * @access public  | 
                                                        |
| 674 | + */  | 
                                                        |
| 675 | + public function verify_event_edit($event = null, $req_type = '')  | 
                                                        |
| 676 | +	{ | 
                                                        |
| 677 | + // don't need to do this when processing  | 
                                                        |
| 678 | +		if (! empty($req_type)) { | 
                                                        |
| 679 | + return;  | 
                                                        |
| 680 | + }  | 
                                                        |
| 681 | + // no event?  | 
                                                        |
| 682 | +		if (empty($event)) { | 
                                                        |
| 683 | + // set event  | 
                                                        |
| 684 | + $event = $this->_cpt_model_obj;  | 
                                                        |
| 685 | + }  | 
                                                        |
| 686 | + // STILL no event?  | 
                                                        |
| 687 | +		if (! $event instanceof EE_Event) { | 
                                                        |
| 688 | + return;  | 
                                                        |
| 689 | + }  | 
                                                        |
| 690 | + $orig_status = $event->status();  | 
                                                        |
| 691 | + // first check if event is active.  | 
                                                        |
| 692 | + if ($orig_status === EEM_Event::cancelled  | 
                                                        |
| 693 | + || $orig_status === EEM_Event::postponed  | 
                                                        |
| 694 | + || $event->is_expired()  | 
                                                        |
| 695 | + || $event->is_inactive()  | 
                                                        |
| 696 | +		) { | 
                                                        |
| 697 | + return;  | 
                                                        |
| 698 | + }  | 
                                                        |
| 699 | + // made it here so it IS active... next check that any of the tickets are sold.  | 
                                                        |
| 700 | +		if ($event->is_sold_out(true)) { | 
                                                        |
| 701 | +			if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { | 
                                                        |
| 702 | + EE_Error::add_attention(  | 
                                                        |
| 703 | + sprintf(  | 
                                                        |
| 704 | + esc_html__(  | 
                                                        |
| 705 | + '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.',  | 
                                                        |
| 706 | + 'event_espresso'  | 
                                                        |
| 707 | + ),  | 
                                                        |
| 708 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence')  | 
                                                        |
| 709 | + )  | 
                                                        |
| 710 | + );  | 
                                                        |
| 711 | + }  | 
                                                        |
| 712 | + return;  | 
                                                        |
| 713 | +		} elseif ($orig_status === EEM_Event::sold_out) { | 
                                                        |
| 714 | + EE_Error::add_attention(  | 
                                                        |
| 715 | + sprintf(  | 
                                                        |
| 716 | + esc_html__(  | 
                                                        |
| 717 | + '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.',  | 
                                                        |
| 718 | + 'event_espresso'  | 
                                                        |
| 719 | + ),  | 
                                                        |
| 720 | + EEH_Template::pretty_status($event->status(), false, 'sentence')  | 
                                                        |
| 721 | + )  | 
                                                        |
| 722 | + );  | 
                                                        |
| 723 | + }  | 
                                                        |
| 724 | + // now we need to determine if the event has any tickets on sale. If not then we dont' show the error  | 
                                                        |
| 725 | +		if (! $event->tickets_on_sale()) { | 
                                                        |
| 726 | + return;  | 
                                                        |
| 727 | + }  | 
                                                        |
| 728 | + // made it here so show warning  | 
                                                        |
| 729 | + $this->_edit_event_warning();  | 
                                                        |
| 730 | + }  | 
                                                        |
| 731 | +  | 
                                                        |
| 732 | +  | 
                                                        |
| 733 | + /**  | 
                                                        |
| 734 | + * This is the text used for when an event is being edited that is public and has tickets for sale.  | 
                                                        |
| 735 | + * When needed, hook this into a EE_Error::add_error() notice.  | 
                                                        |
| 736 | + *  | 
                                                        |
| 737 | + * @access protected  | 
                                                        |
| 738 | + * @return void  | 
                                                        |
| 739 | + */  | 
                                                        |
| 740 | + protected function _edit_event_warning()  | 
                                                        |
| 741 | +	{ | 
                                                        |
| 742 | + // we don't want to add warnings during these requests  | 
                                                        |
| 743 | +		if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { | 
                                                        |
| 744 | + return;  | 
                                                        |
| 745 | + }  | 
                                                        |
| 746 | + EE_Error::add_attention(  | 
                                                        |
| 747 | + sprintf(  | 
                                                        |
| 748 | + esc_html__(  | 
                                                        |
| 749 | + 'Your event is open for registration. Making changes may disrupt any transactions in progress. %sLearn more%s',  | 
                                                        |
| 750 | + 'event_espresso'  | 
                                                        |
| 751 | + ),  | 
                                                        |
| 752 | + '<a class="espresso-help-tab-lnk">',  | 
                                                        |
| 753 | + '</a>'  | 
                                                        |
| 754 | + )  | 
                                                        |
| 755 | + );  | 
                                                        |
| 756 | + }  | 
                                                        |
| 757 | +  | 
                                                        |
| 758 | +  | 
                                                        |
| 759 | + /**  | 
                                                        |
| 760 | + * When a user is creating a new event, notify them if they haven't set their timezone.  | 
                                                        |
| 761 | + * Otherwise, do the normal logic  | 
                                                        |
| 762 | + *  | 
                                                        |
| 763 | + * @return string  | 
                                                        |
| 764 | + * @throws \EE_Error  | 
                                                        |
| 765 | + */  | 
                                                        |
| 766 | + protected function _create_new_cpt_item()  | 
                                                        |
| 767 | +	{ | 
                                                        |
| 768 | +		$has_timezone_string = get_option('timezone_string'); | 
                                                        |
| 769 | + // only nag them about setting their timezone if it's their first event, and they haven't already done it  | 
                                                        |
| 770 | +		if (! $has_timezone_string && ! EEM_Event::instance()->exists(array())) { | 
                                                        |
| 771 | + EE_Error::add_attention(  | 
                                                        |
| 772 | + sprintf(  | 
                                                        |
| 773 | + __(  | 
                                                        |
| 774 | + 'Your website\'s timezone is currently set to a UTC offset. We recommend updating your timezone to a city or region near you before you create an event. Change your timezone now:%1$s%2$s%3$sChange Timezone%4$s',  | 
                                                        |
| 775 | + 'event_espresso'  | 
                                                        |
| 776 | + ),  | 
                                                        |
| 777 | + '<br>',  | 
                                                        |
| 778 | + '<select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">'  | 
                                                        |
| 779 | +					. EEH_DTT_Helper::wp_timezone_choice('', EEH_DTT_Helper::get_user_locale()) | 
                                                        |
| 780 | + . '</select>',  | 
                                                        |
| 781 | + '<button class="button button-secondary timezone-submit">',  | 
                                                        |
| 782 | + '</button><span class="spinner"></span>'  | 
                                                        |
| 783 | + ),  | 
                                                        |
| 784 | + __FILE__,  | 
                                                        |
| 785 | + __FUNCTION__,  | 
                                                        |
| 786 | + __LINE__  | 
                                                        |
| 787 | + );  | 
                                                        |
| 788 | + }  | 
                                                        |
| 789 | + return parent::_create_new_cpt_item();  | 
                                                        |
| 790 | + }  | 
                                                        |
| 791 | +  | 
                                                        |
| 792 | +  | 
                                                        |
| 793 | + /**  | 
                                                        |
| 794 | + * Sets the _views property for the default route in this admin page group.  | 
                                                        |
| 795 | + */  | 
                                                        |
| 796 | + protected function _set_list_table_views_default()  | 
                                                        |
| 797 | +	{ | 
                                                        |
| 798 | + $this->_views = array(  | 
                                                        |
| 799 | + 'all' => array(  | 
                                                        |
| 800 | + 'slug' => 'all',  | 
                                                        |
| 801 | +				'label'       => esc_html__('View All Events', 'event_espresso'), | 
                                                        |
| 802 | + 'count' => 0,  | 
                                                        |
| 803 | + 'bulk_action' => array(  | 
                                                        |
| 804 | +					'trash_events' => esc_html__('Move to Trash', 'event_espresso'), | 
                                                        |
| 805 | + ),  | 
                                                        |
| 806 | + ),  | 
                                                        |
| 807 | + 'draft' => array(  | 
                                                        |
| 808 | + 'slug' => 'draft',  | 
                                                        |
| 809 | +				'label'       => esc_html__('Draft', 'event_espresso'), | 
                                                        |
| 810 | + 'count' => 0,  | 
                                                        |
| 811 | + 'bulk_action' => array(  | 
                                                        |
| 812 | +					'trash_events' => esc_html__('Move to Trash', 'event_espresso'), | 
                                                        |
| 813 | + ),  | 
                                                        |
| 814 | + ),  | 
                                                        |
| 815 | + );  | 
                                                        |
| 816 | +		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { | 
                                                        |
| 817 | + $this->_views['trash'] = array(  | 
                                                        |
| 818 | + 'slug' => 'trash',  | 
                                                        |
| 819 | +				'label'       => esc_html__('Trash', 'event_espresso'), | 
                                                        |
| 820 | + 'count' => 0,  | 
                                                        |
| 821 | + 'bulk_action' => array(  | 
                                                        |
| 822 | +					'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), | 
                                                        |
| 823 | +					'delete_events'  => esc_html__('Delete Permanently', 'event_espresso'), | 
                                                        |
| 824 | + ),  | 
                                                        |
| 825 | + );  | 
                                                        |
| 826 | + }  | 
                                                        |
| 827 | + }  | 
                                                        |
| 828 | +  | 
                                                        |
| 829 | +  | 
                                                        |
| 830 | + /**  | 
                                                        |
| 831 | + * Provides the legend item array for the default list table view.  | 
                                                        |
| 832 | + *  | 
                                                        |
| 833 | + * @return array  | 
                                                        |
| 834 | + */  | 
                                                        |
| 835 | + protected function _event_legend_items()  | 
                                                        |
| 836 | +	{ | 
                                                        |
| 837 | + $items = array(  | 
                                                        |
| 838 | + 'view_details' => array(  | 
                                                        |
| 839 | + 'class' => 'dashicons dashicons-search',  | 
                                                        |
| 840 | +				'desc'  => esc_html__('View Event', 'event_espresso'), | 
                                                        |
| 841 | + ),  | 
                                                        |
| 842 | + 'edit_event' => array(  | 
                                                        |
| 843 | + 'class' => 'ee-icon ee-icon-calendar-edit',  | 
                                                        |
| 844 | +				'desc'  => esc_html__('Edit Event Details', 'event_espresso'), | 
                                                        |
| 845 | + ),  | 
                                                        |
| 846 | + 'view_attendees' => array(  | 
                                                        |
| 847 | + 'class' => 'dashicons dashicons-groups',  | 
                                                        |
| 848 | +				'desc'  => esc_html__('View Registrations for Event', 'event_espresso'), | 
                                                        |
| 849 | + ),  | 
                                                        |
| 850 | + );  | 
                                                        |
| 851 | +		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); | 
                                                        |
| 852 | + $statuses = array(  | 
                                                        |
| 853 | + 'sold_out_status' => array(  | 
                                                        |
| 854 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,  | 
                                                        |
| 855 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'),  | 
                                                        |
| 856 | + ),  | 
                                                        |
| 857 | + 'active_status' => array(  | 
                                                        |
| 858 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,  | 
                                                        |
| 859 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'),  | 
                                                        |
| 860 | + ),  | 
                                                        |
| 861 | + 'upcoming_status' => array(  | 
                                                        |
| 862 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,  | 
                                                        |
| 863 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'),  | 
                                                        |
| 864 | + ),  | 
                                                        |
| 865 | + 'postponed_status' => array(  | 
                                                        |
| 866 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,  | 
                                                        |
| 867 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'),  | 
                                                        |
| 868 | + ),  | 
                                                        |
| 869 | + 'cancelled_status' => array(  | 
                                                        |
| 870 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,  | 
                                                        |
| 871 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'),  | 
                                                        |
| 872 | + ),  | 
                                                        |
| 873 | + 'expired_status' => array(  | 
                                                        |
| 874 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,  | 
                                                        |
| 875 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'),  | 
                                                        |
| 876 | + ),  | 
                                                        |
| 877 | + 'inactive_status' => array(  | 
                                                        |
| 878 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,  | 
                                                        |
| 879 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'),  | 
                                                        |
| 880 | + ),  | 
                                                        |
| 881 | + );  | 
                                                        |
| 882 | +		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); | 
                                                        |
| 883 | + return array_merge($items, $statuses);  | 
                                                        |
| 884 | + }  | 
                                                        |
| 885 | +  | 
                                                        |
| 886 | +  | 
                                                        |
| 887 | + /**  | 
                                                        |
| 888 | + * @return EEM_Event  | 
                                                        |
| 889 | + */  | 
                                                        |
| 890 | + private function _event_model()  | 
                                                        |
| 891 | +	{ | 
                                                        |
| 892 | +		if (! $this->_event_model instanceof EEM_Event) { | 
                                                        |
| 893 | +			$this->_event_model = EE_Registry::instance()->load_model('Event'); | 
                                                        |
| 894 | + }  | 
                                                        |
| 895 | + return $this->_event_model;  | 
                                                        |
| 896 | + }  | 
                                                        |
| 897 | +  | 
                                                        |
| 898 | +  | 
                                                        |
| 899 | + /**  | 
                                                        |
| 900 | + * Adds extra buttons to the WP CPT permalink field row.  | 
                                                        |
| 901 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.  | 
                                                        |
| 902 | + *  | 
                                                        |
| 903 | + * @param string $return the current html  | 
                                                        |
| 904 | + * @param int $id the post id for the page  | 
                                                        |
| 905 | + * @param string $new_title What the title is  | 
                                                        |
| 906 | + * @param string $new_slug what the slug is  | 
                                                        |
| 907 | + * @return string The new html string for the permalink area  | 
                                                        |
| 908 | + */  | 
                                                        |
| 909 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)  | 
                                                        |
| 910 | +	{ | 
                                                        |
| 911 | + // make sure this is only when editing  | 
                                                        |
| 912 | +		if (! empty($id)) { | 
                                                        |
| 913 | + $post = get_post($id);  | 
                                                        |
| 914 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">'  | 
                                                        |
| 915 | +					   . esc_html__('Shortcode', 'event_espresso') | 
                                                        |
| 916 | + . '</a> ';  | 
                                                        |
| 917 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='  | 
                                                        |
| 918 | + . $post->ID  | 
                                                        |
| 919 | + . ']">';  | 
                                                        |
| 920 | + }  | 
                                                        |
| 921 | + return $return;  | 
                                                        |
| 922 | + }  | 
                                                        |
| 923 | +  | 
                                                        |
| 924 | +  | 
                                                        |
| 925 | + /**  | 
                                                        |
| 926 | + * _events_overview_list_table  | 
                                                        |
| 927 | + * This contains the logic for showing the events_overview list  | 
                                                        |
| 928 | + *  | 
                                                        |
| 929 | + * @access protected  | 
                                                        |
| 930 | + * @return void  | 
                                                        |
| 931 | + * @throws \EE_Error  | 
                                                        |
| 932 | + */  | 
                                                        |
| 933 | + protected function _events_overview_list_table()  | 
                                                        |
| 934 | +	{ | 
                                                        |
| 935 | +		do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 936 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table'])  | 
                                                        |
| 937 | + ? (array) $this->_template_args['after_list_table']  | 
                                                        |
| 938 | + : array();  | 
                                                        |
| 939 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br()  | 
                                                        |
| 940 | + . EEH_Template::get_button_or_link(  | 
                                                        |
| 941 | +					get_post_type_archive_link('espresso_events'), | 
                                                        |
| 942 | +					esc_html__("View Event Archive Page", "event_espresso"), | 
                                                        |
| 943 | + 'button'  | 
                                                        |
| 944 | + );  | 
                                                        |
| 945 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items());  | 
                                                        |
| 946 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 947 | + 'create_new',  | 
                                                        |
| 948 | + 'add',  | 
                                                        |
| 949 | + array(),  | 
                                                        |
| 950 | + 'add-new-h2'  | 
                                                        |
| 951 | + );  | 
                                                        |
| 952 | + $this->display_admin_list_table_page_with_no_sidebar();  | 
                                                        |
| 953 | + }  | 
                                                        |
| 954 | +  | 
                                                        |
| 955 | +  | 
                                                        |
| 956 | + /**  | 
                                                        |
| 957 | + * this allows for extra misc actions in the default WP publish box  | 
                                                        |
| 958 | + *  | 
                                                        |
| 959 | + * @return void  | 
                                                        |
| 960 | + */  | 
                                                        |
| 961 | + public function extra_misc_actions_publish_box()  | 
                                                        |
| 962 | +	{ | 
                                                        |
| 963 | + $this->_generate_publish_box_extra_content();  | 
                                                        |
| 964 | + }  | 
                                                        |
| 965 | +  | 
                                                        |
| 966 | +  | 
                                                        |
| 967 | + /**  | 
                                                        |
| 968 | +	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been | 
                                                        |
| 969 | + * saved.  | 
                                                        |
| 970 | + * Typically you would use this to save any additional data.  | 
                                                        |
| 971 | + * Keep in mind also that "save_post" runs on EVERY post update to the database.  | 
                                                        |
| 972 | + * ALSO very important. When a post transitions from scheduled to published,  | 
                                                        |
| 973 | + * the save_post action is fired but you will NOT have any _POST data containing any extra info you may have from  | 
                                                        |
| 974 | + * other meta saves. So MAKE sure that you handle this accordingly.  | 
                                                        |
| 975 | + *  | 
                                                        |
| 976 | + * @access protected  | 
                                                        |
| 977 | + * @abstract  | 
                                                        |
| 978 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally)  | 
                                                        |
| 979 | + * @param object $post The post object of the cpt that was saved.  | 
                                                        |
| 980 | + * @return void  | 
                                                        |
| 981 | + * @throws \EE_Error  | 
                                                        |
| 982 | + */  | 
                                                        |
| 983 | + protected function _insert_update_cpt_item($post_id, $post)  | 
                                                        |
| 984 | +	{ | 
                                                        |
| 985 | +		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { | 
                                                        |
| 986 | + // get out we're not processing an event save.  | 
                                                        |
| 987 | + return;  | 
                                                        |
| 988 | + }  | 
                                                        |
| 989 | + $event_values = array(  | 
                                                        |
| 990 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,  | 
                                                        |
| 991 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,  | 
                                                        |
| 992 | + 'EVT_additional_limit' => min(  | 
                                                        |
| 993 | +				apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), | 
                                                        |
| 994 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null  | 
                                                        |
| 995 | + ),  | 
                                                        |
| 996 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status'])  | 
                                                        |
| 997 | + ? $this->_req_data['EVT_default_registration_status']  | 
                                                        |
| 998 | + : EE_Registry::instance()->CFG->registration->default_STS_ID,  | 
                                                        |
| 999 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,  | 
                                                        |
| 1000 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,  | 
                                                        |
| 1001 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string'])  | 
                                                        |
| 1002 | + ? $this->_req_data['timezone_string'] : null,  | 
                                                        |
| 1003 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL'])  | 
                                                        |
| 1004 | + ? $this->_req_data['externalURL'] : null,  | 
                                                        |
| 1005 | + 'EVT_phone' => ! empty($this->_req_data['event_phone'])  | 
                                                        |
| 1006 | + ? $this->_req_data['event_phone'] : null,  | 
                                                        |
| 1007 | + );  | 
                                                        |
| 1008 | + // update event  | 
                                                        |
| 1009 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id);  | 
                                                        |
| 1010 | + // 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!  | 
                                                        |
| 1011 | + $get_one_where = array(  | 
                                                        |
| 1012 | + $this->_event_model()->primary_key_name() => $post_id,  | 
                                                        |
| 1013 | + 'OR' => array(  | 
                                                        |
| 1014 | + 'status' => $post->post_status,  | 
                                                        |
| 1015 | + // if trying to "Publish" a sold out event, it's status will get switched back to "sold_out" in the db,  | 
                                                        |
| 1016 | + // but the returned object here has a status of "publish", so use the original post status as well  | 
                                                        |
| 1017 | + 'status*1' => $this->_req_data['original_post_status'],  | 
                                                        |
| 1018 | + ),  | 
                                                        |
| 1019 | + );  | 
                                                        |
| 1020 | + $event = $this->_event_model()->get_one(array($get_one_where));  | 
                                                        |
| 1021 | + // the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.  | 
                                                        |
| 1022 | + $event_update_callbacks = apply_filters(  | 
                                                        |
| 1023 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',  | 
                                                        |
| 1024 | + array(  | 
                                                        |
| 1025 | + array($this, '_default_venue_update'),  | 
                                                        |
| 1026 | + array($this, '_default_tickets_update'),  | 
                                                        |
| 1027 | + )  | 
                                                        |
| 1028 | + );  | 
                                                        |
| 1029 | + $att_success = true;  | 
                                                        |
| 1030 | +		foreach ($event_update_callbacks as $e_callback) { | 
                                                        |
| 1031 | + $_success = is_callable($e_callback)  | 
                                                        |
| 1032 | + ? call_user_func($e_callback, $event, $this->_req_data)  | 
                                                        |
| 1033 | + : false;  | 
                                                        |
| 1034 | + // if ANY of these updates fail then we want the appropriate global error message  | 
                                                        |
| 1035 | + $att_success = ! $att_success ? $att_success : $_success;  | 
                                                        |
| 1036 | + }  | 
                                                        |
| 1037 | + // any errors?  | 
                                                        |
| 1038 | +		if ($success && false === $att_success) { | 
                                                        |
| 1039 | + EE_Error::add_error(  | 
                                                        |
| 1040 | + esc_html__(  | 
                                                        |
| 1041 | + 'Event Details saved successfully but something went wrong with saving attachments.',  | 
                                                        |
| 1042 | + 'event_espresso'  | 
                                                        |
| 1043 | + ),  | 
                                                        |
| 1044 | + __FILE__,  | 
                                                        |
| 1045 | + __FUNCTION__,  | 
                                                        |
| 1046 | + __LINE__  | 
                                                        |
| 1047 | + );  | 
                                                        |
| 1048 | +		} elseif ($success === false) { | 
                                                        |
| 1049 | + EE_Error::add_error(  | 
                                                        |
| 1050 | +				esc_html__('Event Details did not save successfully.', 'event_espresso'), | 
                                                        |
| 1051 | + __FILE__,  | 
                                                        |
| 1052 | + __FUNCTION__,  | 
                                                        |
| 1053 | + __LINE__  | 
                                                        |
| 1054 | + );  | 
                                                        |
| 1055 | + }  | 
                                                        |
| 1056 | + }  | 
                                                        |
| 1057 | +  | 
                                                        |
| 1058 | +  | 
                                                        |
| 1059 | + /**  | 
                                                        |
| 1060 | + * @see parent::restore_item()  | 
                                                        |
| 1061 | + * @param int $post_id  | 
                                                        |
| 1062 | + * @param int $revision_id  | 
                                                        |
| 1063 | + */  | 
                                                        |
| 1064 | + protected function _restore_cpt_item($post_id, $revision_id)  | 
                                                        |
| 1065 | +	{ | 
                                                        |
| 1066 | + // copy existing event meta to new post  | 
                                                        |
| 1067 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id);  | 
                                                        |
| 1068 | +		if ($post_evt instanceof EE_Event) { | 
                                                        |
| 1069 | + // meta revision restore  | 
                                                        |
| 1070 | + $post_evt->restore_revision($revision_id);  | 
                                                        |
| 1071 | + // related objs restore  | 
                                                        |
| 1072 | +			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); | 
                                                        |
| 1073 | + }  | 
                                                        |
| 1074 | + }  | 
                                                        |
| 1075 | +  | 
                                                        |
| 1076 | +  | 
                                                        |
| 1077 | + /**  | 
                                                        |
| 1078 | + * Attach the venue to the Event  | 
                                                        |
| 1079 | + *  | 
                                                        |
| 1080 | + * @param \EE_Event $evtobj Event Object to add the venue to  | 
                                                        |
| 1081 | + * @param array $data The request data from the form  | 
                                                        |
| 1082 | + * @return bool Success or fail.  | 
                                                        |
| 1083 | + */  | 
                                                        |
| 1084 | + protected function _default_venue_update(\EE_Event $evtobj, $data)  | 
                                                        |
| 1085 | +	{ | 
                                                        |
| 1086 | + require_once(EE_MODELS . 'EEM_Venue.model.php');  | 
                                                        |
| 1087 | +		$venue_model = EE_Registry::instance()->load_model('Venue'); | 
                                                        |
| 1088 | + $rows_affected = null;  | 
                                                        |
| 1089 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null;  | 
                                                        |
| 1090 | + // very important. If we don't have a venue name...  | 
                                                        |
| 1091 | + // then we'll get out because not necessary to create empty venue  | 
                                                        |
| 1092 | +		if (empty($data['venue_title'])) { | 
                                                        |
| 1093 | + return false;  | 
                                                        |
| 1094 | + }  | 
                                                        |
| 1095 | + $venue_array = array(  | 
                                                        |
| 1096 | +			'VNU_wp_user'         => $evtobj->get('EVT_wp_user'), | 
                                                        |
| 1097 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null,  | 
                                                        |
| 1098 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null,  | 
                                                        |
| 1099 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null,  | 
                                                        |
| 1100 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description']  | 
                                                        |
| 1101 | + : null,  | 
                                                        |
| 1102 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null,  | 
                                                        |
| 1103 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null,  | 
                                                        |
| 1104 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null,  | 
                                                        |
| 1105 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null,  | 
                                                        |
| 1106 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null,  | 
                                                        |
| 1107 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null,  | 
                                                        |
| 1108 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null,  | 
                                                        |
| 1109 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null,  | 
                                                        |
| 1110 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null,  | 
                                                        |
| 1111 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null,  | 
                                                        |
| 1112 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null,  | 
                                                        |
| 1113 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,  | 
                                                        |
| 1114 | + 'status' => 'publish',  | 
                                                        |
| 1115 | + );  | 
                                                        |
| 1116 | + // if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.  | 
                                                        |
| 1117 | +		if (! empty($venue_id)) { | 
                                                        |
| 1118 | + $update_where = array($venue_model->primary_key_name() => $venue_id);  | 
                                                        |
| 1119 | + $rows_affected = $venue_model->update($venue_array, array($update_where));  | 
                                                        |
| 1120 | + // 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.  | 
                                                        |
| 1121 | + $evtobj->_add_relation_to($venue_id, 'Venue');  | 
                                                        |
| 1122 | + return $rows_affected > 0 ? true : false;  | 
                                                        |
| 1123 | +		} else { | 
                                                        |
| 1124 | + // we insert the venue  | 
                                                        |
| 1125 | + $venue_id = $venue_model->insert($venue_array);  | 
                                                        |
| 1126 | + $evtobj->_add_relation_to($venue_id, 'Venue');  | 
                                                        |
| 1127 | + return ! empty($venue_id) ? true : false;  | 
                                                        |
| 1128 | + }  | 
                                                        |
| 1129 | + // when we have the ancestor come in it's already been handled by the revision save.  | 
                                                        |
| 1130 | + }  | 
                                                        |
| 1131 | +  | 
                                                        |
| 1132 | +  | 
                                                        |
| 1133 | + /**  | 
                                                        |
| 1134 | + * Handles saving everything related to Tickets (datetimes, tickets, prices)  | 
                                                        |
| 1135 | + *  | 
                                                        |
| 1136 | + * @param EE_Event $evtobj The Event object we're attaching data to  | 
                                                        |
| 1137 | + * @param array $data The request data from the form  | 
                                                        |
| 1138 | + * @return array  | 
                                                        |
| 1139 | + */  | 
                                                        |
| 1140 | + protected function _default_tickets_update(EE_Event $evtobj, $data)  | 
                                                        |
| 1141 | +	{ | 
                                                        |
| 1142 | + $success = true;  | 
                                                        |
| 1143 | + $saved_dtt = null;  | 
                                                        |
| 1144 | + $saved_tickets = array();  | 
                                                        |
| 1145 | +		$incoming_date_formats = array('Y-m-d', 'h:i a'); | 
                                                        |
| 1146 | +		foreach ($data['edit_event_datetimes'] as $row => $dtt) { | 
                                                        |
| 1147 | + // trim all values to ensure any excess whitespace is removed.  | 
                                                        |
| 1148 | +			$dtt = array_map('trim', $dtt); | 
                                                        |
| 1149 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end']  | 
                                                        |
| 1150 | + : $dtt['DTT_EVT_start'];  | 
                                                        |
| 1151 | + $datetime_values = array(  | 
                                                        |
| 1152 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null,  | 
                                                        |
| 1153 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'],  | 
                                                        |
| 1154 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'],  | 
                                                        |
| 1155 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],  | 
                                                        |
| 1156 | + 'DTT_order' => $row,  | 
                                                        |
| 1157 | + );  | 
                                                        |
| 1158 | + // 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.  | 
                                                        |
| 1159 | +			if (! empty($dtt['DTT_ID'])) { | 
                                                        |
| 1160 | + $DTM = EE_Registry::instance()  | 
                                                        |
| 1161 | +								  ->load_model('Datetime', array($evtobj->get_timezone())) | 
                                                        |
| 1162 | + ->get_one_by_ID($dtt['DTT_ID']);  | 
                                                        |
| 1163 | + $DTM->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1164 | + $DTM->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1165 | +				foreach ($datetime_values as $field => $value) { | 
                                                        |
| 1166 | + $DTM->set($field, $value);  | 
                                                        |
| 1167 | + }  | 
                                                        |
| 1168 | + // 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.  | 
                                                        |
| 1169 | + $saved_dtts[ $DTM->ID() ] = $DTM;  | 
                                                        |
| 1170 | +			} else { | 
                                                        |
| 1171 | + $DTM = EE_Registry::instance()->load_class(  | 
                                                        |
| 1172 | + 'Datetime',  | 
                                                        |
| 1173 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats),  | 
                                                        |
| 1174 | + false,  | 
                                                        |
| 1175 | + false  | 
                                                        |
| 1176 | + );  | 
                                                        |
| 1177 | +				foreach ($datetime_values as $field => $value) { | 
                                                        |
| 1178 | + $DTM->set($field, $value);  | 
                                                        |
| 1179 | + }  | 
                                                        |
| 1180 | + }  | 
                                                        |
| 1181 | + $DTM->save();  | 
                                                        |
| 1182 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime');  | 
                                                        |
| 1183 | + // load DTT helper  | 
                                                        |
| 1184 | + // 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.  | 
                                                        |
| 1185 | +			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { | 
                                                        |
| 1186 | +				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); | 
                                                        |
| 1187 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');  | 
                                                        |
| 1188 | + $DTT->save();  | 
                                                        |
| 1189 | + }  | 
                                                        |
| 1190 | + // 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.  | 
                                                        |
| 1191 | + $saved_dtt = $DTT;  | 
                                                        |
| 1192 | + $success = ! $success ? $success : $DTT;  | 
                                                        |
| 1193 | + // if ANY of these updates fail then we want the appropriate global error message.  | 
                                                        |
| 1194 | + // //todo this is actually sucky we need a better error message but this is what it is for now.  | 
                                                        |
| 1195 | + }  | 
                                                        |
| 1196 | + // no dtts get deleted so we don't do any of that logic here.  | 
                                                        |
| 1197 | + // update tickets next  | 
                                                        |
| 1198 | +		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); | 
                                                        |
| 1199 | +		foreach ($data['edit_tickets'] as $row => $tkt) { | 
                                                        |
| 1200 | +			$incoming_date_formats = array('Y-m-d', 'h:i a'); | 
                                                        |
| 1201 | + $update_prices = false;  | 
                                                        |
| 1202 | + $ticket_price = isset($data['edit_prices'][ $row ][1]['PRC_amount'])  | 
                                                        |
| 1203 | + ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0;  | 
                                                        |
| 1204 | + // trim inputs to ensure any excess whitespace is removed.  | 
                                                        |
| 1205 | +			$tkt = array_map('trim', $tkt); | 
                                                        |
| 1206 | +			if (empty($tkt['TKT_start_date'])) { | 
                                                        |
| 1207 | + // let's use now in the set timezone.  | 
                                                        |
| 1208 | +				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); | 
                                                        |
| 1209 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]);  | 
                                                        |
| 1210 | + }  | 
                                                        |
| 1211 | +			if (empty($tkt['TKT_end_date'])) { | 
                                                        |
| 1212 | + // use the start date of the first datetime  | 
                                                        |
| 1213 | + $dtt = $evtobj->first_datetime();  | 
                                                        |
| 1214 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time(  | 
                                                        |
| 1215 | + $incoming_date_formats[0],  | 
                                                        |
| 1216 | + $incoming_date_formats[1]  | 
                                                        |
| 1217 | + );  | 
                                                        |
| 1218 | + }  | 
                                                        |
| 1219 | + $TKT_values = array(  | 
                                                        |
| 1220 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,  | 
                                                        |
| 1221 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,  | 
                                                        |
| 1222 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',  | 
                                                        |
| 1223 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',  | 
                                                        |
| 1224 | + 'TKT_start_date' => $tkt['TKT_start_date'],  | 
                                                        |
| 1225 | + 'TKT_end_date' => $tkt['TKT_end_date'],  | 
                                                        |
| 1226 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],  | 
                                                        |
| 1227 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],  | 
                                                        |
| 1228 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],  | 
                                                        |
| 1229 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],  | 
                                                        |
| 1230 | + 'TKT_row' => $row,  | 
                                                        |
| 1231 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,  | 
                                                        |
| 1232 | + 'TKT_price' => $ticket_price,  | 
                                                        |
| 1233 | + );  | 
                                                        |
| 1234 | + // 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.  | 
                                                        |
| 1235 | +			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { | 
                                                        |
| 1236 | + $TKT_values['TKT_ID'] = 0;  | 
                                                        |
| 1237 | + $TKT_values['TKT_is_default'] = 0;  | 
                                                        |
| 1238 | + $TKT_values['TKT_price'] = $ticket_price;  | 
                                                        |
| 1239 | + $update_prices = true;  | 
                                                        |
| 1240 | + }  | 
                                                        |
| 1241 | + // if we have a TKT_ID then we need to get that existing TKT_obj and update it  | 
                                                        |
| 1242 | + // 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.  | 
                                                        |
| 1243 | + // 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.  | 
                                                        |
| 1244 | +			if (! empty($tkt['TKT_ID'])) { | 
                                                        |
| 1245 | + $TKT = EE_Registry::instance()  | 
                                                        |
| 1246 | +								  ->load_model('Ticket', array($evtobj->get_timezone())) | 
                                                        |
| 1247 | + ->get_one_by_ID($tkt['TKT_ID']);  | 
                                                        |
| 1248 | +				if ($TKT instanceof EE_Ticket) { | 
                                                        |
| 1249 | + $ticket_sold = $TKT->count_related(  | 
                                                        |
| 1250 | + 'Registration',  | 
                                                        |
| 1251 | + array(  | 
                                                        |
| 1252 | + array(  | 
                                                        |
| 1253 | + 'STS_ID' => array(  | 
                                                        |
| 1254 | + 'NOT IN',  | 
                                                        |
| 1255 | + array(EEM_Registration::status_id_incomplete),  | 
                                                        |
| 1256 | + ),  | 
                                                        |
| 1257 | + ),  | 
                                                        |
| 1258 | + )  | 
                                                        |
| 1259 | + ) > 0 ? true : false;  | 
                                                        |
| 1260 | + // 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.  | 
                                                        |
| 1261 | +					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') | 
                                                        |
| 1262 | +									  && ! $TKT->get('TKT_deleted'); | 
                                                        |
| 1263 | + $TKT->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1264 | + $TKT->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1265 | + // set new values  | 
                                                        |
| 1266 | +					foreach ($TKT_values as $field => $value) { | 
                                                        |
| 1267 | +						if ($field == 'TKT_qty') { | 
                                                        |
| 1268 | + $TKT->set_qty($value);  | 
                                                        |
| 1269 | +						} else { | 
                                                        |
| 1270 | + $TKT->set($field, $value);  | 
                                                        |
| 1271 | + }  | 
                                                        |
| 1272 | + }  | 
                                                        |
| 1273 | + // if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket.  | 
                                                        |
| 1274 | +					if ($create_new_TKT) { | 
                                                        |
| 1275 | + // archive the old ticket first  | 
                                                        |
| 1276 | +						$TKT->set('TKT_deleted', 1); | 
                                                        |
| 1277 | + $TKT->save();  | 
                                                        |
| 1278 | + // make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.  | 
                                                        |
| 1279 | + $saved_tickets[ $TKT->ID() ] = $TKT;  | 
                                                        |
| 1280 | + // 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.  | 
                                                        |
| 1281 | + $TKT = clone $TKT;  | 
                                                        |
| 1282 | +						$TKT->set('TKT_ID', 0); | 
                                                        |
| 1283 | +						$TKT->set('TKT_deleted', 0); | 
                                                        |
| 1284 | +						$TKT->set('TKT_price', $ticket_price); | 
                                                        |
| 1285 | +						$TKT->set('TKT_sold', 0); | 
                                                        |
| 1286 | + // now we need to make sure that $new prices are created as well and attached to new ticket.  | 
                                                        |
| 1287 | + $update_prices = true;  | 
                                                        |
| 1288 | + }  | 
                                                        |
| 1289 | + // make sure price is set if it hasn't been already  | 
                                                        |
| 1290 | +					$TKT->set('TKT_price', $ticket_price); | 
                                                        |
| 1291 | + }  | 
                                                        |
| 1292 | +			} else { | 
                                                        |
| 1293 | + // no TKT_id so a new TKT  | 
                                                        |
| 1294 | + $TKT_values['TKT_price'] = $ticket_price;  | 
                                                        |
| 1295 | +				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); | 
                                                        |
| 1296 | +				if ($TKT instanceof EE_Ticket) { | 
                                                        |
| 1297 | + // need to reset values to properly account for the date formats  | 
                                                        |
| 1298 | + $TKT->set_date_format($incoming_date_formats[0]);  | 
                                                        |
| 1299 | + $TKT->set_time_format($incoming_date_formats[1]);  | 
                                                        |
| 1300 | + $TKT->set_timezone($evtobj->get_timezone());  | 
                                                        |
| 1301 | + // set new values  | 
                                                        |
| 1302 | +					foreach ($TKT_values as $field => $value) { | 
                                                        |
| 1303 | +						if ($field == 'TKT_qty') { | 
                                                        |
| 1304 | + $TKT->set_qty($value);  | 
                                                        |
| 1305 | +						} else { | 
                                                        |
| 1306 | + $TKT->set($field, $value);  | 
                                                        |
| 1307 | + }  | 
                                                        |
| 1308 | + }  | 
                                                        |
| 1309 | + $update_prices = true;  | 
                                                        |
| 1310 | + }  | 
                                                        |
| 1311 | + }  | 
                                                        |
| 1312 | + // cap ticket qty by datetime reg limits  | 
                                                        |
| 1313 | +			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); | 
                                                        |
| 1314 | + // update ticket.  | 
                                                        |
| 1315 | + $TKT->save();  | 
                                                        |
| 1316 | + // 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.  | 
                                                        |
| 1317 | +			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { | 
                                                        |
| 1318 | +				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); | 
                                                        |
| 1319 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');  | 
                                                        |
| 1320 | + $TKT->save();  | 
                                                        |
| 1321 | + }  | 
                                                        |
| 1322 | + // initially let's add the ticket to the dtt  | 
                                                        |
| 1323 | + $saved_dtt->_add_relation_to($TKT, 'Ticket');  | 
                                                        |
| 1324 | + $saved_tickets[ $TKT->ID() ] = $TKT;  | 
                                                        |
| 1325 | + // add prices to ticket  | 
                                                        |
| 1326 | + $this->_add_prices_to_ticket($data['edit_prices'][ $row ], $TKT, $update_prices);  | 
                                                        |
| 1327 | + }  | 
                                                        |
| 1328 | + // 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.  | 
                                                        |
| 1329 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;  | 
                                                        |
| 1330 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));  | 
                                                        |
| 1331 | +		foreach ($tickets_removed as $id) { | 
                                                        |
| 1332 | + $id = absint($id);  | 
                                                        |
| 1333 | + // get the ticket for this id  | 
                                                        |
| 1334 | +			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); | 
                                                        |
| 1335 | + // 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)  | 
                                                        |
| 1336 | +			$dtts = $tkt_to_remove->get_many_related('Datetime'); | 
                                                        |
| 1337 | +			foreach ($dtts as $dtt) { | 
                                                        |
| 1338 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime');  | 
                                                        |
| 1339 | + }  | 
                                                        |
| 1340 | + // 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))  | 
                                                        |
| 1341 | +			$tkt_to_remove->delete_related_permanently('Price'); | 
                                                        |
| 1342 | + // finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)  | 
                                                        |
| 1343 | + $tkt_to_remove->delete_permanently();  | 
                                                        |
| 1344 | + }  | 
                                                        |
| 1345 | + return array($saved_dtt, $saved_tickets);  | 
                                                        |
| 1346 | + }  | 
                                                        |
| 1347 | +  | 
                                                        |
| 1348 | +  | 
                                                        |
| 1349 | + /**  | 
                                                        |
| 1350 | + * This attaches a list of given prices to a ticket.  | 
                                                        |
| 1351 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change  | 
                                                        |
| 1352 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old  | 
                                                        |
| 1353 | + * price info and prices are automatically "archived" via the ticket.  | 
                                                        |
| 1354 | + *  | 
                                                        |
| 1355 | + * @access private  | 
                                                        |
| 1356 | + * @param array $prices Array of prices from the form.  | 
                                                        |
| 1357 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to.  | 
                                                        |
| 1358 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones.  | 
                                                        |
| 1359 | + * @return void  | 
                                                        |
| 1360 | + */  | 
                                                        |
| 1361 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false)  | 
                                                        |
| 1362 | +	{ | 
                                                        |
| 1363 | +		foreach ($prices as $row => $prc) { | 
                                                        |
| 1364 | + $PRC_values = array(  | 
                                                        |
| 1365 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,  | 
                                                        |
| 1366 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null,  | 
                                                        |
| 1367 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,  | 
                                                        |
| 1368 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',  | 
                                                        |
| 1369 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',  | 
                                                        |
| 1370 | + 'PRC_is_default' => 0, // make sure prices are NOT set as default from this context  | 
                                                        |
| 1371 | + 'PRC_order' => $row,  | 
                                                        |
| 1372 | + );  | 
                                                        |
| 1373 | +			if ($new_prices || empty($PRC_values['PRC_ID'])) { | 
                                                        |
| 1374 | + $PRC_values['PRC_ID'] = 0;  | 
                                                        |
| 1375 | +				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); | 
                                                        |
| 1376 | +			} else { | 
                                                        |
| 1377 | +				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); | 
                                                        |
| 1378 | + // update this price with new values  | 
                                                        |
| 1379 | +				foreach ($PRC_values as $field => $newprc) { | 
                                                        |
| 1380 | + $PRC->set($field, $newprc);  | 
                                                        |
| 1381 | + }  | 
                                                        |
| 1382 | + $PRC->save();  | 
                                                        |
| 1383 | + }  | 
                                                        |
| 1384 | + $ticket->_add_relation_to($PRC, 'Price');  | 
                                                        |
| 1385 | + }  | 
                                                        |
| 1386 | + }  | 
                                                        |
| 1387 | +  | 
                                                        |
| 1388 | +  | 
                                                        |
| 1389 | + /**  | 
                                                        |
| 1390 | + * Add in our autosave ajax handlers  | 
                                                        |
| 1391 | + *  | 
                                                        |
| 1392 | + */  | 
                                                        |
| 1393 | + protected function _ee_autosave_create_new()  | 
                                                        |
| 1394 | +	{ | 
                                                        |
| 1395 | + }  | 
                                                        |
| 1396 | +  | 
                                                        |
| 1397 | +  | 
                                                        |
| 1398 | + /**  | 
                                                        |
| 1399 | + * More autosave handlers.  | 
                                                        |
| 1400 | + */  | 
                                                        |
| 1401 | + protected function _ee_autosave_edit()  | 
                                                        |
| 1402 | +	{ | 
                                                        |
| 1403 | + return; // TEMPORARILY EXITING CAUSE THIS IS A TODO  | 
                                                        |
| 1404 | + }  | 
                                                        |
| 1405 | +  | 
                                                        |
| 1406 | +  | 
                                                        |
| 1407 | + /**  | 
                                                        |
| 1408 | + * _generate_publish_box_extra_content  | 
                                                        |
| 1409 | + */  | 
                                                        |
| 1410 | + private function _generate_publish_box_extra_content()  | 
                                                        |
| 1411 | +	{ | 
                                                        |
| 1412 | + // load formatter helper  | 
                                                        |
| 1413 | + // args for getting related registrations  | 
                                                        |
| 1414 | + $approved_query_args = array(  | 
                                                        |
| 1415 | + array(  | 
                                                        |
| 1416 | + 'REG_deleted' => 0,  | 
                                                        |
| 1417 | + 'STS_ID' => EEM_Registration::status_id_approved,  | 
                                                        |
| 1418 | + ),  | 
                                                        |
| 1419 | + );  | 
                                                        |
| 1420 | + $not_approved_query_args = array(  | 
                                                        |
| 1421 | + array(  | 
                                                        |
| 1422 | + 'REG_deleted' => 0,  | 
                                                        |
| 1423 | + 'STS_ID' => EEM_Registration::status_id_not_approved,  | 
                                                        |
| 1424 | + ),  | 
                                                        |
| 1425 | + );  | 
                                                        |
| 1426 | + $pending_payment_query_args = array(  | 
                                                        |
| 1427 | + array(  | 
                                                        |
| 1428 | + 'REG_deleted' => 0,  | 
                                                        |
| 1429 | + 'STS_ID' => EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 1430 | + ),  | 
                                                        |
| 1431 | + );  | 
                                                        |
| 1432 | + // publish box  | 
                                                        |
| 1433 | + $publish_box_extra_args = array(  | 
                                                        |
| 1434 | + 'view_approved_reg_url' => add_query_arg(  | 
                                                        |
| 1435 | + array(  | 
                                                        |
| 1436 | + 'action' => 'default',  | 
                                                        |
| 1437 | + 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1438 | + '_reg_status' => EEM_Registration::status_id_approved,  | 
                                                        |
| 1439 | + ),  | 
                                                        |
| 1440 | + REG_ADMIN_URL  | 
                                                        |
| 1441 | + ),  | 
                                                        |
| 1442 | + 'view_not_approved_reg_url' => add_query_arg(  | 
                                                        |
| 1443 | + array(  | 
                                                        |
| 1444 | + 'action' => 'default',  | 
                                                        |
| 1445 | + 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1446 | + '_reg_status' => EEM_Registration::status_id_not_approved,  | 
                                                        |
| 1447 | + ),  | 
                                                        |
| 1448 | + REG_ADMIN_URL  | 
                                                        |
| 1449 | + ),  | 
                                                        |
| 1450 | + 'view_pending_payment_reg_url' => add_query_arg(  | 
                                                        |
| 1451 | + array(  | 
                                                        |
| 1452 | + 'action' => 'default',  | 
                                                        |
| 1453 | + 'event_id' => $this->_cpt_model_obj->ID(),  | 
                                                        |
| 1454 | + '_reg_status' => EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 1455 | + ),  | 
                                                        |
| 1456 | + REG_ADMIN_URL  | 
                                                        |
| 1457 | + ),  | 
                                                        |
| 1458 | + 'approved_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1459 | + 'Registration',  | 
                                                        |
| 1460 | + $approved_query_args  | 
                                                        |
| 1461 | + ),  | 
                                                        |
| 1462 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1463 | + 'Registration',  | 
                                                        |
| 1464 | + $not_approved_query_args  | 
                                                        |
| 1465 | + ),  | 
                                                        |
| 1466 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related(  | 
                                                        |
| 1467 | + 'Registration',  | 
                                                        |
| 1468 | + $pending_payment_query_args  | 
                                                        |
| 1469 | + ),  | 
                                                        |
| 1470 | + 'misc_pub_section_class' => apply_filters(  | 
                                                        |
| 1471 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',  | 
                                                        |
| 1472 | + 'misc-pub-section'  | 
                                                        |
| 1473 | + ),  | 
                                                        |
| 1474 | + );  | 
                                                        |
| 1475 | + ob_start();  | 
                                                        |
| 1476 | + do_action(  | 
                                                        |
| 1477 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',  | 
                                                        |
| 1478 | + $this->_cpt_model_obj  | 
                                                        |
| 1479 | + );  | 
                                                        |
| 1480 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();  | 
                                                        |
| 1481 | + // load template  | 
                                                        |
| 1482 | + EEH_Template::display_template(  | 
                                                        |
| 1483 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php',  | 
                                                        |
| 1484 | + $publish_box_extra_args  | 
                                                        |
| 1485 | + );  | 
                                                        |
| 1486 | + }  | 
                                                        |
| 1487 | +  | 
                                                        |
| 1488 | +  | 
                                                        |
| 1489 | + /**  | 
                                                        |
| 1490 | + * @return EE_Event  | 
                                                        |
| 1491 | + */  | 
                                                        |
| 1492 | + public function get_event_object()  | 
                                                        |
| 1493 | +	{ | 
                                                        |
| 1494 | + return $this->_cpt_model_obj;  | 
                                                        |
| 1495 | + }  | 
                                                        |
| 1496 | +  | 
                                                        |
| 1497 | +  | 
                                                        |
| 1498 | +  | 
                                                        |
| 1499 | +  | 
                                                        |
| 1500 | + /** METABOXES * */  | 
                                                        |
| 1501 | + /**  | 
                                                        |
| 1502 | + * _register_event_editor_meta_boxes  | 
                                                        |
| 1503 | + * add all metaboxes related to the event_editor  | 
                                                        |
| 1504 | + *  | 
                                                        |
| 1505 | + * @return void  | 
                                                        |
| 1506 | + */  | 
                                                        |
| 1507 | + protected function _register_event_editor_meta_boxes()  | 
                                                        |
| 1508 | +	{ | 
                                                        |
| 1509 | + $this->verify_cpt_object();  | 
                                                        |
| 1510 | + // add_meta_box(  | 
                                                        |
| 1511 | + // 'espresso_event_editor_tickets',  | 
                                                        |
| 1512 | +		//     esc_html__('Event Datetime & Ticket', 'event_espresso'), | 
                                                        |
| 1513 | + // array($this, 'ticket_metabox'),  | 
                                                        |
| 1514 | + // $this->page_slug,  | 
                                                        |
| 1515 | + // 'normal',  | 
                                                        |
| 1516 | + // 'high'  | 
                                                        |
| 1517 | + // );  | 
                                                        |
| 1518 | + add_meta_box(  | 
                                                        |
| 1519 | + 'espresso_event_editor_event_options',  | 
                                                        |
| 1520 | +			esc_html__('Event Registration Options', 'event_espresso'), | 
                                                        |
| 1521 | + array($this, 'registration_options_meta_box'),  | 
                                                        |
| 1522 | + $this->page_slug,  | 
                                                        |
| 1523 | + 'side',  | 
                                                        |
| 1524 | + 'default'  | 
                                                        |
| 1525 | + );  | 
                                                        |
| 1526 | + // NOTE: if you're looking for other metaboxes in here,  | 
                                                        |
| 1527 | + // where a metabox has a related management page in the admin  | 
                                                        |
| 1528 | + // you will find it setup in the related management page's "_Hooks" file.  | 
                                                        |
| 1529 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php".  | 
                                                        |
| 1530 | + }  | 
                                                        |
| 1531 | +  | 
                                                        |
| 1532 | +  | 
                                                        |
| 1533 | + /**  | 
                                                        |
| 1534 | + * @throws DomainException  | 
                                                        |
| 1535 | + * @throws EE_Error  | 
                                                        |
| 1536 | + */  | 
                                                        |
| 1537 | + public function ticket_metabox()  | 
                                                        |
| 1538 | +	{ | 
                                                        |
| 1539 | + $existing_datetime_ids = $existing_ticket_ids = array();  | 
                                                        |
| 1540 | + // defaults for template args  | 
                                                        |
| 1541 | + $template_args = array(  | 
                                                        |
| 1542 | + 'existing_datetime_ids' => '',  | 
                                                        |
| 1543 | + 'event_datetime_help_link' => '',  | 
                                                        |
| 1544 | + 'ticket_options_help_link' => '',  | 
                                                        |
| 1545 | + 'time' => null,  | 
                                                        |
| 1546 | + 'ticket_rows' => '',  | 
                                                        |
| 1547 | + 'existing_ticket_ids' => '',  | 
                                                        |
| 1548 | + 'total_ticket_rows' => 1,  | 
                                                        |
| 1549 | + 'ticket_js_structure' => '',  | 
                                                        |
| 1550 | + 'trash_icon' => 'ee-lock-icon',  | 
                                                        |
| 1551 | + 'disabled' => '',  | 
                                                        |
| 1552 | + );  | 
                                                        |
| 1553 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null;  | 
                                                        |
| 1554 | +		do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 1555 | + /**  | 
                                                        |
| 1556 | + * 1. Start with retrieving Datetimes  | 
                                                        |
| 1557 | + * 2. Fore each datetime get related tickets  | 
                                                        |
| 1558 | + * 3. For each ticket get related prices  | 
                                                        |
| 1559 | + */  | 
                                                        |
| 1560 | +		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); | 
                                                        |
| 1561 | + /** @type EE_Datetime $first_datetime */  | 
                                                        |
| 1562 | + $first_datetime = reset($times);  | 
                                                        |
| 1563 | + // do we get related tickets?  | 
                                                        |
| 1564 | + if ($first_datetime instanceof EE_Datetime  | 
                                                        |
| 1565 | + && $first_datetime->ID() !== 0  | 
                                                        |
| 1566 | +		) { | 
                                                        |
| 1567 | +			$existing_datetime_ids[] = $first_datetime->get('DTT_ID'); | 
                                                        |
| 1568 | + $template_args['time'] = $first_datetime;  | 
                                                        |
| 1569 | + $related_tickets = $first_datetime->tickets(  | 
                                                        |
| 1570 | + array(  | 
                                                        |
| 1571 | +					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), | 
                                                        |
| 1572 | + 'default_where_conditions' => 'none',  | 
                                                        |
| 1573 | + )  | 
                                                        |
| 1574 | + );  | 
                                                        |
| 1575 | +			if (! empty($related_tickets)) { | 
                                                        |
| 1576 | + $template_args['total_ticket_rows'] = count($related_tickets);  | 
                                                        |
| 1577 | + $row = 0;  | 
                                                        |
| 1578 | +				foreach ($related_tickets as $ticket) { | 
                                                        |
| 1579 | +					$existing_ticket_ids[] = $ticket->get('TKT_ID'); | 
                                                        |
| 1580 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row);  | 
                                                        |
| 1581 | + $row++;  | 
                                                        |
| 1582 | + }  | 
                                                        |
| 1583 | +			} else { | 
                                                        |
| 1584 | + $template_args['total_ticket_rows'] = 1;  | 
                                                        |
| 1585 | + /** @type EE_Ticket $ticket */  | 
                                                        |
| 1586 | +				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); | 
                                                        |
| 1587 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);  | 
                                                        |
| 1588 | + }  | 
                                                        |
| 1589 | +		} else { | 
                                                        |
| 1590 | + $template_args['time'] = $times[0];  | 
                                                        |
| 1591 | + /** @type EE_Ticket $ticket */  | 
                                                        |
| 1592 | +			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); | 
                                                        |
| 1593 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);  | 
                                                        |
| 1594 | + // NOTE: we're just sending the first default row  | 
                                                        |
| 1595 | + // (decaf can't manage default tickets so this should be sufficient);  | 
                                                        |
| 1596 | + }  | 
                                                        |
| 1597 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link(  | 
                                                        |
| 1598 | + 'event_editor_event_datetimes_help_tab'  | 
                                                        |
| 1599 | + );  | 
                                                        |
| 1600 | +		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); | 
                                                        |
| 1601 | +		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); | 
                                                        |
| 1602 | +		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); | 
                                                        |
| 1603 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row(  | 
                                                        |
| 1604 | +			EE_Registry::instance()->load_model('Ticket')->create_default_object(), | 
                                                        |
| 1605 | + true  | 
                                                        |
| 1606 | + );  | 
                                                        |
| 1607 | + $template = apply_filters(  | 
                                                        |
| 1608 | + 'FHEE__Events_Admin_Page__ticket_metabox__template',  | 
                                                        |
| 1609 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'  | 
                                                        |
| 1610 | + );  | 
                                                        |
| 1611 | + EEH_Template::display_template($template, $template_args);  | 
                                                        |
| 1612 | + }  | 
                                                        |
| 1613 | +  | 
                                                        |
| 1614 | +  | 
                                                        |
| 1615 | + /**  | 
                                                        |
| 1616 | + * Setup an individual ticket form for the decaf event editor page  | 
                                                        |
| 1617 | + *  | 
                                                        |
| 1618 | + * @access private  | 
                                                        |
| 1619 | + * @param EE_Ticket $ticket the ticket object  | 
                                                        |
| 1620 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation  | 
                                                        |
| 1621 | + * @param int $row  | 
                                                        |
| 1622 | + * @return string generated html for the ticket row.  | 
                                                        |
| 1623 | + */  | 
                                                        |
| 1624 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0)  | 
                                                        |
| 1625 | +	{ | 
                                                        |
| 1626 | + $template_args = array(  | 
                                                        |
| 1627 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),  | 
                                                        |
| 1628 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived'  | 
                                                        |
| 1629 | + : '',  | 
                                                        |
| 1630 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row,  | 
                                                        |
| 1631 | +			'TKT_ID'              => $ticket->get('TKT_ID'), | 
                                                        |
| 1632 | +			'TKT_name'            => $ticket->get('TKT_name'), | 
                                                        |
| 1633 | +			'TKT_start_date'      => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), | 
                                                        |
| 1634 | +			'TKT_end_date'        => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), | 
                                                        |
| 1635 | +			'TKT_is_default'      => $ticket->get('TKT_is_default'), | 
                                                        |
| 1636 | +			'TKT_qty'             => $ticket->get_pretty('TKT_qty', 'input'), | 
                                                        |
| 1637 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',  | 
                                                        |
| 1638 | +			'TKT_sold'            => $skeleton ? 0 : $ticket->get('TKT_sold'), | 
                                                        |
| 1639 | +			'trash_icon'          => ($skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted'))) | 
                                                        |
| 1640 | +									 && (! empty($ticket) && $ticket->get('TKT_sold') === 0) | 
                                                        |
| 1641 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',  | 
                                                        |
| 1642 | +			'disabled'            => $skeleton || (! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' | 
                                                        |
| 1643 | + : ' disabled=disabled',  | 
                                                        |
| 1644 | + );  | 
                                                        |
| 1645 | + $price = $ticket->ID() !== 0  | 
                                                        |
| 1646 | +			? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) | 
                                                        |
| 1647 | +			: EE_Registry::instance()->load_model('Price')->create_default_object(); | 
                                                        |
| 1648 | + $price_args = array(  | 
                                                        |
| 1649 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,  | 
                                                        |
| 1650 | +			'PRC_amount'            => $price->get('PRC_amount'), | 
                                                        |
| 1651 | +			'PRT_ID'                => $price->get('PRT_ID'), | 
                                                        |
| 1652 | +			'PRC_ID'                => $price->get('PRC_ID'), | 
                                                        |
| 1653 | +			'PRC_is_default'        => $price->get('PRC_is_default'), | 
                                                        |
| 1654 | + );  | 
                                                        |
| 1655 | + // make sure we have default start and end dates if skeleton  | 
                                                        |
| 1656 | + // handle rows that should NOT be empty  | 
                                                        |
| 1657 | +		if (empty($template_args['TKT_start_date'])) { | 
                                                        |
| 1658 | + // if empty then the start date will be now.  | 
                                                        |
| 1659 | +			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); | 
                                                        |
| 1660 | + }  | 
                                                        |
| 1661 | +		if (empty($template_args['TKT_end_date'])) { | 
                                                        |
| 1662 | + // get the earliest datetime (if present);  | 
                                                        |
| 1663 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0  | 
                                                        |
| 1664 | + ? $this->_cpt_model_obj->get_first_related(  | 
                                                        |
| 1665 | + 'Datetime',  | 
                                                        |
| 1666 | +					array('order_by' => array('DTT_EVT_start' => 'ASC')) | 
                                                        |
| 1667 | + )  | 
                                                        |
| 1668 | + : null;  | 
                                                        |
| 1669 | +			if (! empty($earliest_dtt)) { | 
                                                        |
| 1670 | +				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); | 
                                                        |
| 1671 | +			} else { | 
                                                        |
| 1672 | + $template_args['TKT_end_date'] = date(  | 
                                                        |
| 1673 | + 'Y-m-d h:i a',  | 
                                                        |
| 1674 | +					mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) | 
                                                        |
| 1675 | + );  | 
                                                        |
| 1676 | + }  | 
                                                        |
| 1677 | + }  | 
                                                        |
| 1678 | + $template_args = array_merge($template_args, $price_args);  | 
                                                        |
| 1679 | + $template = apply_filters(  | 
                                                        |
| 1680 | + 'FHEE__Events_Admin_Page__get_ticket_row__template',  | 
                                                        |
| 1681 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php',  | 
                                                        |
| 1682 | + $ticket  | 
                                                        |
| 1683 | + );  | 
                                                        |
| 1684 | + return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 1685 | + }  | 
                                                        |
| 1686 | +  | 
                                                        |
| 1687 | +  | 
                                                        |
| 1688 | + /**  | 
                                                        |
| 1689 | + * @throws DomainException  | 
                                                        |
| 1690 | + */  | 
                                                        |
| 1691 | + public function registration_options_meta_box()  | 
                                                        |
| 1692 | +	{ | 
                                                        |
| 1693 | + $yes_no_values = array(  | 
                                                        |
| 1694 | +			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), | 
                                                        |
| 1695 | +			array('id' => false, 'text' => esc_html__('No', 'event_espresso')), | 
                                                        |
| 1696 | + );  | 
                                                        |
| 1697 | + $default_reg_status_values = EEM_Registration::reg_status_array(  | 
                                                        |
| 1698 | + array(  | 
                                                        |
| 1699 | + EEM_Registration::status_id_cancelled,  | 
                                                        |
| 1700 | + EEM_Registration::status_id_declined,  | 
                                                        |
| 1701 | + EEM_Registration::status_id_incomplete,  | 
                                                        |
| 1702 | + ),  | 
                                                        |
| 1703 | + true  | 
                                                        |
| 1704 | + );  | 
                                                        |
| 1705 | +		// $template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); | 
                                                        |
| 1706 | + $template_args['_event'] = $this->_cpt_model_obj;  | 
                                                        |
| 1707 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false);  | 
                                                        |
| 1708 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();  | 
                                                        |
| 1709 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1710 | + 'default_reg_status',  | 
                                                        |
| 1711 | + $default_reg_status_values,  | 
                                                        |
| 1712 | + $this->_cpt_model_obj->default_registration_status()  | 
                                                        |
| 1713 | + );  | 
                                                        |
| 1714 | + $template_args['display_description'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1715 | + 'display_desc',  | 
                                                        |
| 1716 | + $yes_no_values,  | 
                                                        |
| 1717 | + $this->_cpt_model_obj->display_description()  | 
                                                        |
| 1718 | + );  | 
                                                        |
| 1719 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(  | 
                                                        |
| 1720 | + 'display_ticket_selector',  | 
                                                        |
| 1721 | + $yes_no_values,  | 
                                                        |
| 1722 | + $this->_cpt_model_obj->display_ticket_selector(),  | 
                                                        |
| 1723 | + '',  | 
                                                        |
| 1724 | + '',  | 
                                                        |
| 1725 | + false  | 
                                                        |
| 1726 | + );  | 
                                                        |
| 1727 | + $template_args['additional_registration_options'] = apply_filters(  | 
                                                        |
| 1728 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',  | 
                                                        |
| 1729 | + '',  | 
                                                        |
| 1730 | + $template_args,  | 
                                                        |
| 1731 | + $yes_no_values,  | 
                                                        |
| 1732 | + $default_reg_status_values  | 
                                                        |
| 1733 | + );  | 
                                                        |
| 1734 | + EEH_Template::display_template(  | 
                                                        |
| 1735 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php',  | 
                                                        |
| 1736 | + $template_args  | 
                                                        |
| 1737 | + );  | 
                                                        |
| 1738 | + }  | 
                                                        |
| 1739 | +  | 
                                                        |
| 1740 | +  | 
                                                        |
| 1741 | + /**  | 
                                                        |
| 1742 | + * _get_events()  | 
                                                        |
| 1743 | + * This method simply returns all the events (for the given _view and paging)  | 
                                                        |
| 1744 | + *  | 
                                                        |
| 1745 | + * @access public  | 
                                                        |
| 1746 | + * @param int $per_page count of items per page (20 default);  | 
                                                        |
| 1747 | + * @param int $current_page what is the current page being viewed.  | 
                                                        |
| 1748 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view.  | 
                                                        |
| 1749 | + * If FALSE then we return an array of event objects  | 
                                                        |
| 1750 | + * that match the given _view and paging parameters.  | 
                                                        |
| 1751 | + * @return array an array of event objects.  | 
                                                        |
| 1752 | + */  | 
                                                        |
| 1753 | + public function get_events($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 1754 | +	{ | 
                                                        |
| 1755 | + $EEME = $this->_event_model();  | 
                                                        |
| 1756 | + $offset = ($current_page - 1) * $per_page;  | 
                                                        |
| 1757 | + $limit = $count ? null : $offset . ',' . $per_page;  | 
                                                        |
| 1758 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';  | 
                                                        |
| 1759 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";  | 
                                                        |
| 1760 | +		if (isset($this->_req_data['month_range'])) { | 
                                                        |
| 1761 | +			$pieces = explode(' ', $this->_req_data['month_range'], 3); | 
                                                        |
| 1762 | + // simulate the FIRST day of the month, that fixes issues for months like February  | 
                                                        |
| 1763 | + // where PHP doesn't know what to assume for date.  | 
                                                        |
| 1764 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/10437  | 
                                                        |
| 1765 | +			$month_r = ! empty($pieces[0]) ? date('m', \EEH_DTT_Helper::first_of_month_timestamp($pieces[0])) : ''; | 
                                                        |
| 1766 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : '';  | 
                                                        |
| 1767 | + }  | 
                                                        |
| 1768 | + $where = array();  | 
                                                        |
| 1769 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;  | 
                                                        |
| 1770 | + // determine what post_status our condition will have for the query.  | 
                                                        |
| 1771 | +		switch ($status) { | 
                                                        |
| 1772 | + case 'month':  | 
                                                        |
| 1773 | + case 'today':  | 
                                                        |
| 1774 | + case null:  | 
                                                        |
| 1775 | + case 'all':  | 
                                                        |
| 1776 | + break;  | 
                                                        |
| 1777 | + case 'draft':  | 
                                                        |
| 1778 | +				$where['status'] = array('IN', array('draft', 'auto-draft')); | 
                                                        |
| 1779 | + break;  | 
                                                        |
| 1780 | + default:  | 
                                                        |
| 1781 | + $where['status'] = $status;  | 
                                                        |
| 1782 | + }  | 
                                                        |
| 1783 | + // categories?  | 
                                                        |
| 1784 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0  | 
                                                        |
| 1785 | + ? $this->_req_data['EVT_CAT'] : null;  | 
                                                        |
| 1786 | +		if (! empty($category)) { | 
                                                        |
| 1787 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';  | 
                                                        |
| 1788 | + $where['Term_Taxonomy.term_id'] = $category;  | 
                                                        |
| 1789 | + }  | 
                                                        |
| 1790 | + // date where conditions  | 
                                                        |
| 1791 | +		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); | 
                                                        |
| 1792 | +		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { | 
                                                        |
| 1793 | + $DateTime = new DateTime(  | 
                                                        |
| 1794 | + $year_r . '-' . $month_r . '-01 00:00:00',  | 
                                                        |
| 1795 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone())  | 
                                                        |
| 1796 | + );  | 
                                                        |
| 1797 | +			$start = $DateTime->format(implode(' ', $start_formats)); | 
                                                        |
| 1798 | + $end = $DateTime->setDate(  | 
                                                        |
| 1799 | + $year_r,  | 
                                                        |
| 1800 | + $month_r,  | 
                                                        |
| 1801 | + $DateTime  | 
                                                        |
| 1802 | +					->format('t') | 
                                                        |
| 1803 | + )->setTime(23, 59, 59)  | 
                                                        |
| 1804 | +							->format(implode(' ', $start_formats)); | 
                                                        |
| 1805 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1806 | +		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { | 
                                                        |
| 1807 | +			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); | 
                                                        |
| 1808 | +			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1809 | +			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); | 
                                                        |
| 1810 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1811 | +		} elseif (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { | 
                                                        |
| 1812 | +			$now = date('Y-m-01'); | 
                                                        |
| 1813 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));  | 
                                                        |
| 1814 | +			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); | 
                                                        |
| 1815 | +			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) | 
                                                        |
| 1816 | + ->setTime(23, 59, 59)  | 
                                                        |
| 1817 | +							->format(implode(' ', $start_formats)); | 
                                                        |
| 1818 | +			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); | 
                                                        |
| 1819 | + }  | 
                                                        |
| 1820 | +		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { | 
                                                        |
| 1821 | + $where['EVT_wp_user'] = get_current_user_id();  | 
                                                        |
| 1822 | +		} else { | 
                                                        |
| 1823 | +			if (! isset($where['status'])) { | 
                                                        |
| 1824 | +				if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { | 
                                                        |
| 1825 | + $where['OR'] = array(  | 
                                                        |
| 1826 | +						'status*restrict_private' => array('!=', 'private'), | 
                                                        |
| 1827 | + 'AND' => array(  | 
                                                        |
| 1828 | +							'status*inclusive' => array('=', 'private'), | 
                                                        |
| 1829 | + 'EVT_wp_user' => get_current_user_id(),  | 
                                                        |
| 1830 | + ),  | 
                                                        |
| 1831 | + );  | 
                                                        |
| 1832 | + }  | 
                                                        |
| 1833 | + }  | 
                                                        |
| 1834 | + }  | 
                                                        |
| 1835 | +		if (isset($this->_req_data['EVT_wp_user'])) { | 
                                                        |
| 1836 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id()  | 
                                                        |
| 1837 | +				&& EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') | 
                                                        |
| 1838 | +			) { | 
                                                        |
| 1839 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];  | 
                                                        |
| 1840 | + }  | 
                                                        |
| 1841 | + }  | 
                                                        |
| 1842 | + // search query handling  | 
                                                        |
| 1843 | +		if (isset($this->_req_data['s'])) { | 
                                                        |
| 1844 | + $search_string = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 1845 | + $where['OR'] = array(  | 
                                                        |
| 1846 | +				'EVT_name'       => array('LIKE', $search_string), | 
                                                        |
| 1847 | +				'EVT_desc'       => array('LIKE', $search_string), | 
                                                        |
| 1848 | +				'EVT_short_desc' => array('LIKE', $search_string), | 
                                                        |
| 1849 | + );  | 
                                                        |
| 1850 | + }  | 
                                                        |
| 1851 | +		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); | 
                                                        |
| 1852 | + $query_params = apply_filters(  | 
                                                        |
| 1853 | + 'FHEE__Events_Admin_Page__get_events__query_params',  | 
                                                        |
| 1854 | + array(  | 
                                                        |
| 1855 | + $where,  | 
                                                        |
| 1856 | + 'limit' => $limit,  | 
                                                        |
| 1857 | + 'order_by' => $orderby,  | 
                                                        |
| 1858 | + 'order' => $order,  | 
                                                        |
| 1859 | + 'group_by' => 'EVT_ID',  | 
                                                        |
| 1860 | + ),  | 
                                                        |
| 1861 | + $this->_req_data  | 
                                                        |
| 1862 | + );  | 
                                                        |
| 1863 | + // let's first check if we have special requests coming in.  | 
                                                        |
| 1864 | +		if (isset($this->_req_data['active_status'])) { | 
                                                        |
| 1865 | +			switch ($this->_req_data['active_status']) { | 
                                                        |
| 1866 | + case 'upcoming':  | 
                                                        |
| 1867 | + return $EEME->get_upcoming_events($query_params, $count);  | 
                                                        |
| 1868 | + break;  | 
                                                        |
| 1869 | + case 'expired':  | 
                                                        |
| 1870 | + return $EEME->get_expired_events($query_params, $count);  | 
                                                        |
| 1871 | + break;  | 
                                                        |
| 1872 | + case 'active':  | 
                                                        |
| 1873 | + return $EEME->get_active_events($query_params, $count);  | 
                                                        |
| 1874 | + break;  | 
                                                        |
| 1875 | + case 'inactive':  | 
                                                        |
| 1876 | + return $EEME->get_inactive_events($query_params, $count);  | 
                                                        |
| 1877 | + break;  | 
                                                        |
| 1878 | + }  | 
                                                        |
| 1879 | + }  | 
                                                        |
| 1880 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);  | 
                                                        |
| 1881 | + return $events;  | 
                                                        |
| 1882 | + }  | 
                                                        |
| 1883 | +  | 
                                                        |
| 1884 | +  | 
                                                        |
| 1885 | + /**  | 
                                                        |
| 1886 | + * handling for WordPress CPT actions (trash, restore, delete)  | 
                                                        |
| 1887 | + *  | 
                                                        |
| 1888 | + * @param string $post_id  | 
                                                        |
| 1889 | + */  | 
                                                        |
| 1890 | + public function trash_cpt_item($post_id)  | 
                                                        |
| 1891 | +	{ | 
                                                        |
| 1892 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1893 | +		$this->_trash_or_restore_event('trash', false); | 
                                                        |
| 1894 | + }  | 
                                                        |
| 1895 | +  | 
                                                        |
| 1896 | +  | 
                                                        |
| 1897 | + /**  | 
                                                        |
| 1898 | + * @param string $post_id  | 
                                                        |
| 1899 | + */  | 
                                                        |
| 1900 | + public function restore_cpt_item($post_id)  | 
                                                        |
| 1901 | +	{ | 
                                                        |
| 1902 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1903 | +		$this->_trash_or_restore_event('draft', false); | 
                                                        |
| 1904 | + }  | 
                                                        |
| 1905 | +  | 
                                                        |
| 1906 | +  | 
                                                        |
| 1907 | + /**  | 
                                                        |
| 1908 | + * @param string $post_id  | 
                                                        |
| 1909 | + */  | 
                                                        |
| 1910 | + public function delete_cpt_item($post_id)  | 
                                                        |
| 1911 | +	{ | 
                                                        |
| 1912 | + $this->_req_data['EVT_ID'] = $post_id;  | 
                                                        |
| 1913 | + $this->_delete_event(false);  | 
                                                        |
| 1914 | + }  | 
                                                        |
| 1915 | +  | 
                                                        |
| 1916 | +  | 
                                                        |
| 1917 | + /**  | 
                                                        |
| 1918 | + * _trash_or_restore_event  | 
                                                        |
| 1919 | + *  | 
                                                        |
| 1920 | + * @access protected  | 
                                                        |
| 1921 | + * @param string $event_status  | 
                                                        |
| 1922 | + * @param bool $redirect_after  | 
                                                        |
| 1923 | + */  | 
                                                        |
| 1924 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true)  | 
                                                        |
| 1925 | +	{ | 
                                                        |
| 1926 | + // determine the event id and set to array.  | 
                                                        |
| 1927 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false;  | 
                                                        |
| 1928 | + // loop thru events  | 
                                                        |
| 1929 | +		if ($EVT_ID) { | 
                                                        |
| 1930 | + // clean status  | 
                                                        |
| 1931 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 1932 | + // grab status  | 
                                                        |
| 1933 | +			if (! empty($event_status)) { | 
                                                        |
| 1934 | + $success = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1935 | +			} else { | 
                                                        |
| 1936 | + $success = false;  | 
                                                        |
| 1937 | + $msg = esc_html__(  | 
                                                        |
| 1938 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1939 | + 'event_espresso'  | 
                                                        |
| 1940 | + );  | 
                                                        |
| 1941 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1942 | + }  | 
                                                        |
| 1943 | +		} else { | 
                                                        |
| 1944 | + $success = false;  | 
                                                        |
| 1945 | + $msg = esc_html__(  | 
                                                        |
| 1946 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1947 | + 'event_espresso'  | 
                                                        |
| 1948 | + );  | 
                                                        |
| 1949 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1950 | + }  | 
                                                        |
| 1951 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 1952 | +		if ($redirect_after) { | 
                                                        |
| 1953 | +			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); | 
                                                        |
| 1954 | + }  | 
                                                        |
| 1955 | + }  | 
                                                        |
| 1956 | +  | 
                                                        |
| 1957 | +  | 
                                                        |
| 1958 | + /**  | 
                                                        |
| 1959 | + * _trash_or_restore_events  | 
                                                        |
| 1960 | + *  | 
                                                        |
| 1961 | + * @access protected  | 
                                                        |
| 1962 | + * @param string $event_status  | 
                                                        |
| 1963 | + * @return void  | 
                                                        |
| 1964 | + */  | 
                                                        |
| 1965 | + protected function _trash_or_restore_events($event_status = 'trash')  | 
                                                        |
| 1966 | +	{ | 
                                                        |
| 1967 | + // clean status  | 
                                                        |
| 1968 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 1969 | + // grab status  | 
                                                        |
| 1970 | +		if (! empty($event_status)) { | 
                                                        |
| 1971 | + $success = true;  | 
                                                        |
| 1972 | + // determine the event id and set to array.  | 
                                                        |
| 1973 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 1974 | + // loop thru events  | 
                                                        |
| 1975 | +			foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 1976 | +				if ($EVT_ID = absint($EVT_ID)) { | 
                                                        |
| 1977 | + $results = $this->_change_event_status($EVT_ID, $event_status);  | 
                                                        |
| 1978 | + $success = $results !== false ? $success : false;  | 
                                                        |
| 1979 | +				} else { | 
                                                        |
| 1980 | + $msg = sprintf(  | 
                                                        |
| 1981 | + esc_html__(  | 
                                                        |
| 1982 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.',  | 
                                                        |
| 1983 | + 'event_espresso'  | 
                                                        |
| 1984 | + ),  | 
                                                        |
| 1985 | + $EVT_ID  | 
                                                        |
| 1986 | + );  | 
                                                        |
| 1987 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1988 | + $success = false;  | 
                                                        |
| 1989 | + }  | 
                                                        |
| 1990 | + }  | 
                                                        |
| 1991 | +		} else { | 
                                                        |
| 1992 | + $success = false;  | 
                                                        |
| 1993 | + $msg = esc_html__(  | 
                                                        |
| 1994 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.',  | 
                                                        |
| 1995 | + 'event_espresso'  | 
                                                        |
| 1996 | + );  | 
                                                        |
| 1997 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 1998 | + }  | 
                                                        |
| 1999 | + // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2000 | + $success = $success ? 2 : false;  | 
                                                        |
| 2001 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';  | 
                                                        |
| 2002 | +		$this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); | 
                                                        |
| 2003 | + }  | 
                                                        |
| 2004 | +  | 
                                                        |
| 2005 | +  | 
                                                        |
| 2006 | + /**  | 
                                                        |
| 2007 | + * _trash_or_restore_events  | 
                                                        |
| 2008 | + *  | 
                                                        |
| 2009 | + * @access private  | 
                                                        |
| 2010 | + * @param int $EVT_ID  | 
                                                        |
| 2011 | + * @param string $event_status  | 
                                                        |
| 2012 | + * @return bool  | 
                                                        |
| 2013 | + */  | 
                                                        |
| 2014 | + private function _change_event_status($EVT_ID = 0, $event_status = '')  | 
                                                        |
| 2015 | +	{ | 
                                                        |
| 2016 | + // grab event id  | 
                                                        |
| 2017 | +		if (! $EVT_ID) { | 
                                                        |
| 2018 | + $msg = esc_html__(  | 
                                                        |
| 2019 | + 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2020 | + 'event_espresso'  | 
                                                        |
| 2021 | + );  | 
                                                        |
| 2022 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2023 | + return false;  | 
                                                        |
| 2024 | + }  | 
                                                        |
| 2025 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2026 | + // clean status  | 
                                                        |
| 2027 | + $event_status = sanitize_key($event_status);  | 
                                                        |
| 2028 | + // grab status  | 
                                                        |
| 2029 | +		if (empty($event_status)) { | 
                                                        |
| 2030 | + $msg = esc_html__(  | 
                                                        |
| 2031 | + 'An error occurred. No Event Status or an invalid Event Status was received.',  | 
                                                        |
| 2032 | + 'event_espresso'  | 
                                                        |
| 2033 | + );  | 
                                                        |
| 2034 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2035 | + return false;  | 
                                                        |
| 2036 | + }  | 
                                                        |
| 2037 | + // was event trashed or restored ?  | 
                                                        |
| 2038 | +		switch ($event_status) { | 
                                                        |
| 2039 | + case 'draft':  | 
                                                        |
| 2040 | + $action = 'restored from the trash';  | 
                                                        |
| 2041 | + $hook = 'AHEE_event_restored_from_trash';  | 
                                                        |
| 2042 | + break;  | 
                                                        |
| 2043 | + case 'trash':  | 
                                                        |
| 2044 | + $action = 'moved to the trash';  | 
                                                        |
| 2045 | + $hook = 'AHEE_event_moved_to_trash';  | 
                                                        |
| 2046 | + break;  | 
                                                        |
| 2047 | + default:  | 
                                                        |
| 2048 | + $action = 'updated';  | 
                                                        |
| 2049 | + $hook = false;  | 
                                                        |
| 2050 | + }  | 
                                                        |
| 2051 | + // use class to change status  | 
                                                        |
| 2052 | + $this->_cpt_model_obj->set_status($event_status);  | 
                                                        |
| 2053 | + $success = $this->_cpt_model_obj->save();  | 
                                                        |
| 2054 | +		if ($success === false) { | 
                                                        |
| 2055 | +			$msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); | 
                                                        |
| 2056 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2057 | + return false;  | 
                                                        |
| 2058 | + }  | 
                                                        |
| 2059 | +		if ($hook) { | 
                                                        |
| 2060 | + do_action($hook);  | 
                                                        |
| 2061 | + }  | 
                                                        |
| 2062 | + return true;  | 
                                                        |
| 2063 | + }  | 
                                                        |
| 2064 | +  | 
                                                        |
| 2065 | +  | 
                                                        |
| 2066 | + /**  | 
                                                        |
| 2067 | + * _delete_event  | 
                                                        |
| 2068 | + *  | 
                                                        |
| 2069 | + * @access protected  | 
                                                        |
| 2070 | + * @param bool $redirect_after  | 
                                                        |
| 2071 | + */  | 
                                                        |
| 2072 | + protected function _delete_event($redirect_after = true)  | 
                                                        |
| 2073 | +	{ | 
                                                        |
| 2074 | + // determine the event id and set to array.  | 
                                                        |
| 2075 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null;  | 
                                                        |
| 2076 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;  | 
                                                        |
| 2077 | + // loop thru events  | 
                                                        |
| 2078 | +		if ($EVT_ID) { | 
                                                        |
| 2079 | + $success = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2080 | + // get list of events with no prices  | 
                                                        |
| 2081 | +			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2082 | + // remove this event from the list of events with no prices  | 
                                                        |
| 2083 | +			if (isset($espresso_no_ticket_prices[ $EVT_ID ])) { | 
                                                        |
| 2084 | + unset($espresso_no_ticket_prices[ $EVT_ID ]);  | 
                                                        |
| 2085 | + }  | 
                                                        |
| 2086 | +			update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2087 | +		} else { | 
                                                        |
| 2088 | + $success = false;  | 
                                                        |
| 2089 | + $msg = esc_html__(  | 
                                                        |
| 2090 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2091 | + 'event_espresso'  | 
                                                        |
| 2092 | + );  | 
                                                        |
| 2093 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2094 | + }  | 
                                                        |
| 2095 | +		if ($redirect_after) { | 
                                                        |
| 2096 | + $this->_redirect_after_action(  | 
                                                        |
| 2097 | + $success,  | 
                                                        |
| 2098 | + 'Event',  | 
                                                        |
| 2099 | + 'deleted',  | 
                                                        |
| 2100 | +				array('action' => 'default', 'status' => 'trash') | 
                                                        |
| 2101 | + );  | 
                                                        |
| 2102 | + }  | 
                                                        |
| 2103 | + }  | 
                                                        |
| 2104 | +  | 
                                                        |
| 2105 | +  | 
                                                        |
| 2106 | + /**  | 
                                                        |
| 2107 | + * _delete_events  | 
                                                        |
| 2108 | + *  | 
                                                        |
| 2109 | + * @access protected  | 
                                                        |
| 2110 | + * @return void  | 
                                                        |
| 2111 | + */  | 
                                                        |
| 2112 | + protected function _delete_events()  | 
                                                        |
| 2113 | +	{ | 
                                                        |
| 2114 | + $success = true;  | 
                                                        |
| 2115 | + // get list of events with no prices  | 
                                                        |
| 2116 | +		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); | 
                                                        |
| 2117 | + // determine the event id and set to array.  | 
                                                        |
| 2118 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();  | 
                                                        |
| 2119 | + // loop thru events  | 
                                                        |
| 2120 | +		foreach ($EVT_IDs as $EVT_ID) { | 
                                                        |
| 2121 | + $EVT_ID = absint($EVT_ID);  | 
                                                        |
| 2122 | +			if ($EVT_ID) { | 
                                                        |
| 2123 | + $results = $this->_permanently_delete_event($EVT_ID);  | 
                                                        |
| 2124 | + $success = $results !== false ? $success : false;  | 
                                                        |
| 2125 | + // remove this event from the list of events with no prices  | 
                                                        |
| 2126 | + unset($espresso_no_ticket_prices[ $EVT_ID ]);  | 
                                                        |
| 2127 | +			} else { | 
                                                        |
| 2128 | + $success = false;  | 
                                                        |
| 2129 | + $msg = esc_html__(  | 
                                                        |
| 2130 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.',  | 
                                                        |
| 2131 | + 'event_espresso'  | 
                                                        |
| 2132 | + );  | 
                                                        |
| 2133 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2134 | + }  | 
                                                        |
| 2135 | + }  | 
                                                        |
| 2136 | +		update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); | 
                                                        |
| 2137 | + // in order to force a pluralized result message we need to send back a success status greater than 1  | 
                                                        |
| 2138 | + $success = $success ? 2 : false;  | 
                                                        |
| 2139 | +		$this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); | 
                                                        |
| 2140 | + }  | 
                                                        |
| 2141 | +  | 
                                                        |
| 2142 | +  | 
                                                        |
| 2143 | + /**  | 
                                                        |
| 2144 | + * _permanently_delete_event  | 
                                                        |
| 2145 | + *  | 
                                                        |
| 2146 | + * @access private  | 
                                                        |
| 2147 | + * @param int $EVT_ID  | 
                                                        |
| 2148 | + * @return bool  | 
                                                        |
| 2149 | + */  | 
                                                        |
| 2150 | + private function _permanently_delete_event($EVT_ID = 0)  | 
                                                        |
| 2151 | +	{ | 
                                                        |
| 2152 | + // grab event id  | 
                                                        |
| 2153 | +		if (! $EVT_ID) { | 
                                                        |
| 2154 | + $msg = esc_html__(  | 
                                                        |
| 2155 | + 'An error occurred. No Event ID or an invalid Event ID was received.',  | 
                                                        |
| 2156 | + 'event_espresso'  | 
                                                        |
| 2157 | + );  | 
                                                        |
| 2158 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2159 | + return false;  | 
                                                        |
| 2160 | + }  | 
                                                        |
| 2161 | + if (! $this->_cpt_model_obj instanceof EE_Event  | 
                                                        |
| 2162 | + || $this->_cpt_model_obj->ID() !== $EVT_ID  | 
                                                        |
| 2163 | +		) { | 
                                                        |
| 2164 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);  | 
                                                        |
| 2165 | + }  | 
                                                        |
| 2166 | +		if (! $this->_cpt_model_obj instanceof EE_Event) { | 
                                                        |
| 2167 | + return false;  | 
                                                        |
| 2168 | + }  | 
                                                        |
| 2169 | + // need to delete related tickets and prices first.  | 
                                                        |
| 2170 | +		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); | 
                                                        |
| 2171 | +		foreach ($datetimes as $datetime) { | 
                                                        |
| 2172 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2173 | +			$tickets = $datetime->get_many_related('Ticket'); | 
                                                        |
| 2174 | +			foreach ($tickets as $ticket) { | 
                                                        |
| 2175 | + $ticket->_remove_relation_to($datetime, 'Datetime');  | 
                                                        |
| 2176 | +				$ticket->delete_related_permanently('Price'); | 
                                                        |
| 2177 | + $ticket->delete_permanently();  | 
                                                        |
| 2178 | + }  | 
                                                        |
| 2179 | + $datetime->delete();  | 
                                                        |
| 2180 | + }  | 
                                                        |
| 2181 | + // what about related venues or terms?  | 
                                                        |
| 2182 | +		$venues = $this->_cpt_model_obj->get_many_related('Venue'); | 
                                                        |
| 2183 | +		foreach ($venues as $venue) { | 
                                                        |
| 2184 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');  | 
                                                        |
| 2185 | + }  | 
                                                        |
| 2186 | + // any attached question groups?  | 
                                                        |
| 2187 | +		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); | 
                                                        |
| 2188 | +		if (! empty($question_groups)) { | 
                                                        |
| 2189 | +			foreach ($question_groups as $question_group) { | 
                                                        |
| 2190 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');  | 
                                                        |
| 2191 | + }  | 
                                                        |
| 2192 | + }  | 
                                                        |
| 2193 | + // Message Template Groups  | 
                                                        |
| 2194 | +		$this->_cpt_model_obj->_remove_relations('Message_Template_Group'); | 
                                                        |
| 2195 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */  | 
                                                        |
| 2196 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies();  | 
                                                        |
| 2197 | +		foreach ($term_taxonomies as $term_taxonomy) { | 
                                                        |
| 2198 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);  | 
                                                        |
| 2199 | + }  | 
                                                        |
| 2200 | + $success = $this->_cpt_model_obj->delete_permanently();  | 
                                                        |
| 2201 | + // did it all go as planned ?  | 
                                                        |
| 2202 | +		if ($success) { | 
                                                        |
| 2203 | +			$msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); | 
                                                        |
| 2204 | + EE_Error::add_success($msg);  | 
                                                        |
| 2205 | +		} else { | 
                                                        |
| 2206 | + $msg = sprintf(  | 
                                                        |
| 2207 | +				esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), | 
                                                        |
| 2208 | + $EVT_ID  | 
                                                        |
| 2209 | + );  | 
                                                        |
| 2210 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2211 | + return false;  | 
                                                        |
| 2212 | + }  | 
                                                        |
| 2213 | +		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); | 
                                                        |
| 2214 | + return true;  | 
                                                        |
| 2215 | + }  | 
                                                        |
| 2216 | +  | 
                                                        |
| 2217 | +  | 
                                                        |
| 2218 | + /**  | 
                                                        |
| 2219 | + * get total number of events  | 
                                                        |
| 2220 | + *  | 
                                                        |
| 2221 | + * @access public  | 
                                                        |
| 2222 | + * @return int  | 
                                                        |
| 2223 | + */  | 
                                                        |
| 2224 | + public function total_events()  | 
                                                        |
| 2225 | +	{ | 
                                                        |
| 2226 | +		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); | 
                                                        |
| 2227 | + return $count;  | 
                                                        |
| 2228 | + }  | 
                                                        |
| 2229 | +  | 
                                                        |
| 2230 | +  | 
                                                        |
| 2231 | + /**  | 
                                                        |
| 2232 | + * get total number of draft events  | 
                                                        |
| 2233 | + *  | 
                                                        |
| 2234 | + * @access public  | 
                                                        |
| 2235 | + * @return int  | 
                                                        |
| 2236 | + */  | 
                                                        |
| 2237 | + public function total_events_draft()  | 
                                                        |
| 2238 | +	{ | 
                                                        |
| 2239 | + $where = array(  | 
                                                        |
| 2240 | +			'status' => array('IN', array('draft', 'auto-draft')), | 
                                                        |
| 2241 | + );  | 
                                                        |
| 2242 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2243 | + return $count;  | 
                                                        |
| 2244 | + }  | 
                                                        |
| 2245 | +  | 
                                                        |
| 2246 | +  | 
                                                        |
| 2247 | + /**  | 
                                                        |
| 2248 | + * get total number of trashed events  | 
                                                        |
| 2249 | + *  | 
                                                        |
| 2250 | + * @access public  | 
                                                        |
| 2251 | + * @return int  | 
                                                        |
| 2252 | + */  | 
                                                        |
| 2253 | + public function total_trashed_events()  | 
                                                        |
| 2254 | +	{ | 
                                                        |
| 2255 | + $where = array(  | 
                                                        |
| 2256 | + 'status' => 'trash',  | 
                                                        |
| 2257 | + );  | 
                                                        |
| 2258 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);  | 
                                                        |
| 2259 | + return $count;  | 
                                                        |
| 2260 | + }  | 
                                                        |
| 2261 | +  | 
                                                        |
| 2262 | +  | 
                                                        |
| 2263 | + /**  | 
                                                        |
| 2264 | + * _default_event_settings  | 
                                                        |
| 2265 | + * This generates the Default Settings Tab  | 
                                                        |
| 2266 | + *  | 
                                                        |
| 2267 | + * @return void  | 
                                                        |
| 2268 | + * @throws EE_Error  | 
                                                        |
| 2269 | + */  | 
                                                        |
| 2270 | + protected function _default_event_settings()  | 
                                                        |
| 2271 | +	{ | 
                                                        |
| 2272 | +		$this->_set_add_edit_form_tags('update_default_event_settings'); | 
                                                        |
| 2273 | + $this->_set_publish_post_box_vars(null, false, false, null, false);  | 
                                                        |
| 2274 | + $this->_template_args['admin_page_content'] = $this->_default_event_settings_form()->get_html();  | 
                                                        |
| 2275 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2276 | + }  | 
                                                        |
| 2277 | +  | 
                                                        |
| 2278 | +  | 
                                                        |
| 2279 | + /**  | 
                                                        |
| 2280 | + * Return the form for event settings.  | 
                                                        |
| 2281 | + *  | 
                                                        |
| 2282 | + * @return EE_Form_Section_Proper  | 
                                                        |
| 2283 | + * @throws EE_Error  | 
                                                        |
| 2284 | + */  | 
                                                        |
| 2285 | + protected function _default_event_settings_form()  | 
                                                        |
| 2286 | +	{ | 
                                                        |
| 2287 | + $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2288 | + $registration_stati_for_selection = EEM_Registration::reg_status_array(  | 
                                                        |
| 2289 | + // exclude  | 
                                                        |
| 2290 | + array(  | 
                                                        |
| 2291 | + EEM_Registration::status_id_cancelled,  | 
                                                        |
| 2292 | + EEM_Registration::status_id_declined,  | 
                                                        |
| 2293 | + EEM_Registration::status_id_incomplete,  | 
                                                        |
| 2294 | + EEM_Registration::status_id_wait_list,  | 
                                                        |
| 2295 | + ),  | 
                                                        |
| 2296 | + true  | 
                                                        |
| 2297 | + );  | 
                                                        |
| 2298 | + return new EE_Form_Section_Proper(  | 
                                                        |
| 2299 | + array(  | 
                                                        |
| 2300 | + 'name' => 'update_default_event_settings',  | 
                                                        |
| 2301 | + 'html_id' => 'update_default_event_settings',  | 
                                                        |
| 2302 | + 'html_class' => 'form-table',  | 
                                                        |
| 2303 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(),  | 
                                                        |
| 2304 | + 'subsections' => apply_filters(  | 
                                                        |
| 2305 | + 'FHEE__Events_Admin_Page___default_event_settings_form__form_subsections',  | 
                                                        |
| 2306 | + array(  | 
                                                        |
| 2307 | + 'default_reg_status' => new EE_Select_Input(  | 
                                                        |
| 2308 | + $registration_stati_for_selection,  | 
                                                        |
| 2309 | + array(  | 
                                                        |
| 2310 | + 'default' => isset($registration_config->default_STS_ID)  | 
                                                        |
| 2311 | + && array_key_exists(  | 
                                                        |
| 2312 | + $registration_config->default_STS_ID,  | 
                                                        |
| 2313 | + $registration_stati_for_selection  | 
                                                        |
| 2314 | + )  | 
                                                        |
| 2315 | + ? sanitize_text_field($registration_config->default_STS_ID)  | 
                                                        |
| 2316 | + : EEM_Registration::status_id_pending_payment,  | 
                                                        |
| 2317 | +								'html_label_text' => esc_html__('Default Registration Status', 'event_espresso') | 
                                                        |
| 2318 | + . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2319 | + 'default_settings_status_help_tab'  | 
                                                        |
| 2320 | + ),  | 
                                                        |
| 2321 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 2322 | + 'This setting allows you to preselect what the default registration status setting is when creating an event. Note that changing this setting does NOT retroactively apply it to existing events.',  | 
                                                        |
| 2323 | + 'event_espresso'  | 
                                                        |
| 2324 | + ),  | 
                                                        |
| 2325 | + )  | 
                                                        |
| 2326 | + ),  | 
                                                        |
| 2327 | + 'default_max_tickets' => new EE_Integer_Input(  | 
                                                        |
| 2328 | + array(  | 
                                                        |
| 2329 | + 'default' => isset($registration_config->default_maximum_number_of_tickets)  | 
                                                        |
| 2330 | + ? $registration_config->default_maximum_number_of_tickets  | 
                                                        |
| 2331 | + : EEM_Event::get_default_additional_limit(),  | 
                                                        |
| 2332 | + 'html_label_text' => esc_html__(  | 
                                                        |
| 2333 | + 'Default Maximum Tickets Allowed Per Order:',  | 
                                                        |
| 2334 | + 'event_espresso'  | 
                                                        |
| 2335 | + )  | 
                                                        |
| 2336 | + . EEH_Template::get_help_tab_link(  | 
                                                        |
| 2337 | + 'default_maximum_tickets_help_tab"'  | 
                                                        |
| 2338 | + ),  | 
                                                        |
| 2339 | + 'html_help_text' => esc_html__(  | 
                                                        |
| 2340 | + 'This setting allows you to indicate what will be the default for the maximum number of tickets per order when creating new events.',  | 
                                                        |
| 2341 | + 'event_espresso'  | 
                                                        |
| 2342 | + ),  | 
                                                        |
| 2343 | + )  | 
                                                        |
| 2344 | + ),  | 
                                                        |
| 2345 | + )  | 
                                                        |
| 2346 | + ),  | 
                                                        |
| 2347 | + )  | 
                                                        |
| 2348 | + );  | 
                                                        |
| 2349 | + }  | 
                                                        |
| 2350 | +  | 
                                                        |
| 2351 | +  | 
                                                        |
| 2352 | + /**  | 
                                                        |
| 2353 | + * _update_default_event_settings  | 
                                                        |
| 2354 | + *  | 
                                                        |
| 2355 | + * @access protected  | 
                                                        |
| 2356 | + * @return void  | 
                                                        |
| 2357 | + * @throws EE_Error  | 
                                                        |
| 2358 | + */  | 
                                                        |
| 2359 | + protected function _update_default_event_settings()  | 
                                                        |
| 2360 | +	{ | 
                                                        |
| 2361 | + $registration_config = EE_Registry::instance()->CFG->registration;  | 
                                                        |
| 2362 | + $form = $this->_default_event_settings_form();  | 
                                                        |
| 2363 | +		if ($form->was_submitted()) { | 
                                                        |
| 2364 | + $form->receive_form_submission();  | 
                                                        |
| 2365 | +			if ($form->is_valid()) { | 
                                                        |
| 2366 | + $valid_data = $form->valid_data();  | 
                                                        |
| 2367 | +				if (isset($valid_data['default_reg_status'])) { | 
                                                        |
| 2368 | + $registration_config->default_STS_ID = $valid_data['default_reg_status'];  | 
                                                        |
| 2369 | + }  | 
                                                        |
| 2370 | +				if (isset($valid_data['default_max_tickets'])) { | 
                                                        |
| 2371 | + $registration_config->default_maximum_number_of_tickets = $valid_data['default_max_tickets'];  | 
                                                        |
| 2372 | + }  | 
                                                        |
| 2373 | + // update because data was valid!  | 
                                                        |
| 2374 | + EE_Registry::instance()->CFG->update_espresso_config();  | 
                                                        |
| 2375 | + EE_Error::overwrite_success();  | 
                                                        |
| 2376 | + EE_Error::add_success(  | 
                                                        |
| 2377 | +					__('Default Event Settings were updated', 'event_espresso') | 
                                                        |
| 2378 | + );  | 
                                                        |
| 2379 | + }  | 
                                                        |
| 2380 | + }  | 
                                                        |
| 2381 | +		$this->_redirect_after_action(0, '', '', array('action' => 'default_event_settings'), true); | 
                                                        |
| 2382 | + }  | 
                                                        |
| 2383 | +  | 
                                                        |
| 2384 | +  | 
                                                        |
| 2385 | + /************* Templates *************/  | 
                                                        |
| 2386 | + protected function _template_settings()  | 
                                                        |
| 2387 | +	{ | 
                                                        |
| 2388 | +		$this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); | 
                                                        |
| 2389 | + $this->_template_args['preview_img'] = '<img src="'  | 
                                                        |
| 2390 | + . EVENTS_ASSETS_URL  | 
                                                        |
| 2391 | + . DS  | 
                                                        |
| 2392 | + . 'images'  | 
                                                        |
| 2393 | + . DS  | 
                                                        |
| 2394 | + . 'caffeinated_template_features.jpg" alt="'  | 
                                                        |
| 2395 | +											   . esc_attr__('Template Settings Preview screenshot', 'event_espresso') | 
                                                        |
| 2396 | + . '" />';  | 
                                                        |
| 2397 | + $this->_template_args['preview_text'] = '<strong>'  | 
                                                        |
| 2398 | + . esc_html__(  | 
                                                        |
| 2399 | + 'Template Settings is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.',  | 
                                                        |
| 2400 | + 'event_espresso'  | 
                                                        |
| 2401 | + ) . '</strong>';  | 
                                                        |
| 2402 | +		$this->display_admin_caf_preview_page('template_settings_tab'); | 
                                                        |
| 2403 | + }  | 
                                                        |
| 2404 | +  | 
                                                        |
| 2405 | +  | 
                                                        |
| 2406 | + /** Event Category Stuff **/  | 
                                                        |
| 2407 | + /**  | 
                                                        |
| 2408 | + * set the _category property with the category object for the loaded page.  | 
                                                        |
| 2409 | + *  | 
                                                        |
| 2410 | + * @access private  | 
                                                        |
| 2411 | + * @return void  | 
                                                        |
| 2412 | + */  | 
                                                        |
| 2413 | + private function _set_category_object()  | 
                                                        |
| 2414 | +	{ | 
                                                        |
| 2415 | +		if (isset($this->_category->id) && ! empty($this->_category->id)) { | 
                                                        |
| 2416 | + return;  | 
                                                        |
| 2417 | + } //already have the category object so get out.  | 
                                                        |
| 2418 | + // set default category object  | 
                                                        |
| 2419 | + $this->_set_empty_category_object();  | 
                                                        |
| 2420 | + // only set if we've got an id  | 
                                                        |
| 2421 | +		if (! isset($this->_req_data['EVT_CAT_ID'])) { | 
                                                        |
| 2422 | + return;  | 
                                                        |
| 2423 | + }  | 
                                                        |
| 2424 | + $category_id = absint($this->_req_data['EVT_CAT_ID']);  | 
                                                        |
| 2425 | + $term = get_term($category_id, 'espresso_event_categories');  | 
                                                        |
| 2426 | +		if (! empty($term)) { | 
                                                        |
| 2427 | + $this->_category->category_name = $term->name;  | 
                                                        |
| 2428 | + $this->_category->category_identifier = $term->slug;  | 
                                                        |
| 2429 | + $this->_category->category_desc = $term->description;  | 
                                                        |
| 2430 | + $this->_category->id = $term->term_id;  | 
                                                        |
| 2431 | + $this->_category->parent = $term->parent;  | 
                                                        |
| 2432 | + }  | 
                                                        |
| 2433 | + }  | 
                                                        |
| 2434 | +  | 
                                                        |
| 2435 | +  | 
                                                        |
| 2436 | + /**  | 
                                                        |
| 2437 | + * Clears out category properties.  | 
                                                        |
| 2438 | + */  | 
                                                        |
| 2439 | + private function _set_empty_category_object()  | 
                                                        |
| 2440 | +	{ | 
                                                        |
| 2441 | + $this->_category = new stdClass();  | 
                                                        |
| 2442 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';  | 
                                                        |
| 2443 | + $this->_category->id = $this->_category->parent = 0;  | 
                                                        |
| 2444 | + }  | 
                                                        |
| 2445 | +  | 
                                                        |
| 2446 | +  | 
                                                        |
| 2447 | + /**  | 
                                                        |
| 2448 | + * @throws EE_Error  | 
                                                        |
| 2449 | + */  | 
                                                        |
| 2450 | + protected function _category_list_table()  | 
                                                        |
| 2451 | +	{ | 
                                                        |
| 2452 | +		do_action('AHEE_log', __FILE__, __FUNCTION__, ''); | 
                                                        |
| 2453 | +		$this->_search_btn_label = esc_html__('Categories', 'event_espresso'); | 
                                                        |
| 2454 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(  | 
                                                        |
| 2455 | + 'add_category',  | 
                                                        |
| 2456 | + 'add_category',  | 
                                                        |
| 2457 | + array(),  | 
                                                        |
| 2458 | + 'add-new-h2'  | 
                                                        |
| 2459 | + );  | 
                                                        |
| 2460 | + $this->display_admin_list_table_page_with_sidebar();  | 
                                                        |
| 2461 | + }  | 
                                                        |
| 2462 | +  | 
                                                        |
| 2463 | +  | 
                                                        |
| 2464 | + /**  | 
                                                        |
| 2465 | + * Output category details view.  | 
                                                        |
| 2466 | + */  | 
                                                        |
| 2467 | + protected function _category_details($view)  | 
                                                        |
| 2468 | +	{ | 
                                                        |
| 2469 | + // load formatter helper  | 
                                                        |
| 2470 | + // load field generator helper  | 
                                                        |
| 2471 | + $route = $view == 'edit' ? 'update_category' : 'insert_category';  | 
                                                        |
| 2472 | + $this->_set_add_edit_form_tags($route);  | 
                                                        |
| 2473 | + $this->_set_category_object();  | 
                                                        |
| 2474 | + $id = ! empty($this->_category->id) ? $this->_category->id : '';  | 
                                                        |
| 2475 | + $delete_action = 'delete_category';  | 
                                                        |
| 2476 | + // custom redirect  | 
                                                        |
| 2477 | + $redirect = EE_Admin_Page::add_query_args_and_nonce(  | 
                                                        |
| 2478 | +			array('action' => 'category_list'), | 
                                                        |
| 2479 | + $this->_admin_base_url  | 
                                                        |
| 2480 | + );  | 
                                                        |
| 2481 | +		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); | 
                                                        |
| 2482 | + // take care of contents  | 
                                                        |
| 2483 | + $this->_template_args['admin_page_content'] = $this->_category_details_content();  | 
                                                        |
| 2484 | + $this->display_admin_page_with_sidebar();  | 
                                                        |
| 2485 | + }  | 
                                                        |
| 2486 | +  | 
                                                        |
| 2487 | +  | 
                                                        |
| 2488 | + /**  | 
                                                        |
| 2489 | + * Output category details content.  | 
                                                        |
| 2490 | + */  | 
                                                        |
| 2491 | + protected function _category_details_content()  | 
                                                        |
| 2492 | +	{ | 
                                                        |
| 2493 | + $editor_args['category_desc'] = array(  | 
                                                        |
| 2494 | + 'type' => 'wp_editor',  | 
                                                        |
| 2495 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),  | 
                                                        |
| 2496 | + 'class' => 'my_editor_custom',  | 
                                                        |
| 2497 | +			'wpeditor_args' => array('media_buttons' => false), | 
                                                        |
| 2498 | + );  | 
                                                        |
| 2499 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');  | 
                                                        |
| 2500 | + $all_terms = get_terms(  | 
                                                        |
| 2501 | +			array('espresso_event_categories'), | 
                                                        |
| 2502 | +			array('hide_empty' => 0, 'exclude' => array($this->_category->id)) | 
                                                        |
| 2503 | + );  | 
                                                        |
| 2504 | + // setup category select for term parents.  | 
                                                        |
| 2505 | + $category_select_values[] = array(  | 
                                                        |
| 2506 | +			'text' => esc_html__('No Parent', 'event_espresso'), | 
                                                        |
| 2507 | + 'id' => 0,  | 
                                                        |
| 2508 | + );  | 
                                                        |
| 2509 | +		foreach ($all_terms as $term) { | 
                                                        |
| 2510 | + $category_select_values[] = array(  | 
                                                        |
| 2511 | + 'text' => $term->name,  | 
                                                        |
| 2512 | + 'id' => $term->term_id,  | 
                                                        |
| 2513 | + );  | 
                                                        |
| 2514 | + }  | 
                                                        |
| 2515 | + $category_select = EEH_Form_Fields::select_input(  | 
                                                        |
| 2516 | + 'category_parent',  | 
                                                        |
| 2517 | + $category_select_values,  | 
                                                        |
| 2518 | + $this->_category->parent  | 
                                                        |
| 2519 | + );  | 
                                                        |
| 2520 | + $template_args = array(  | 
                                                        |
| 2521 | + 'category' => $this->_category,  | 
                                                        |
| 2522 | + 'category_select' => $category_select,  | 
                                                        |
| 2523 | +			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), | 
                                                        |
| 2524 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'],  | 
                                                        |
| 2525 | + 'disable' => '',  | 
                                                        |
| 2526 | + 'disabled_message' => false,  | 
                                                        |
| 2527 | + );  | 
                                                        |
| 2528 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';  | 
                                                        |
| 2529 | + return EEH_Template::display_template($template, $template_args, true);  | 
                                                        |
| 2530 | + }  | 
                                                        |
| 2531 | +  | 
                                                        |
| 2532 | +  | 
                                                        |
| 2533 | + /**  | 
                                                        |
| 2534 | + * Handles deleting categories.  | 
                                                        |
| 2535 | + */  | 
                                                        |
| 2536 | + protected function _delete_categories()  | 
                                                        |
| 2537 | +	{ | 
                                                        |
| 2538 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID']  | 
                                                        |
| 2539 | + : (array) $this->_req_data['category_id'];  | 
                                                        |
| 2540 | +		foreach ($cat_ids as $cat_id) { | 
                                                        |
| 2541 | + $this->_delete_category($cat_id);  | 
                                                        |
| 2542 | + }  | 
                                                        |
| 2543 | + // doesn't matter what page we're coming from... we're going to the same place after delete.  | 
                                                        |
| 2544 | + $query_args = array(  | 
                                                        |
| 2545 | + 'action' => 'category_list',  | 
                                                        |
| 2546 | + );  | 
                                                        |
| 2547 | + $this->_redirect_after_action(0, '', '', $query_args);  | 
                                                        |
| 2548 | + }  | 
                                                        |
| 2549 | +  | 
                                                        |
| 2550 | +  | 
                                                        |
| 2551 | + /**  | 
                                                        |
| 2552 | + * Handles deleting specific category.  | 
                                                        |
| 2553 | + *  | 
                                                        |
| 2554 | + * @param int $cat_id  | 
                                                        |
| 2555 | + */  | 
                                                        |
| 2556 | + protected function _delete_category($cat_id)  | 
                                                        |
| 2557 | +	{ | 
                                                        |
| 2558 | + $cat_id = absint($cat_id);  | 
                                                        |
| 2559 | + wp_delete_term($cat_id, 'espresso_event_categories');  | 
                                                        |
| 2560 | + }  | 
                                                        |
| 2561 | +  | 
                                                        |
| 2562 | +  | 
                                                        |
| 2563 | + /**  | 
                                                        |
| 2564 | + * Handles triggering the update or insertion of a new category.  | 
                                                        |
| 2565 | + *  | 
                                                        |
| 2566 | + * @param bool $new_category true means we're triggering the insert of a new category.  | 
                                                        |
| 2567 | + */  | 
                                                        |
| 2568 | + protected function _insert_or_update_category($new_category)  | 
                                                        |
| 2569 | +	{ | 
                                                        |
| 2570 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true);  | 
                                                        |
| 2571 | + $success = 0; // we already have a success message so lets not send another.  | 
                                                        |
| 2572 | +		if ($cat_id) { | 
                                                        |
| 2573 | + $query_args = array(  | 
                                                        |
| 2574 | + 'action' => 'edit_category',  | 
                                                        |
| 2575 | + 'EVT_CAT_ID' => $cat_id,  | 
                                                        |
| 2576 | + );  | 
                                                        |
| 2577 | +		} else { | 
                                                        |
| 2578 | +			$query_args = array('action' => 'add_category'); | 
                                                        |
| 2579 | + }  | 
                                                        |
| 2580 | + $this->_redirect_after_action($success, '', '', $query_args, true);  | 
                                                        |
| 2581 | + }  | 
                                                        |
| 2582 | +  | 
                                                        |
| 2583 | +  | 
                                                        |
| 2584 | + /**  | 
                                                        |
| 2585 | + * Inserts or updates category  | 
                                                        |
| 2586 | + *  | 
                                                        |
| 2587 | + * @param bool $update (true indicates we're updating a category).  | 
                                                        |
| 2588 | + * @return bool|mixed|string  | 
                                                        |
| 2589 | + */  | 
                                                        |
| 2590 | + private function _insert_category($update = false)  | 
                                                        |
| 2591 | +	{ | 
                                                        |
| 2592 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';  | 
                                                        |
| 2593 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';  | 
                                                        |
| 2594 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';  | 
                                                        |
| 2595 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;  | 
                                                        |
| 2596 | +		if (empty($category_name)) { | 
                                                        |
| 2597 | +			$msg = esc_html__('You must add a name for the category.', 'event_espresso'); | 
                                                        |
| 2598 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2599 | + return false;  | 
                                                        |
| 2600 | + }  | 
                                                        |
| 2601 | + $term_args = array(  | 
                                                        |
| 2602 | + 'name' => $category_name,  | 
                                                        |
| 2603 | + 'description' => $category_desc,  | 
                                                        |
| 2604 | + 'parent' => $category_parent,  | 
                                                        |
| 2605 | + );  | 
                                                        |
| 2606 | + // was the category_identifier input disabled?  | 
                                                        |
| 2607 | +		if (isset($this->_req_data['category_identifier'])) { | 
                                                        |
| 2608 | + $term_args['slug'] = $this->_req_data['category_identifier'];  | 
                                                        |
| 2609 | + }  | 
                                                        |
| 2610 | + $insert_ids = $update  | 
                                                        |
| 2611 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args)  | 
                                                        |
| 2612 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args);  | 
                                                        |
| 2613 | +		if (! is_array($insert_ids)) { | 
                                                        |
| 2614 | + $msg = esc_html__(  | 
                                                        |
| 2615 | + 'An error occurred and the category has not been saved to the database.',  | 
                                                        |
| 2616 | + 'event_espresso'  | 
                                                        |
| 2617 | + );  | 
                                                        |
| 2618 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);  | 
                                                        |
| 2619 | +		} else { | 
                                                        |
| 2620 | + $cat_id = $insert_ids['term_id'];  | 
                                                        |
| 2621 | +			$msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); | 
                                                        |
| 2622 | + EE_Error::add_success($msg);  | 
                                                        |
| 2623 | + }  | 
                                                        |
| 2624 | + return $cat_id;  | 
                                                        |
| 2625 | + }  | 
                                                        |
| 2626 | +  | 
                                                        |
| 2627 | +  | 
                                                        |
| 2628 | + /**  | 
                                                        |
| 2629 | + * Gets categories or count of categories matching the arguments in the request.  | 
                                                        |
| 2630 | + *  | 
                                                        |
| 2631 | + * @param int $per_page  | 
                                                        |
| 2632 | + * @param int $current_page  | 
                                                        |
| 2633 | + * @param bool $count  | 
                                                        |
| 2634 | + * @return EE_Base_Class[]|EE_Term_Taxonomy[]|int  | 
                                                        |
| 2635 | + */  | 
                                                        |
| 2636 | + public function get_categories($per_page = 10, $current_page = 1, $count = false)  | 
                                                        |
| 2637 | +	{ | 
                                                        |
| 2638 | + // testing term stuff  | 
                                                        |
| 2639 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';  | 
                                                        |
| 2640 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';  | 
                                                        |
| 2641 | + $limit = ($current_page - 1) * $per_page;  | 
                                                        |
| 2642 | +		$where = array('taxonomy' => 'espresso_event_categories'); | 
                                                        |
| 2643 | +		if (isset($this->_req_data['s'])) { | 
                                                        |
| 2644 | + $sstr = '%' . $this->_req_data['s'] . '%';  | 
                                                        |
| 2645 | + $where['OR'] = array(  | 
                                                        |
| 2646 | +				'Term.name'   => array('LIKE', $sstr), | 
                                                        |
| 2647 | +				'description' => array('LIKE', $sstr), | 
                                                        |
| 2648 | + );  | 
                                                        |
| 2649 | + }  | 
                                                        |
| 2650 | + $query_params = array(  | 
                                                        |
| 2651 | + $where,  | 
                                                        |
| 2652 | + 'order_by' => array($orderby => $order),  | 
                                                        |
| 2653 | + 'limit' => $limit . ',' . $per_page,  | 
                                                        |
| 2654 | +			'force_join' => array('Term'), | 
                                                        |
| 2655 | + );  | 
                                                        |
| 2656 | + $categories = $count  | 
                                                        |
| 2657 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')  | 
                                                        |
| 2658 | + : EEM_Term_Taxonomy::instance()->get_all($query_params);  | 
                                                        |
| 2659 | + return $categories;  | 
                                                        |
| 2660 | + }  | 
                                                        |
| 2661 | +  | 
                                                        |
| 2662 | + /* end category stuff */  | 
                                                        |
| 2663 | + /**************/  | 
                                                        |
| 2664 | +  | 
                                                        |
| 2665 | +  | 
                                                        |
| 2666 | + /**  | 
                                                        |
| 2667 | + * Callback for the `ee_save_timezone_setting` ajax action.  | 
                                                        |
| 2668 | + *  | 
                                                        |
| 2669 | + * @throws EE_Error  | 
                                                        |
| 2670 | + */  | 
                                                        |
| 2671 | + public function save_timezonestring_setting()  | 
                                                        |
| 2672 | +	{ | 
                                                        |
| 2673 | + $timezone_string = isset($this->_req_data['timezone_selected'])  | 
                                                        |
| 2674 | + ? $this->_req_data['timezone_selected']  | 
                                                        |
| 2675 | + : '';  | 
                                                        |
| 2676 | +		if (empty($timezone_string) || ! EEH_DTT_Helper::validate_timezone($timezone_string, false)) { | 
                                                        |
| 2677 | + EE_Error::add_error(  | 
                                                        |
| 2678 | +				esc_html__('An invalid timezone string submitted.', 'event_espresso'), | 
                                                        |
| 2679 | + __FILE__,  | 
                                                        |
| 2680 | + __FUNCTION__,  | 
                                                        |
| 2681 | + __LINE__  | 
                                                        |
| 2682 | + );  | 
                                                        |
| 2683 | + $this->_template_args['error'] = true;  | 
                                                        |
| 2684 | + $this->_return_json();  | 
                                                        |
| 2685 | + }  | 
                                                        |
| 2686 | +  | 
                                                        |
| 2687 | +		update_option('timezone_string', $timezone_string); | 
                                                        |
| 2688 | + EE_Error::add_success(  | 
                                                        |
| 2689 | +			esc_html__('Your timezone string was updated.', 'event_espresso') | 
                                                        |
| 2690 | + );  | 
                                                        |
| 2691 | + $this->_template_args['success'] = true;  | 
                                                        |
| 2692 | +		$this->_return_json(true, array('action' => 'create_new')); | 
                                                        |
| 2693 | + }  | 
                                                        |
| 2694 | 2694 | }  |