@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Brent Christensen |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table{ |
|
| 16 | +class EE_DMS_4_6_0_state_system_question extends EE_Data_Migration_Script_Stage_Table { |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | global $wpdb; |
| 27 | - $this->_pretty_name = __( 'State - System Question', 'event_espresso' ); |
|
| 27 | + $this->_pretty_name = __('State - System Question', 'event_espresso'); |
|
| 28 | 28 | $this->_old_table = $wpdb->prefix.'esp_question'; |
| 29 | 29 | $this->_extra_where_sql = "WHERE QST_system = 'state'"; |
| 30 | 30 | parent::__construct(); |
@@ -37,21 +37,21 @@ discard block |
||
| 37 | 37 | * @param array $question an associative array where keys are column names and values are their values. |
| 38 | 38 | * @return null |
| 39 | 39 | */ |
| 40 | - protected function _migrate_old_row( $question ) { |
|
| 41 | - if ( $question['QST_ID'] && $question['QST_system'] == 'state' ) { |
|
| 40 | + protected function _migrate_old_row($question) { |
|
| 41 | + if ($question['QST_ID'] && $question['QST_system'] == 'state') { |
|
| 42 | 42 | global $wpdb; |
| 43 | 43 | $success = $wpdb->update( |
| 44 | 44 | $this->_old_table, |
| 45 | - array( 'QST_type' => 'STATE' ), // data |
|
| 46 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 47 | - array( '%s' ), // data format |
|
| 48 | - array( '%d' ) // where format |
|
| 45 | + array('QST_type' => 'STATE'), // data |
|
| 46 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 47 | + array('%s'), // data format |
|
| 48 | + array('%d') // where format |
|
| 49 | 49 | ); |
| 50 | - if ( ! $success ) { |
|
| 50 | + if ( ! $success) { |
|
| 51 | 51 | $this->add_error( |
| 52 | 52 | sprintf( |
| 53 | - __( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ), |
|
| 54 | - wp_json_encode( $question['QST_system'] ), |
|
| 53 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 54 | + wp_json_encode($question['QST_system']), |
|
| 55 | 55 | $question['QST_ID'], |
| 56 | 56 | $wpdb->last_error |
| 57 | 57 | ) |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | 28 | global $wpdb; |
| 29 | - $this->_pretty_name = __( 'Question Types', 'event_espresso' ); |
|
| 29 | + $this->_pretty_name = __('Question Types', 'event_espresso'); |
|
| 30 | 30 | $this->_old_table = $wpdb->prefix.'esp_question'; |
| 31 | 31 | $this->_question_type_conversions = array( |
| 32 | 32 | 'MULTIPLE' => 'CHECKBOX', |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | //when fetching rows, because we automatically use a limit and offset |
| 36 | 36 | //rows counted before migrating any rows, need to ALSO be counted after a bunch of rows were counted |
| 37 | 37 | //so we need to include both the migrated rows as well as the non-migrated rows |
| 38 | - $QST_types_to_count = array_merge( array_keys( $this->_question_type_conversions ), $this->_question_type_conversions ); |
|
| 39 | - $this->_extra_where_sql = "WHERE QST_type IN ('" . implode( "', '", $QST_types_to_count ) . "')" ; |
|
| 38 | + $QST_types_to_count = array_merge(array_keys($this->_question_type_conversions), $this->_question_type_conversions); |
|
| 39 | + $this->_extra_where_sql = "WHERE QST_type IN ('".implode("', '", $QST_types_to_count)."')"; |
|
| 40 | 40 | parent::__construct(); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | * @param array $question an associative array where keys are column names and values are their values. |
| 45 | 45 | * @return null |
| 46 | 46 | */ |
| 47 | - protected function _migrate_old_row( $question ) { |
|
| 47 | + protected function _migrate_old_row($question) { |
|
| 48 | 48 | global $wpdb; |
| 49 | - if ( $question['QST_ID'] && isset( $this->_question_type_conversions[ $question['QST_type'] ] )) { |
|
| 49 | + if ($question['QST_ID'] && isset($this->_question_type_conversions[$question['QST_type']])) { |
|
| 50 | 50 | $success = $wpdb->update( |
| 51 | 51 | $this->_old_table, |
| 52 | - array( 'QST_type' => $this->_question_type_conversions[ $question['QST_type'] ] ), // data |
|
| 53 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 54 | - array( '%s' ), // data format |
|
| 55 | - array( '%d' ) // where format |
|
| 52 | + array('QST_type' => $this->_question_type_conversions[$question['QST_type']]), // data |
|
| 53 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 54 | + array('%s'), // data format |
|
| 55 | + array('%d') // where format |
|
| 56 | 56 | ); |
| 57 | - if ( ! $success ) { |
|
| 57 | + if ( ! $success) { |
|
| 58 | 58 | $this->add_error( |
| 59 | 59 | sprintf( |
| 60 | - __( 'Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso' ), |
|
| 61 | - wp_json_encode( $question['QST_type'] ), |
|
| 60 | + __('Could not update question type %1$s for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 61 | + wp_json_encode($question['QST_type']), |
|
| 62 | 62 | $question['QST_ID'], |
| 63 | 63 | $wpdb->last_error |
| 64 | 64 | ) |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Brent Christensen |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table{ |
|
| 16 | +class EE_DMS_4_6_0_country_system_question extends EE_Data_Migration_Script_Stage_Table { |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | global $wpdb; |
| 27 | - $this->_pretty_name = __( 'Country - System Question', 'event_espresso' ); |
|
| 27 | + $this->_pretty_name = __('Country - System Question', 'event_espresso'); |
|
| 28 | 28 | $this->_old_table = $wpdb->prefix.'esp_question'; |
| 29 | 29 | $this->_extra_where_sql = "WHERE QST_system = 'country'"; |
| 30 | 30 | parent::__construct(); |
@@ -37,21 +37,21 @@ discard block |
||
| 37 | 37 | * @param array $question an associative array where keys are column names and values are their values. |
| 38 | 38 | * @return null |
| 39 | 39 | */ |
| 40 | - protected function _migrate_old_row( $question ) { |
|
| 41 | - if ( $question['QST_ID'] && $question['QST_system'] == 'country' ) { |
|
| 40 | + protected function _migrate_old_row($question) { |
|
| 41 | + if ($question['QST_ID'] && $question['QST_system'] == 'country') { |
|
| 42 | 42 | global $wpdb; |
| 43 | 43 | $success = $wpdb->update( |
| 44 | 44 | $this->_old_table, |
| 45 | - array( 'QST_type' => 'COUNTRY' ), // data |
|
| 46 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 47 | - array( '%s' ), // data format |
|
| 48 | - array( '%d' ) // where format |
|
| 45 | + array('QST_type' => 'COUNTRY'), // data |
|
| 46 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 47 | + array('%s'), // data format |
|
| 48 | + array('%d') // where format |
|
| 49 | 49 | ); |
| 50 | - if ( ! $success ) { |
|
| 50 | + if ( ! $success) { |
|
| 51 | 51 | $this->add_error( |
| 52 | 52 | sprintf( |
| 53 | - __( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ), |
|
| 54 | - wp_json_encode( $question['QST_system'] ), |
|
| 53 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 54 | + wp_json_encode($question['QST_system']), |
|
| 55 | 55 | $question['QST_ID'], |
| 56 | 56 | $wpdb->last_error |
| 57 | 57 | ) |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * Migrates 4.1-4.5-style gateway settings (which were stores in EE_Config) |
| 15 | 15 | * to 4.6-style payment methods (which have their database table) |
| 16 | 16 | */ |
| 17 | -class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage{ |
|
| 17 | +class EE_DMS_4_6_0_gateways extends EE_Data_Migration_Script_Stage { |
|
| 18 | 18 | |
| 19 | 19 | protected $_new_table_name; |
| 20 | 20 | protected $_extra_meta_table_name; |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | protected function _migration_step($num_items_to_migrate = 50) { |
| 75 | 75 | $items_actually_migrated = 0; |
| 76 | - $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings,$this->count_records_migrated(),$num_items_to_migrate); |
|
| 77 | - foreach($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings){ |
|
| 76 | + $gateways_to_deal_with = array_slice(EE_Config::instance()->gateway->payment_settings, $this->count_records_migrated(), $num_items_to_migrate); |
|
| 77 | + foreach ($gateways_to_deal_with as $old_gateway_slug => $old_gateway_settings) { |
|
| 78 | 78 | |
| 79 | - if( in_array( $old_gateway_slug, $this->_gateway_we_know_to_migrate ) ) { |
|
| 80 | - if( ! $old_gateway_settings){ |
|
| 79 | + if (in_array($old_gateway_slug, $this->_gateway_we_know_to_migrate)) { |
|
| 80 | + if ( ! $old_gateway_settings) { |
|
| 81 | 81 | //no settings existed for this gateway anyways... weird... |
| 82 | 82 | $items_actually_migrated++; |
| 83 | 83 | continue; |
@@ -86,16 +86,16 @@ discard block |
||
| 86 | 86 | $success = $this->_convert_gateway_settings( |
| 87 | 87 | $old_gateway_slug, |
| 88 | 88 | $old_gateway_settings, |
| 89 | - isset( EE_Config::instance()->gateway->active_gateways[ $old_gateway_slug ] ) ); |
|
| 90 | - if( $success ) { |
|
| 91 | - EE_Config::instance()->gateway->payment_settings[ $old_gateway_slug ] = 'Deprecated'; |
|
| 89 | + isset(EE_Config::instance()->gateway->active_gateways[$old_gateway_slug]) ); |
|
| 90 | + if ($success) { |
|
| 91 | + EE_Config::instance()->gateway->payment_settings[$old_gateway_slug] = 'Deprecated'; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | $items_actually_migrated++; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - EE_Config::instance()->update_espresso_config(false,false); |
|
| 98 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 97 | + EE_Config::instance()->update_espresso_config(false, false); |
|
| 98 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 99 | 99 | $this->set_completed(); |
| 100 | 100 | } |
| 101 | 101 | return $items_actually_migrated; |
@@ -108,22 +108,22 @@ discard block |
||
| 108 | 108 | * @param boolean $active indicates the gateway is currently active |
| 109 | 109 | * @return boolean success |
| 110 | 110 | */ |
| 111 | - protected function _convert_gateway_settings($old_gateway_slug,$old_gateway_settings,$active){ |
|
| 112 | - switch($old_gateway_slug){ |
|
| 111 | + protected function _convert_gateway_settings($old_gateway_slug, $old_gateway_settings, $active) { |
|
| 112 | + switch ($old_gateway_slug) { |
|
| 113 | 113 | case 'Aim': |
| 114 | 114 | $extra_meta_key_values = array( |
| 115 | 115 | 'login_id'=>$old_gateway_settings['authnet_aim_login_id'], |
| 116 | 116 | 'transaction_key'=>$old_gateway_settings['authnet_aim_transaction_key'], |
| 117 | 117 | 'test_transactions'=>$old_gateway_settings['test_transactions'] |
| 118 | 118 | ); |
| 119 | - $desc = __( 'Please provide the following billing information.', 'event_espresso' ); |
|
| 119 | + $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 120 | 120 | break; |
| 121 | 121 | case 'Bank': |
| 122 | 122 | $extra_meta_key_values = array( |
| 123 | 123 | 'page_title'=>$old_gateway_settings['page_title'], |
| 124 | 124 | 'payment_instructions'=> |
| 125 | - sprintf( __('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'] , $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address'] ) ); |
|
| 126 | - $desc = __( 'Make payment using an electronic funds transfer from your bank.', 'event_espresso' ); |
|
| 125 | + sprintf(__('%1$s<br/>Name on Bank Account: %2$s<br/>Bank Account Number: %3$s<br/>Bank Name: %4$s<br/>Bank Address:%5$s', 'event_espresso'), $old_gateway_settings['bank_instructions'], $old_gateway_settings['account_name'], $old_gateway_settings['account_number'], $old_gateway_settings['bank_name'], $old_gateway_settings['bank_address']) ); |
|
| 126 | + $desc = __('Make payment using an electronic funds transfer from your bank.', 'event_espresso'); |
|
| 127 | 127 | break; |
| 128 | 128 | case 'Check': |
| 129 | 129 | $extra_meta_key_values = array( |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | 'payment_instructions'=>$old_gateway_settings['check_instructions'], |
| 132 | 132 | 'address_to_send_payment'=>$old_gateway_settings['payment_address'] |
| 133 | 133 | ); |
| 134 | - $desc = __( 'On the next page you will be given instructions on how to make a payment by check.', 'event_espresso' ); |
|
| 134 | + $desc = __('On the next page you will be given instructions on how to make a payment by check.', 'event_espresso'); |
|
| 135 | 135 | break; |
| 136 | 136 | case 'Invoice': |
| 137 | 137 | $extra_meta_key_values = array( |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | 'pdf_payee_email' => $old_gateway_settings['template_invoice_email'], |
| 140 | 140 | 'pdf_payee_tax_number' => $old_gateway_settings['template_invoice_tax_number'], |
| 141 | 141 | 'pdf_payee_address' => $old_gateway_settings['template_invoice_address'], |
| 142 | - 'pdf_instructions' => $old_gateway_settings[ 'template_payment_instructions' ], |
|
| 143 | - 'pdf_logo_image' => $old_gateway_settings[ 'invoice_logo_url' ], |
|
| 144 | - 'page_confirmation_text' => isset( $old_gateway_settings[ 'page_instructions' ] ) ? $old_gateway_settings[ 'page_instructions' ] : '', |
|
| 145 | - 'page_extra_info' => isset( $old_gateway_settings[ 'payment_address' ] ) ? $old_gateway_settings[ 'payment_address' ] : '', |
|
| 142 | + 'pdf_instructions' => $old_gateway_settings['template_payment_instructions'], |
|
| 143 | + 'pdf_logo_image' => $old_gateway_settings['invoice_logo_url'], |
|
| 144 | + 'page_confirmation_text' => isset($old_gateway_settings['page_instructions']) ? $old_gateway_settings['page_instructions'] : '', |
|
| 145 | + 'page_extra_info' => isset($old_gateway_settings['payment_address']) ? $old_gateway_settings['payment_address'] : '', |
|
| 146 | 146 | 'legacy_invoice_css' => $old_gateway_settings['invoice_css'] |
| 147 | 147 | ); |
| 148 | 148 | //if they didnt want the invoiec gateway to show, pretend it was inactive |
| 149 | - if( ! $old_gateway_settings['show'] ){ |
|
| 149 | + if ( ! $old_gateway_settings['show']) { |
|
| 150 | 150 | $active = FALSE; |
| 151 | 151 | } |
| 152 | - $desc = __( 'On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso' ); |
|
| 152 | + $desc = __('On the next page you will be able to access your invoice and instructions on how to pay it.', 'event_espresso'); |
|
| 153 | 153 | break; |
| 154 | 154 | case 'Mijireh': |
| 155 | 155 | $extra_meta_key_values = array( |
| 156 | - 'access_key' => $old_gateway_settings[ 'access_key' ] |
|
| 156 | + 'access_key' => $old_gateway_settings['access_key'] |
|
| 157 | 157 | ); |
| 158 | - $desc = __( 'On the next page you will be able to enter your billing information to make the payment.', 'event_espresso' ); |
|
| 158 | + $desc = __('On the next page you will be able to enter your billing information to make the payment.', 'event_espresso'); |
|
| 159 | 159 | break; |
| 160 | 160 | case 'Paypal_Pro': |
| 161 | 161 | $extra_meta_key_values = array( |
@@ -164,31 +164,31 @@ discard block |
||
| 164 | 164 | 'signature'=>$old_gateway_settings['signature'], |
| 165 | 165 | 'credit_card_types'=>$old_gateway_settings['credit_cards'], |
| 166 | 166 | ); |
| 167 | - $desc = __( 'Please provide the following billing information.', 'event_espresso' ); |
|
| 167 | + $desc = __('Please provide the following billing information.', 'event_espresso'); |
|
| 168 | 168 | break; |
| 169 | 169 | case 'Paypal_Standard': |
| 170 | 170 | $extra_meta_key_values = array( |
| 171 | - 'paypal_id' => $old_gateway_settings[ 'paypal_id' ], |
|
| 172 | - 'image_url' => $old_gateway_settings[ 'image_url' ], |
|
| 173 | - 'shipping_details' => isset( $old_gateway_settings[ 'no_shipping' ] ) ? $old_gateway_settings[ 'no_shipping' ] : false, |
|
| 171 | + 'paypal_id' => $old_gateway_settings['paypal_id'], |
|
| 172 | + 'image_url' => $old_gateway_settings['image_url'], |
|
| 173 | + 'shipping_details' => isset($old_gateway_settings['no_shipping']) ? $old_gateway_settings['no_shipping'] : false, |
|
| 174 | 174 | |
| 175 | 175 | ); |
| 176 | - $desc = sprintf( __( 'After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso' ), '<strong>','</strong>' ); |
|
| 176 | + $desc = sprintf(__('After clicking \'Finalize Registration\', you will be forwarded to PayPal to make your payment. Make sure you return to this site in order to properly finalize your registration.', 'event_espresso'), '<strong>', '</strong>'); |
|
| 177 | 177 | break; |
| 178 | 178 | default: |
| 179 | 179 | //if we don't recognize the payment method, just put everything in it into extra meta. At least this way its preserved somewhere |
| 180 | 180 | $extra_meta_key_values = $old_gateway_settings; |
| 181 | 181 | $desc = ''; |
| 182 | 182 | } |
| 183 | - $pretty_name = isset( $old_gateway_settings[ 'display_name' ] ) ? $old_gateway_settings[ 'display_name' ] : $old_gateway_slug; |
|
| 184 | - $offline_gateways = array( 'Bank', 'Check', 'Invoice' ); |
|
| 185 | - if( $active && in_array( $old_gateway_slug, $offline_gateways ) ) { |
|
| 186 | - $scope = array( 'CART', 'ADMIN'); |
|
| 187 | - }elseif( $active && ! in_array( $old_gateway_slug, $offline_gateways ) ) { |
|
| 188 | - $scope = array( 'CART' ); |
|
| 189 | - }elseif( ! $active && in_array($old_gateway_slug,$offline_gateways ) ) { |
|
| 190 | - $scope = array( 'ADMIN' ); |
|
| 191 | - }else{ |
|
| 183 | + $pretty_name = isset($old_gateway_settings['display_name']) ? $old_gateway_settings['display_name'] : $old_gateway_slug; |
|
| 184 | + $offline_gateways = array('Bank', 'Check', 'Invoice'); |
|
| 185 | + if ($active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 186 | + $scope = array('CART', 'ADMIN'); |
|
| 187 | + }elseif ($active && ! in_array($old_gateway_slug, $offline_gateways)) { |
|
| 188 | + $scope = array('CART'); |
|
| 189 | + }elseif ( ! $active && in_array($old_gateway_slug, $offline_gateways)) { |
|
| 190 | + $scope = array('ADMIN'); |
|
| 191 | + } else { |
|
| 192 | 192 | $scope = array(); |
| 193 | 193 | } |
| 194 | 194 | $payment_method_col_values = array( |
@@ -196,25 +196,25 @@ discard block |
||
| 196 | 196 | 'PMD_name' => $pretty_name, |
| 197 | 197 | 'PMD_desc' => $desc, |
| 198 | 198 | 'PMD_admin_name' => $pretty_name, |
| 199 | - 'PMD_slug' => sanitize_key( $old_gateway_slug ), |
|
| 200 | - 'PMD_debug_mode' => isset( $old_gateway_settings[ 'use_sandbox' ] ) ? $old_gateway_settings['use_sandbox'] : FALSE, |
|
| 201 | - 'PMD_button_url' => isset( $old_gateway_settings[ 'button_url' ] ) ? $old_gateway_settings[ 'button_url' ] : NULL, |
|
| 202 | - 'PMD_scope' => serialize( $scope ) |
|
| 199 | + 'PMD_slug' => sanitize_key($old_gateway_slug), |
|
| 200 | + 'PMD_debug_mode' => isset($old_gateway_settings['use_sandbox']) ? $old_gateway_settings['use_sandbox'] : FALSE, |
|
| 201 | + 'PMD_button_url' => isset($old_gateway_settings['button_url']) ? $old_gateway_settings['button_url'] : NULL, |
|
| 202 | + 'PMD_scope' => serialize($scope) |
|
| 203 | 203 | ); |
| 204 | 204 | $db_types = array( |
| 205 | - '%s',//PMD_type |
|
| 206 | - '%s',//PMD_name |
|
| 207 | - '%s',//PMD_desc |
|
| 208 | - '%s',//PMD_admin_name |
|
| 209 | - '%s',//PMD_slug |
|
| 210 | - '%d',//PMD_debug_mode |
|
| 211 | - '%s',//PMD_button_url |
|
| 212 | - '%s',//PMD_scope |
|
| 205 | + '%s', //PMD_type |
|
| 206 | + '%s', //PMD_name |
|
| 207 | + '%s', //PMD_desc |
|
| 208 | + '%s', //PMD_admin_name |
|
| 209 | + '%s', //PMD_slug |
|
| 210 | + '%d', //PMD_debug_mode |
|
| 211 | + '%s', //PMD_button_url |
|
| 212 | + '%s', //PMD_scope |
|
| 213 | 213 | ); |
| 214 | 214 | global $wpdb; |
| 215 | 215 | //first: check if it already exists |
| 216 | - $id = $wpdb->get_var( $wpdb->prepare( "SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values[ 'PMD_slug' ] ) ); |
|
| 217 | - if( $id ){ |
|
| 216 | + $id = $wpdb->get_var($wpdb->prepare("SELECT PMD_ID FROM {$this->_new_table_name} WHERE PMD_slug=%s", $payment_method_col_values['PMD_slug'])); |
|
| 217 | + if ($id) { |
|
| 218 | 218 | //just update that payment method instead of creating a new one |
| 219 | 219 | $success = $wpdb->update( |
| 220 | 220 | $this->_new_table_name, |
@@ -224,27 +224,27 @@ discard block |
||
| 224 | 224 | ), |
| 225 | 225 | $db_types, |
| 226 | 226 | array( |
| 227 | - '%d',//PMD_ID |
|
| 227 | + '%d', //PMD_ID |
|
| 228 | 228 | )); |
| 229 | - if( ! $success ){ |
|
| 230 | - $this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"),$id,wp_json_encode($payment_method_col_values),$wpdb->last_error)); |
|
| 229 | + if ( ! $success) { |
|
| 230 | + $this->add_error(sprintf(__('Could not update payment method %d with properties %s because %s', "event_espresso"), $id, wp_json_encode($payment_method_col_values), $wpdb->last_error)); |
|
| 231 | 231 | } |
| 232 | - }else{ |
|
| 232 | + } else { |
|
| 233 | 233 | $success = $wpdb->insert( |
| 234 | 234 | $this->_new_table_name, |
| 235 | 235 | $payment_method_col_values, |
| 236 | 236 | $db_types); |
| 237 | - if ( ! $success ) { |
|
| 237 | + if ( ! $success) { |
|
| 238 | 238 | $this->add_error($wpdb->last_error); |
| 239 | 239 | return false; |
| 240 | - }else{ |
|
| 240 | + } else { |
|
| 241 | 241 | $id = $wpdb->insert_id; |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - if( $id ){ |
|
| 246 | - $this->_convert_extra_meta_values( $id, $extra_meta_key_values ); |
|
| 247 | - $this->get_migration_script()->set_mapping( 'EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id ); |
|
| 245 | + if ($id) { |
|
| 246 | + $this->_convert_extra_meta_values($id, $extra_meta_key_values); |
|
| 247 | + $this->get_migration_script()->set_mapping('EE_Gateway_Config', $old_gateway_slug, $this->_new_table_name, $id); |
|
| 248 | 248 | return true; |
| 249 | 249 | } |
| 250 | 250 | return false; |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | * @param int $id |
| 259 | 259 | * @param array $extra_meta_key_values |
| 260 | 260 | */ |
| 261 | - private function _convert_extra_meta_values($id,$extra_meta_key_values){ |
|
| 261 | + private function _convert_extra_meta_values($id, $extra_meta_key_values) { |
|
| 262 | 262 | global $wpdb; |
| 263 | - foreach( $extra_meta_key_values as $key => $value ){ |
|
| 263 | + foreach ($extra_meta_key_values as $key => $value) { |
|
| 264 | 264 | $exm_args = array( |
| 265 | 265 | 'OBJ_ID'=>$id, |
| 266 | 266 | 'EXM_type'=>'Payment_Method', |
| 267 | 267 | 'EXM_key'=>$key, |
| 268 | - 'EXM_value'=> maybe_serialize($value ) |
|
| 268 | + 'EXM_value'=> maybe_serialize($value) |
|
| 269 | 269 | ); |
| 270 | 270 | $success = $wpdb->insert( |
| 271 | 271 | $this->_extra_meta_table_name, |
| 272 | 272 | $exm_args, |
| 273 | 273 | array( |
| 274 | - '%d',//OBJ_ID |
|
| 275 | - '%s',//EXM_type |
|
| 276 | - '%s',//EXM_key |
|
| 277 | - '%s',//EXM_value |
|
| 274 | + '%d', //OBJ_ID |
|
| 275 | + '%s', //EXM_type |
|
| 276 | + '%s', //EXM_key |
|
| 277 | + '%s', //EXM_value |
|
| 278 | 278 | )); |
| 279 | - if( ! $success ){ |
|
| 280 | - $this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"),wp_json_encode($exm_args),$wpdb->last_error)); |
|
| 279 | + if ( ! $success) { |
|
| 280 | + $this->add_error(sprintf(__('Could not insert extra meta key with values %s. %s', "event_espresso"), wp_json_encode($exm_args), $wpdb->last_error)); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Mike Nelson |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage{ |
|
| 16 | +class EE_DMS_4_6_0_payment_method_currencies extends EE_Data_Migration_Script_Stage { |
|
| 17 | 17 | protected $_currency_table_name; |
| 18 | 18 | protected $_currency_payment_method_table_name; |
| 19 | 19 | protected $_payment_method_table_name; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ); |
| 90 | 90 | public function __construct() { |
| 91 | 91 | global $wpdb; |
| 92 | - $this->_pretty_name = __( 'Payment Method Currencies', 'event_espresso' ); |
|
| 92 | + $this->_pretty_name = __('Payment Method Currencies', 'event_espresso'); |
|
| 93 | 93 | $this->_payment_method_table_name = $wpdb->prefix.'esp_payment_method'; |
| 94 | 94 | $this->_currency_payment_method_table_name = $wpdb->prefix.'esp_currency_payment_method'; |
| 95 | 95 | $this->_currency_table_name = $wpdb->prefix.'esp_currency'; |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | protected function _count_records_to_migrate() { |
| 100 | 100 | $count = 0; |
| 101 | - foreach($this->_gateway_currencies as $currencies){ |
|
| 102 | - if( $currencies == 'all'){ |
|
| 101 | + foreach ($this->_gateway_currencies as $currencies) { |
|
| 102 | + if ($currencies == 'all') { |
|
| 103 | 103 | $currencies = $this->_get_all_currencies(); |
| 104 | 104 | } |
| 105 | 105 | $count += count($currencies); |
@@ -109,20 +109,20 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | |
| 112 | - protected function _migration_step( $num_items_to_migrate = 50 ) { |
|
| 112 | + protected function _migration_step($num_items_to_migrate = 50) { |
|
| 113 | 113 | $items_actually_migrated = 0; |
| 114 | 114 | $relations_to_add_this_step = $this->_gather_relations_to_add($num_items_to_migrate); |
| 115 | - foreach($relations_to_add_this_step as $pm_slug => $currencies){ |
|
| 115 | + foreach ($relations_to_add_this_step as $pm_slug => $currencies) { |
|
| 116 | 116 | |
| 117 | - $id = $this->get_migration_script()->get_mapping_new_pk( 'EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name ); |
|
| 118 | - foreach( $currencies as $currency ){ |
|
| 119 | - if( $id ){ |
|
| 120 | - $this->_add_currency_relations( $id, $currency ); |
|
| 117 | + $id = $this->get_migration_script()->get_mapping_new_pk('EE_Gateway_Config', $pm_slug, $this->_payment_method_table_name); |
|
| 118 | + foreach ($currencies as $currency) { |
|
| 119 | + if ($id) { |
|
| 120 | + $this->_add_currency_relations($id, $currency); |
|
| 121 | 121 | } |
| 122 | 122 | $items_actually_migrated++; |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
| 125 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
| 126 | 126 | $this->set_completed(); |
| 127 | 127 | } |
| 128 | 128 | return $items_actually_migrated; |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | $relations_to_add_this_step = array(); |
| 133 | 133 | $migrate_up_to_count = $this->count_records_migrated() + $num_items_to_migrate; |
| 134 | 134 | $iterator = 0; |
| 135 | - foreach($this->_gateway_currencies as $pm_slug => $currencies){ |
|
| 136 | - if( $currencies == 'all' ){ |
|
| 135 | + foreach ($this->_gateway_currencies as $pm_slug => $currencies) { |
|
| 136 | + if ($currencies == 'all') { |
|
| 137 | 137 | $currencies = $this->_get_all_currencies(); |
| 138 | 138 | } |
| 139 | - foreach($currencies as $currency_code){ |
|
| 140 | - if( $this->count_records_migrated() <= $iterator && |
|
| 141 | - $iterator < $migrate_up_to_count ){ |
|
| 142 | - $relations_to_add_this_step[ $pm_slug ] [] = $currency_code; |
|
| 139 | + foreach ($currencies as $currency_code) { |
|
| 140 | + if ($this->count_records_migrated() <= $iterator && |
|
| 141 | + $iterator < $migrate_up_to_count) { |
|
| 142 | + $relations_to_add_this_step[$pm_slug] [] = $currency_code; |
|
| 143 | 143 | } |
| 144 | 144 | $iterator++; |
| 145 | 145 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * Gets all the currency codes in the database |
| 151 | 151 | * @return array |
| 152 | 152 | */ |
| 153 | - private function _get_all_currencies(){ |
|
| 153 | + private function _get_all_currencies() { |
|
| 154 | 154 | global $wpdb; |
| 155 | 155 | $currencies = $wpdb->get_col("SELECT CUR_code FROM {$this->_currency_table_name}"); |
| 156 | 156 | return $currencies; |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * @param int $id |
| 162 | 162 | * @param string $gateway_slug |
| 163 | 163 | */ |
| 164 | - private function _add_currency_relations($pm_id,$currency_code){ |
|
| 164 | + private function _add_currency_relations($pm_id, $currency_code) { |
|
| 165 | 165 | global $wpdb; |
| 166 | 166 | $cur_pm_relation = array( |
| 167 | 167 | 'CUR_code'=>$currency_code, |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | $success = $wpdb->insert($this->_currency_payment_method_table_name, |
| 171 | 171 | $cur_pm_relation, |
| 172 | 172 | array( |
| 173 | - '%s',//CUR_code |
|
| 174 | - '%d',//PMD_ID |
|
| 173 | + '%s', //CUR_code |
|
| 174 | + '%d', //PMD_ID |
|
| 175 | 175 | )); |
| 176 | - if( ! $success ){ |
|
| 177 | - $this->add_error( sprintf( __( 'Could not add currency relation %s because %s', "event_espresso" ), wp_json_encode( $cur_pm_relation ), $wpdb->last_error ) ); |
|
| 176 | + if ( ! $success) { |
|
| 177 | + $this->add_error(sprintf(__('Could not add currency relation %s because %s', "event_espresso"), wp_json_encode($cur_pm_relation), $wpdb->last_error)); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * @author Brent Christensen |
| 14 | 14 | * |
| 15 | 15 | */ |
| 16 | -class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table{ |
|
| 16 | +class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table { |
|
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | public function __construct() { |
| 26 | 26 | global $wpdb; |
| 27 | - $this->_pretty_name = __( 'Email - System Question', 'event_espresso' ); |
|
| 27 | + $this->_pretty_name = __('Email - System Question', 'event_espresso'); |
|
| 28 | 28 | $this->_old_table = $wpdb->prefix.'esp_question'; |
| 29 | 29 | $this->_extra_where_sql = "WHERE QST_system = 'email'"; |
| 30 | 30 | parent::__construct(); |
@@ -37,21 +37,21 @@ discard block |
||
| 37 | 37 | * @param array $question an associative array where keys are column names and values are their values. |
| 38 | 38 | * @return null |
| 39 | 39 | */ |
| 40 | - protected function _migrate_old_row( $question ) { |
|
| 41 | - if ( $question['QST_ID'] && $question['QST_system'] == 'email' ) { |
|
| 40 | + protected function _migrate_old_row($question) { |
|
| 41 | + if ($question['QST_ID'] && $question['QST_system'] == 'email') { |
|
| 42 | 42 | global $wpdb; |
| 43 | 43 | $success = $wpdb->update( |
| 44 | 44 | $this->_old_table, |
| 45 | - array( 'QST_type' => 'EMAIL' ), // data |
|
| 46 | - array( 'QST_ID' => $question['QST_ID'] ), // where |
|
| 47 | - array( '%s' ), // data format |
|
| 48 | - array( '%d' ) // where format |
|
| 45 | + array('QST_type' => 'EMAIL'), // data |
|
| 46 | + array('QST_ID' => $question['QST_ID']), // where |
|
| 47 | + array('%s'), // data format |
|
| 48 | + array('%d') // where format |
|
| 49 | 49 | ); |
| 50 | - if ( ! $success ) { |
|
| 50 | + if ( ! $success) { |
|
| 51 | 51 | $this->add_error( |
| 52 | 52 | sprintf( |
| 53 | - __( 'Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso' ), |
|
| 54 | - wp_json_encode( $question['QST_system'] ), |
|
| 53 | + __('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'), |
|
| 54 | + wp_json_encode($question['QST_system']), |
|
| 55 | 55 | $question['QST_ID'], |
| 56 | 56 | $wpdb->last_error |
| 57 | 57 | ) |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers; |
| 3 | 3 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
| 4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 5 | - exit( 'No direct script access allowed' ); |
|
| 4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 5 | + exit('No direct script access allowed'); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | public function __construct() { |
| 52 | - $this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false; |
|
| 52 | + $this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * Sets the version the user requested |
| 58 | 58 | * @param string $version eg '4.8' |
| 59 | 59 | */ |
| 60 | - public function set_requested_version( $version ) { |
|
| 60 | + public function set_requested_version($version) { |
|
| 61 | 61 | $this->_requested_version = $version; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | * @param string $key |
| 67 | 67 | * @param string|array $info |
| 68 | 68 | */ |
| 69 | - protected function _set_debug_info( $key, $info ){ |
|
| 70 | - $this->_debug_info[ $key ] = $info; |
|
| 69 | + protected function _set_debug_info($key, $info) { |
|
| 70 | + $this->_debug_info[$key] = $info; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * @param boolean $use_ee_prefix whether to use the EE prefix on the header, or fallback to |
| 80 | 80 | * the standard WP one |
| 81 | 81 | */ |
| 82 | - protected function _set_response_header( $header_key, $value, $use_ee_prefix = true ) { |
|
| 83 | - if( is_array( $value ) ) { |
|
| 84 | - foreach( $value as $value_key => $value_value ) { |
|
| 85 | - $this->_set_response_header( $header_key . '[' . $value_key . ']', $value_value ); |
|
| 82 | + protected function _set_response_header($header_key, $value, $use_ee_prefix = true) { |
|
| 83 | + if (is_array($value)) { |
|
| 84 | + foreach ($value as $value_key => $value_value) { |
|
| 85 | + $this->_set_response_header($header_key.'['.$value_key.']', $value_value); |
|
| 86 | 86 | } |
| 87 | 87 | } else { |
| 88 | 88 | $prefix = $use_ee_prefix ? Base::header_prefix_for_ee : Base::header_prefix_for_wp; |
| 89 | - $this->_response_headers[ $prefix . $header_key ] = $value; |
|
| 89 | + $this->_response_headers[$prefix.$header_key] = $value; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @return array |
| 96 | 96 | */ |
| 97 | 97 | protected function _get_response_headers() { |
| 98 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
| 98 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
| 99 | 99 | $this->_response_headers, |
| 100 | 100 | $this, |
| 101 | 101 | $this->_requested_version |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | * @param \WP_Error $wp_error_response |
| 108 | 108 | * @return \WP_Error |
| 109 | 109 | */ |
| 110 | - protected function _add_ee_errors_to_response( \WP_Error $wp_error_response ) { |
|
| 110 | + protected function _add_ee_errors_to_response(\WP_Error $wp_error_response) { |
|
| 111 | 111 | $notices_during_checkin = \EE_Error::get_raw_notices(); |
| 112 | - if( ! empty( $notices_during_checkin[ 'errors' ] ) ) { |
|
| 113 | - foreach( $notices_during_checkin[ 'errors' ] as $error_code => $error_message ) { |
|
| 112 | + if ( ! empty($notices_during_checkin['errors'])) { |
|
| 113 | + foreach ($notices_during_checkin['errors'] as $error_code => $error_message) { |
|
| 114 | 114 | $wp_error_response->add( |
| 115 | - sanitize_key( $error_code ), |
|
| 116 | - strip_tags( $error_message ) ); |
|
| 115 | + sanitize_key($error_code), |
|
| 116 | + strip_tags($error_message) ); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | return $wp_error_response; |
@@ -131,27 +131,27 @@ discard block |
||
| 131 | 131 | * @param array|\WP_Error|\Exception $response |
| 132 | 132 | * @return \WP_REST_Response |
| 133 | 133 | */ |
| 134 | - public function send_response( $response ) { |
|
| 135 | - if( $response instanceof Rest_Exception ) { |
|
| 136 | - $response = new \WP_Error( $response->get_string_code(), $response->getMessage(), $response->get_data() ); |
|
| 134 | + public function send_response($response) { |
|
| 135 | + if ($response instanceof Rest_Exception) { |
|
| 136 | + $response = new \WP_Error($response->get_string_code(), $response->getMessage(), $response->get_data()); |
|
| 137 | 137 | } |
| 138 | - if( $response instanceof \Exception ) { |
|
| 138 | + if ($response instanceof \Exception) { |
|
| 139 | 139 | $code = $response->getCode() ? $response->getCode() : 'error_occurred'; |
| 140 | - $response = new \WP_Error( $code, $response->getMessage() ); |
|
| 140 | + $response = new \WP_Error($code, $response->getMessage()); |
|
| 141 | 141 | } |
| 142 | - if( $response instanceof \WP_Error ) { |
|
| 143 | - $response = $this->_add_ee_errors_to_response( $response ); |
|
| 144 | - $rest_response = $this->_create_rest_response_from_wp_error( $response ); |
|
| 145 | - }else{ |
|
| 146 | - $rest_response = new \WP_REST_Response( $response, 200 ); |
|
| 142 | + if ($response instanceof \WP_Error) { |
|
| 143 | + $response = $this->_add_ee_errors_to_response($response); |
|
| 144 | + $rest_response = $this->_create_rest_response_from_wp_error($response); |
|
| 145 | + } else { |
|
| 146 | + $rest_response = new \WP_REST_Response($response, 200); |
|
| 147 | 147 | } |
| 148 | 148 | $headers = array(); |
| 149 | - if( $this->_debug_mode && is_array( $this->_debug_info ) ) { |
|
| 150 | - foreach( $this->_debug_info as $debug_key => $debug_info ) { |
|
| 151 | - if( is_array( $debug_info ) ) { |
|
| 152 | - $debug_info = wp_json_encode( $debug_info ); |
|
| 149 | + if ($this->_debug_mode && is_array($this->_debug_info)) { |
|
| 150 | + foreach ($this->_debug_info as $debug_key => $debug_info) { |
|
| 151 | + if (is_array($debug_info)) { |
|
| 152 | + $debug_info = wp_json_encode($debug_info); |
|
| 153 | 153 | } |
| 154 | - $headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info; |
|
| 154 | + $headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info; |
|
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | 157 | $headers = array_merge( |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $this->_get_headers_from_ee_notices() |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | - $rest_response->set_headers( $headers ); |
|
| 163 | + $rest_response->set_headers($headers); |
|
| 164 | 164 | return $rest_response; |
| 165 | 165 | } |
| 166 | 166 | |
@@ -171,31 +171,31 @@ discard block |
||
| 171 | 171 | * @param \WP_Error $wp_error |
| 172 | 172 | * @return \WP_REST_Response |
| 173 | 173 | */ |
| 174 | - protected function _create_rest_response_from_wp_error( \WP_Error $wp_error ) { |
|
| 174 | + protected function _create_rest_response_from_wp_error(\WP_Error $wp_error) { |
|
| 175 | 175 | $error_data = $wp_error->get_error_data(); |
| 176 | - if ( is_array( $error_data ) && isset( $error_data['status'] ) ) { |
|
| 176 | + if (is_array($error_data) && isset($error_data['status'])) { |
|
| 177 | 177 | $status = $error_data['status']; |
| 178 | 178 | } else { |
| 179 | 179 | $status = 500; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | $errors = array(); |
| 183 | - foreach ( (array) $wp_error->errors as $code => $messages ) { |
|
| 184 | - foreach ( (array) $messages as $message ) { |
|
| 183 | + foreach ((array) $wp_error->errors as $code => $messages) { |
|
| 184 | + foreach ((array) $messages as $message) { |
|
| 185 | 185 | $errors[] = array( |
| 186 | 186 | 'code' => $code, |
| 187 | 187 | 'message' => $message, |
| 188 | - 'data' => $wp_error->get_error_data( $code ) |
|
| 188 | + 'data' => $wp_error->get_error_data($code) |
|
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - $data = isset( $errors[0] ) ? $errors[0] : array(); |
|
| 193 | - if ( count( $errors ) > 1 ) { |
|
| 192 | + $data = isset($errors[0]) ? $errors[0] : array(); |
|
| 193 | + if (count($errors) > 1) { |
|
| 194 | 194 | // Remove the primary error. |
| 195 | - array_shift( $errors ); |
|
| 195 | + array_shift($errors); |
|
| 196 | 196 | $data['additional_errors'] = $errors; |
| 197 | 197 | } |
| 198 | - return new \WP_REST_Response( $data, $status ); |
|
| 198 | + return new \WP_REST_Response($data, $status); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -205,12 +205,12 @@ discard block |
||
| 205 | 205 | protected function _get_headers_from_ee_notices() { |
| 206 | 206 | $headers = array(); |
| 207 | 207 | $notices = \EE_Error::get_raw_notices(); |
| 208 | - foreach( $notices as $notice_type => $sub_notices ) { |
|
| 209 | - if( ! is_array( $sub_notices ) ) { |
|
| 208 | + foreach ($notices as $notice_type => $sub_notices) { |
|
| 209 | + if ( ! is_array($sub_notices)) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | - foreach( $sub_notices as $notice_code => $sub_notice ) { |
|
| 213 | - $headers[ 'X-EE4-Notices-' . \EEH_Inflector::humanize( $notice_type ) . '[' . $notice_code . ']' ] = strip_tags( $sub_notice ); |
|
| 212 | + foreach ($sub_notices as $notice_code => $sub_notice) { |
|
| 213 | + $headers['X-EE4-Notices-'.\EEH_Inflector::humanize($notice_type).'['.$notice_code.']'] = strip_tags($sub_notice); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | return apply_filters( |
@@ -228,14 +228,14 @@ discard block |
||
| 228 | 228 | * @param string $route |
| 229 | 229 | * @return string |
| 230 | 230 | */ |
| 231 | - public function get_requested_version( $route = null ) { |
|
| 231 | + public function get_requested_version($route = null) { |
|
| 232 | 232 | $matches = $this->parse_route( |
| 233 | 233 | $route, |
| 234 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '~', |
|
| 235 | - array( 'version' ) |
|
| 234 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'~', |
|
| 235 | + array('version') |
|
| 236 | 236 | ); |
| 237 | - if( isset( $matches[ 'version' ] ) ) { |
|
| 238 | - return $matches[ 'version' ]; |
|
| 237 | + if (isset($matches['version'])) { |
|
| 238 | + return $matches['version']; |
|
| 239 | 239 | } else { |
| 240 | 240 | return \EED_Core_Rest_Api::latest_rest_api_version(); |
| 241 | 241 | } |
@@ -260,23 +260,23 @@ discard block |
||
| 260 | 260 | * array( 'model' => 'foo', 'id' => 'bar' ) |
| 261 | 261 | * @throws \EE_Error if it couldn't be parsed |
| 262 | 262 | */ |
| 263 | - public function parse_route( $route, $regex, $match_keys ) { |
|
| 263 | + public function parse_route($route, $regex, $match_keys) { |
|
| 264 | 264 | $indexed_matches = array(); |
| 265 | - $success = preg_match( $regex, $route, $matches ); |
|
| 266 | - if( |
|
| 267 | - is_array( $matches ) ) { |
|
| 265 | + $success = preg_match($regex, $route, $matches); |
|
| 266 | + if ( |
|
| 267 | + is_array($matches) ) { |
|
| 268 | 268 | //skip the overall regex match. Who cares |
| 269 | - for( $i = 1; $i <= count( $match_keys ); $i++ ) { |
|
| 270 | - if( ! isset( $matches[ $i ] ) ) { |
|
| 269 | + for ($i = 1; $i <= count($match_keys); $i++) { |
|
| 270 | + if ( ! isset($matches[$i])) { |
|
| 271 | 271 | $success = false; |
| 272 | 272 | } else { |
| 273 | - $indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ]; |
|
| 273 | + $indexed_matches[$match_keys[$i - 1]] = $matches[$i]; |
|
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | - if( ! $success ) { |
|
| 277 | + if ( ! $success) { |
|
| 278 | 278 | throw new \EE_Error( |
| 279 | - __( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ), |
|
| 279 | + __('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'), |
|
| 280 | 280 | 'endpoint_parsing_error' |
| 281 | 281 | ); |
| 282 | 282 | } |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * @param bool $routing |
| 32 | 32 | * @return Pricing_Admin_Page |
| 33 | 33 | */ |
| 34 | - public function __construct( $routing = TRUE ) { |
|
| 35 | - parent::__construct( $routing ); |
|
| 34 | + public function __construct($routing = TRUE) { |
|
| 35 | + parent::__construct($routing); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | protected function _ajax_hooks() { |
| 52 | - add_action('wp_ajax_espresso_update_prices_order', array( $this, 'update_price_order' )); |
|
| 52 | + add_action('wp_ajax_espresso_update_prices_order', array($this, 'update_price_order')); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | 84 | protected function _set_page_routes() { |
| 85 | - $prc_id = ! empty( $this->_req_data['PRC_ID'] ) && ! is_array( $this->_req_data['PRC_ID'] ) ? $this->_req_data['PRC_ID'] : 0; |
|
| 86 | - $prt_id = ! empty( $this->_req_data['PRT_ID'] ) && ! is_array( $this->_req_data['PRT_ID'] ) ? $this->_req_data['PRT_ID'] : 0; |
|
| 85 | + $prc_id = ! empty($this->_req_data['PRC_ID']) && ! is_array($this->_req_data['PRC_ID']) ? $this->_req_data['PRC_ID'] : 0; |
|
| 86 | + $prt_id = ! empty($this->_req_data['PRT_ID']) && ! is_array($this->_req_data['PRT_ID']) ? $this->_req_data['PRT_ID'] : 0; |
|
| 87 | 87 | $this->_page_routes = array( |
| 88 | 88 | 'default' => array( |
| 89 | 89 | 'func' => '_price_overview_list_table', |
@@ -91,38 +91,38 @@ discard block |
||
| 91 | 91 | ), |
| 92 | 92 | 'add_new_price' => array( |
| 93 | 93 | 'func' => '_edit_price_details', |
| 94 | - 'args' => array( 'new_price' => TRUE ), |
|
| 94 | + 'args' => array('new_price' => TRUE), |
|
| 95 | 95 | 'capability' => 'ee_edit_default_prices' |
| 96 | 96 | ), |
| 97 | 97 | 'edit_price' => array( |
| 98 | 98 | 'func' => '_edit_price_details', |
| 99 | - 'args' => array( 'new_price' => FALSE ), |
|
| 99 | + 'args' => array('new_price' => FALSE), |
|
| 100 | 100 | 'capability' => 'ee_edit_default_price', |
| 101 | 101 | 'obj_id' => $prc_id |
| 102 | 102 | ), |
| 103 | 103 | 'insert_price' => array( |
| 104 | 104 | 'func' => '_insert_or_update_price', |
| 105 | - 'args' => array( 'new_price' => TRUE ), |
|
| 105 | + 'args' => array('new_price' => TRUE), |
|
| 106 | 106 | 'noheader' => TRUE, |
| 107 | 107 | 'capability' => 'ee_edit_default_prices', |
| 108 | 108 | ), |
| 109 | 109 | 'update_price' => array( |
| 110 | 110 | 'func' => '_insert_or_update_price', |
| 111 | - 'args' => array( 'new_price' => FALSE ), |
|
| 111 | + 'args' => array('new_price' => FALSE), |
|
| 112 | 112 | 'noheader' => TRUE, |
| 113 | 113 | 'capability' => 'ee_edit_default_price', |
| 114 | 114 | 'obj_id' => $prc_id |
| 115 | 115 | ), |
| 116 | 116 | 'trash_price' => array( |
| 117 | 117 | 'func' => '_trash_or_restore_price', |
| 118 | - 'args' => array( 'trash' => TRUE ), |
|
| 118 | + 'args' => array('trash' => TRUE), |
|
| 119 | 119 | 'noheader' => TRUE, |
| 120 | 120 | 'capability' => 'ee_delete_default_price', |
| 121 | 121 | 'obj_id' => $prc_id |
| 122 | 122 | ), |
| 123 | 123 | 'restore_price' => array( |
| 124 | 124 | 'func' => '_trash_or_restore_price', |
| 125 | - 'args' => array( 'trash' => FALSE ), |
|
| 125 | + 'args' => array('trash' => FALSE), |
|
| 126 | 126 | 'noheader' => TRUE, |
| 127 | 127 | 'capability' => 'ee_delete_default_price', |
| 128 | 128 | 'obj_id' => $prc_id |
@@ -154,27 +154,27 @@ discard block |
||
| 154 | 154 | ), |
| 155 | 155 | 'insert_price_type' => array( |
| 156 | 156 | 'func' => '_insert_or_update_price_type', |
| 157 | - 'args' => array( 'new_price_type' => TRUE ), |
|
| 157 | + 'args' => array('new_price_type' => TRUE), |
|
| 158 | 158 | 'noheader' => TRUE, |
| 159 | 159 | 'capability' => 'ee_edit_default_price_types' |
| 160 | 160 | ), |
| 161 | 161 | 'update_price_type' => array( |
| 162 | 162 | 'func' => '_insert_or_update_price_type', |
| 163 | - 'args' => array( 'new_price_type' => FALSE ), |
|
| 163 | + 'args' => array('new_price_type' => FALSE), |
|
| 164 | 164 | 'noheader' => TRUE, |
| 165 | 165 | 'capability' => 'ee_edit_default_price_type', |
| 166 | 166 | 'obj_id' => $prt_id |
| 167 | 167 | ), |
| 168 | 168 | 'trash_price_type' => array( |
| 169 | 169 | 'func' => '_trash_or_restore_price_type', |
| 170 | - 'args' => array( 'trash' => TRUE ), |
|
| 170 | + 'args' => array('trash' => TRUE), |
|
| 171 | 171 | 'noheader' => TRUE, |
| 172 | 172 | 'capability' => 'ee_delete_default_price_type', |
| 173 | 173 | 'obj_id' => $prt_id |
| 174 | 174 | ), |
| 175 | 175 | 'restore_price_type' => array( |
| 176 | 176 | 'func' => '_trash_or_restore_price_type', |
| 177 | - 'args' => array( 'trash' => FALSE ), |
|
| 177 | + 'args' => array('trash' => FALSE), |
|
| 178 | 178 | 'noheader' => TRUE, |
| 179 | 179 | 'capability' => 'ee_delete_default_price_type', |
| 180 | 180 | 'obj_id' => $prt_id |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | 'filename' => 'pricing_default_pricing_views_bulk_actions_search' |
| 224 | 224 | ) |
| 225 | 225 | ), |
| 226 | - 'help_tour' => array( 'Pricing_Default_Prices_Help_Tour'), |
|
| 226 | + 'help_tour' => array('Pricing_Default_Prices_Help_Tour'), |
|
| 227 | 227 | 'require_nonce' => FALSE |
| 228 | 228 | ), |
| 229 | 229 | 'add_new_price' => array( |
@@ -239,24 +239,24 @@ discard block |
||
| 239 | 239 | ) |
| 240 | 240 | ), |
| 241 | 241 | 'help_tour' => array('Pricing_Add_New_Default_Price_Help_Tour'), |
| 242 | - 'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes' ), |
|
| 242 | + 'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'), |
|
| 243 | 243 | 'require_nonce' => FALSE |
| 244 | 244 | ), |
| 245 | 245 | 'edit_price' => array( |
| 246 | 246 | 'nav' => array( |
| 247 | 247 | 'label' => __('Edit Default Price', 'event_espresso'), |
| 248 | 248 | 'order' => 20, |
| 249 | - 'url' => isset($this->_req_data['id']) ? add_query_arg(array('id' => $this->_req_data['id'] ), $this->_current_page_view_url ) : $this->_admin_base_url, |
|
| 249 | + 'url' => isset($this->_req_data['id']) ? add_query_arg(array('id' => $this->_req_data['id']), $this->_current_page_view_url) : $this->_admin_base_url, |
|
| 250 | 250 | 'persistent' => FALSE |
| 251 | 251 | ), |
| 252 | - 'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes' ), |
|
| 252 | + 'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_details_meta_boxes'), |
|
| 253 | 253 | 'help_tabs' => array( |
| 254 | 254 | 'edit_default_price_help_tab' => array( |
| 255 | 255 | 'title' => __('Edit Default Price', 'event_espresso'), |
| 256 | 256 | 'filename' => 'pricing_edit_default_price' |
| 257 | 257 | ) |
| 258 | 258 | ), |
| 259 | - 'help_tour' => array( 'Pricing_Edit_Default_Price_Help_Tour' ), |
|
| 259 | + 'help_tour' => array('Pricing_Edit_Default_Price_Help_Tour'), |
|
| 260 | 260 | 'require_nonce' => FALSE |
| 261 | 261 | ), |
| 262 | 262 | 'price_types' => array( |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | 'filename' => 'pricing_price_types_views_bulk_actions_search' |
| 280 | 280 | ), |
| 281 | 281 | ), |
| 282 | - 'help_tour' => array( 'Pricing_Price_Types_Default_Help_Tour' ), |
|
| 282 | + 'help_tour' => array('Pricing_Price_Types_Default_Help_Tour'), |
|
| 283 | 283 | 'metaboxes' => array('_espresso_news_post_box', '_espresso_links_post_box'), |
| 284 | 284 | 'require_nonce' => FALSE |
| 285 | 285 | ), |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | 'filename' => 'pricing_add_new_price_type' |
| 296 | 296 | ) |
| 297 | 297 | ), |
| 298 | - 'help_tour' => array( 'Pricing_Add_New_Price_Type_Help_Tour' ), |
|
| 299 | - 'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes' ), |
|
| 298 | + 'help_tour' => array('Pricing_Add_New_Price_Type_Help_Tour'), |
|
| 299 | + 'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'), |
|
| 300 | 300 | 'require_nonce' => FALSE |
| 301 | 301 | ), |
| 302 | 302 | 'edit_price_type' => array( |
@@ -311,8 +311,8 @@ discard block |
||
| 311 | 311 | 'filename' => 'pricing_edit_price_type' |
| 312 | 312 | ) |
| 313 | 313 | ), |
| 314 | - 'help_tour' => array( 'Pricing_Edit_Price_Type_Help_Tour' ), |
|
| 315 | - 'metaboxes' => array( '_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes' ), |
|
| 314 | + 'help_tour' => array('Pricing_Edit_Price_Type_Help_Tour'), |
|
| 315 | + 'metaboxes' => array('_publish_post_box', '_espresso_news_post_box', '_price_type_details_meta_boxes'), |
|
| 316 | 316 | |
| 317 | 317 | 'require_nonce' => FALSE |
| 318 | 318 | ), |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | public function load_scripts_styles() { |
| 368 | 368 | //styles |
| 369 | 369 | wp_enqueue_style('espresso-ui-theme'); |
| 370 | - wp_register_style( 'espresso_PRICING', PRICING_ASSETS_URL . 'espresso_pricing_admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
| 370 | + wp_register_style('espresso_PRICING', PRICING_ASSETS_URL.'espresso_pricing_admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 371 | 371 | wp_enqueue_style('espresso_PRICING'); |
| 372 | 372 | |
| 373 | 373 | //scripts |
@@ -377,8 +377,8 @@ discard block |
||
| 377 | 377 | //wp_enqueue_script('jquery-ui-dialog'); |
| 378 | 378 | //wp_enqueue_script('jquery-ui-draggable'); |
| 379 | 379 | //wp_enqueue_script('jquery-ui-datepicker'); |
| 380 | - wp_register_script( 'espresso_PRICING', PRICING_ASSETS_URL . 'espresso_pricing_admin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
| 381 | - wp_enqueue_script( 'espresso_PRICING' ); |
|
| 380 | + wp_register_script('espresso_PRICING', PRICING_ASSETS_URL.'espresso_pricing_admin.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
| 381 | + wp_enqueue_script('espresso_PRICING'); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | |
| 388 | 388 | public function load_scripts_styles_default() { |
| 389 | - wp_enqueue_script( 'espresso_ajax_table_sorting' ); |
|
| 389 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | ) |
| 415 | 415 | ); |
| 416 | 416 | |
| 417 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_prices', 'pricing_trash_price' ) ) { |
|
| 417 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) { |
|
| 418 | 418 | $this->_views['trashed'] = array( |
| 419 | 419 | 'slug' => 'trashed', |
| 420 | 420 | 'label' => __('Trash', 'event_espresso'), |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | ) |
| 445 | 445 | ); |
| 446 | 446 | |
| 447 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_default_price_types', 'pricing_trash_price_type' ) ) { |
|
| 447 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_price_types', 'pricing_trash_price_type')) { |
|
| 448 | 448 | $this->_views['trashed'] = array( |
| 449 | 449 | 'slug' => 'trashed', |
| 450 | 450 | 'label' => __('Trash', 'event_espresso'), |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return void |
| 465 | 465 | */ |
| 466 | 466 | protected function _price_overview_list_table() { |
| 467 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 467 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 468 | 468 | 'add_new_price', |
| 469 | 469 | 'add', |
| 470 | 470 | array(), |
@@ -488,18 +488,18 @@ discard block |
||
| 488 | 488 | * @param boolean $trashed whether the current view is of the trash can - eww yuck! |
| 489 | 489 | * @return mixed (int|array) int = count || array of price objects |
| 490 | 490 | */ |
| 491 | - public function get_prices_overview_data( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
| 491 | + public function get_prices_overview_data($per_page = 10, $count = FALSE, $trashed = FALSE) { |
|
| 492 | 492 | |
| 493 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 493 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 494 | 494 | // start with an empty array |
| 495 | 495 | $event_pricing = array(); |
| 496 | 496 | |
| 497 | - require_once( PRICING_ADMIN . 'Prices_List_Table.class.php' ); |
|
| 498 | - require_once(EE_MODELS . 'EEM_Price.model.php'); |
|
| 497 | + require_once(PRICING_ADMIN.'Prices_List_Table.class.php'); |
|
| 498 | + require_once(EE_MODELS.'EEM_Price.model.php'); |
|
| 499 | 499 | //$PRC = EEM_Price::instance(); |
| 500 | 500 | |
| 501 | 501 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby']; |
| 502 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
| 502 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
| 503 | 503 | |
| 504 | 504 | switch ($this->_req_data['orderby']) { |
| 505 | 505 | case 'name': |
@@ -512,27 +512,27 @@ discard block |
||
| 512 | 512 | $orderby = array('PRC_amount'=>$order); |
| 513 | 513 | break; |
| 514 | 514 | default: |
| 515 | - $orderby = array( 'PRC_order'=>$order, 'Price_Type.PRT_order'=>$order, 'PRC_ID'=>$order); |
|
| 515 | + $orderby = array('PRC_order'=>$order, 'Price_Type.PRT_order'=>$order, 'PRC_ID'=>$order); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 519 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 518 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 519 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 520 | 520 | |
| 521 | 521 | $_where = array( |
| 522 | 522 | 'PRC_is_default' => 1, |
| 523 | 523 | 'PRC_deleted' => $trashed |
| 524 | 524 | ); |
| 525 | 525 | |
| 526 | - $offset = ($current_page-1)*$per_page; |
|
| 527 | - $limit = array( $offset, $per_page ); |
|
| 526 | + $offset = ($current_page - 1) * $per_page; |
|
| 527 | + $limit = array($offset, $per_page); |
|
| 528 | 528 | |
| 529 | - if ( isset( $this->_req_data['s'] ) ) { |
|
| 530 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 529 | + if (isset($this->_req_data['s'])) { |
|
| 530 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 531 | 531 | $_where['OR'] = array( |
| 532 | - 'PRC_name' => array('LIKE',$sstr ), |
|
| 533 | - 'PRC_desc' => array('LIKE',$sstr ), |
|
| 534 | - 'PRC_amount' => array( 'LIKE',$sstr ), |
|
| 535 | - 'Price_Type.PRT_name' => array( 'LIKE', $sstr ) |
|
| 532 | + 'PRC_name' => array('LIKE', $sstr), |
|
| 533 | + 'PRC_desc' => array('LIKE', $sstr), |
|
| 534 | + 'PRC_amount' => array('LIKE', $sstr), |
|
| 535 | + 'Price_Type.PRT_name' => array('LIKE', $sstr) |
|
| 536 | 536 | ); |
| 537 | 537 | } |
| 538 | 538 | |
@@ -543,9 +543,9 @@ discard block |
||
| 543 | 543 | 'group_by'=>'PRC_ID' |
| 544 | 544 | ); |
| 545 | 545 | |
| 546 | - if($count){ |
|
| 547 | - return $trashed ? EEM_Price::instance()->count( array( $_where ) ) : EEM_Price::instance()->count_deleted_and_undeleted(array($_where)); |
|
| 548 | - }else{ |
|
| 546 | + if ($count) { |
|
| 547 | + return $trashed ? EEM_Price::instance()->count(array($_where)) : EEM_Price::instance()->count_deleted_and_undeleted(array($_where)); |
|
| 548 | + } else { |
|
| 549 | 549 | return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params); |
| 550 | 550 | } |
| 551 | 551 | } |
@@ -561,49 +561,49 @@ discard block |
||
| 561 | 561 | * @return void |
| 562 | 562 | */ |
| 563 | 563 | protected function _edit_price_details() { |
| 564 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 564 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 565 | 565 | // grab price ID |
| 566 | - $PRC_ID = isset( $this->_req_data['id'] ) && ! empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE; |
|
| 566 | + $PRC_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE; |
|
| 567 | 567 | // change page title based on request action |
| 568 | - switch( $this->_req_action ) { |
|
| 568 | + switch ($this->_req_action) { |
|
| 569 | 569 | case 'add_new_price' : |
| 570 | - $this->_admin_page_title = esc_html__( 'Add New Price', 'event_espresso' ); |
|
| 570 | + $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso'); |
|
| 571 | 571 | break; |
| 572 | 572 | case 'edit_price' : |
| 573 | - $this->_admin_page_title = esc_html__( 'Edit Price', 'event_espresso' ); |
|
| 573 | + $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso'); |
|
| 574 | 574 | break; |
| 575 | 575 | default : |
| 576 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
| 576 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 577 | 577 | } |
| 578 | 578 | // add PRC_ID to title if editing |
| 579 | - $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title; |
|
| 579 | + $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title; |
|
| 580 | 580 | |
| 581 | 581 | // get prices |
| 582 | - require_once(EE_MODELS . 'EEM_Price.model.php'); |
|
| 582 | + require_once(EE_MODELS.'EEM_Price.model.php'); |
|
| 583 | 583 | $PRC = EEM_Price::instance(); |
| 584 | 584 | |
| 585 | - if ( $PRC_ID ) { |
|
| 586 | - $price = $PRC->get_one_by_ID( $PRC_ID ); |
|
| 585 | + if ($PRC_ID) { |
|
| 586 | + $price = $PRC->get_one_by_ID($PRC_ID); |
|
| 587 | 587 | $additional_hidden_fields = array( |
| 588 | - 'PRC_ID' => array( 'type' => 'hidden', 'value' => $PRC_ID ) |
|
| 588 | + 'PRC_ID' => array('type' => 'hidden', 'value' => $PRC_ID) |
|
| 589 | 589 | ); |
| 590 | - $this->_set_add_edit_form_tags( 'update_price', $additional_hidden_fields ); |
|
| 590 | + $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields); |
|
| 591 | 591 | } else { |
| 592 | 592 | $price = $PRC->get_new_price(); |
| 593 | - $this->_set_add_edit_form_tags( 'insert_price' ); |
|
| 593 | + $this->_set_add_edit_form_tags('insert_price'); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | $this->_template_args['PRC_ID'] = $PRC_ID; |
| 597 | 597 | $this->_template_args['price'] = $price; |
| 598 | 598 | |
| 599 | 599 | // get price types |
| 600 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
| 600 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
| 601 | 601 | $PRT = EEM_Price_Type::instance(); |
| 602 | - $price_types = $PRT->get_all( array( array('PBT_ID' => array('!=', 1 ) ) ) ); |
|
| 602 | + $price_types = $PRT->get_all(array(array('PBT_ID' => array('!=', 1)))); |
|
| 603 | 603 | $price_type_names = array(); |
| 604 | 604 | if (empty($price_types)) { |
| 605 | - $msg = __( 'You have no price types defined. Please add a price type before adding a price.', 'event_espresso' ); |
|
| 606 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 605 | + $msg = __('You have no price types defined. Please add a price type before adding a price.', 'event_espresso'); |
|
| 606 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 607 | 607 | exit(); |
| 608 | 608 | } else { |
| 609 | 609 | foreach ($price_types as $type) { |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | $this->_template_args['price_types'] = $price_type_names; |
| 617 | 617 | $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
| 618 | 618 | |
| 619 | - $this->_set_publish_post_box_vars( 'id', $PRC_ID ); |
|
| 619 | + $this->_set_publish_post_box_vars('id', $PRC_ID); |
|
| 620 | 620 | // the details template wrapper |
| 621 | 621 | $this->display_admin_page_with_sidebar(); |
| 622 | 622 | } |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * @return void |
| 633 | 633 | */ |
| 634 | 634 | protected function _price_details_meta_boxes() { |
| 635 | - add_meta_box( 'edit-price-details-mbox', __( 'Default Price Details', 'event_espresso' ), array( $this, '_edit_price_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 635 | + add_meta_box('edit-price-details-mbox', __('Default Price Details', 'event_espresso'), array($this, '_edit_price_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | * @return void |
| 647 | 647 | */ |
| 648 | 648 | public function _edit_price_details_meta_box() { |
| 649 | - echo EEH_Template::display_template( PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
| 649 | + echo EEH_Template::display_template(PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php', $this->_template_args, TRUE); |
|
| 650 | 650 | } |
| 651 | 651 | |
| 652 | 652 | |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | */ |
| 661 | 661 | protected function set_price_column_values() { |
| 662 | 662 | |
| 663 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 663 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 664 | 664 | |
| 665 | 665 | $set_column_values = array( |
| 666 | 666 | 'PRT_ID' => absint($this->_req_data['PRT_ID']), |
@@ -688,12 +688,12 @@ discard block |
||
| 688 | 688 | * @access protected |
| 689 | 689 | * @return void |
| 690 | 690 | */ |
| 691 | - protected function _insert_or_update_price( $insert = FALSE ) { |
|
| 691 | + protected function _insert_or_update_price($insert = FALSE) { |
|
| 692 | 692 | |
| 693 | 693 | //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 694 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 694 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 695 | 695 | |
| 696 | - require_once(EE_MODELS . 'EEM_Price.model.php'); |
|
| 696 | + require_once(EE_MODELS.'EEM_Price.model.php'); |
|
| 697 | 697 | $PRC = EEM_Price::instance(); |
| 698 | 698 | |
| 699 | 699 | // why be so pessimistic ??? : ( |
@@ -701,14 +701,14 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $set_column_values = $this->set_price_column_values(); |
| 703 | 703 | // is this a new Price ? |
| 704 | - if ( $insert ) { |
|
| 704 | + if ($insert) { |
|
| 705 | 705 | // run the insert |
| 706 | - if ( $PRC_ID = $PRC->insert( $set_column_values )) { |
|
| 706 | + if ($PRC_ID = $PRC->insert($set_column_values)) { |
|
| 707 | 707 | //make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type |
| 708 | 708 | $PR = EEM_price::instance()->get_one_by_ID($PRC_ID); |
| 709 | - if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) { |
|
| 709 | + if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 710 | 710 | $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
| 711 | - $ticket->_add_relation_to( $PR, 'Price' ); |
|
| 711 | + $ticket->_add_relation_to($PR, 'Price'); |
|
| 712 | 712 | $ticket->save(); |
| 713 | 713 | } |
| 714 | 714 | $success = 1; |
@@ -718,29 +718,29 @@ discard block |
||
| 718 | 718 | } |
| 719 | 719 | $action_desc = 'created'; |
| 720 | 720 | } else { |
| 721 | - $PRC_ID = absint( $this->_req_data['PRC_ID'] ); |
|
| 721 | + $PRC_ID = absint($this->_req_data['PRC_ID']); |
|
| 722 | 722 | // run the update |
| 723 | - $where_cols_n_values = array( 'PRC_ID' => $PRC_ID ); |
|
| 724 | - if ( $PRC->update( $set_column_values, array($where_cols_n_values))) { |
|
| 723 | + $where_cols_n_values = array('PRC_ID' => $PRC_ID); |
|
| 724 | + if ($PRC->update($set_column_values, array($where_cols_n_values))) { |
|
| 725 | 725 | $success = 1; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
| 729 | - if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) { |
|
| 729 | + if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 730 | 730 | |
| 731 | 731 | //if this is $PRC_ID == 1, then we need to update the default ticket attached to this price so the TKT_price value is updated. |
| 732 | - if ( $PRC_ID === 1 ) { |
|
| 732 | + if ($PRC_ID === 1) { |
|
| 733 | 733 | $ticket = $PR->get_first_related('Ticket'); |
| 734 | - if ( $ticket ) { |
|
| 735 | - $ticket->set('TKT_price', $PR->get('PRC_amount') ); |
|
| 736 | - $ticket->set('TKT_name', $PR->get('PRC_name') ); |
|
| 734 | + if ($ticket) { |
|
| 735 | + $ticket->set('TKT_price', $PR->get('PRC_amount')); |
|
| 736 | + $ticket->set('TKT_name', $PR->get('PRC_name')); |
|
| 737 | 737 | $ticket->set('TKT_description', $PR->get('PRC_desc')); |
| 738 | 738 | $ticket->save(); |
| 739 | 739 | } |
| 740 | 740 | } else { |
| 741 | 741 | //we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type. |
| 742 | 742 | $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
| 743 | - $ticket->_add_relation_to( $PRC_ID, 'Price' ); |
|
| 743 | + $ticket->_add_relation_to($PRC_ID, 'Price'); |
|
| 744 | 744 | $ticket->save(); |
| 745 | 745 | } |
| 746 | 746 | } |
@@ -748,9 +748,9 @@ discard block |
||
| 748 | 748 | $action_desc = 'updated'; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - $query_args = array( 'action' => 'edit_price', 'id' => $PRC_ID ); |
|
| 751 | + $query_args = array('action' => 'edit_price', 'id' => $PRC_ID); |
|
| 752 | 752 | |
| 753 | - $this->_redirect_after_action( $success, 'Prices', $action_desc, $query_args ); |
|
| 753 | + $this->_redirect_after_action($success, 'Prices', $action_desc, $query_args); |
|
| 754 | 754 | |
| 755 | 755 | } |
| 756 | 756 | |
@@ -764,12 +764,12 @@ discard block |
||
| 764 | 764 | * @access protected |
| 765 | 765 | * @return void |
| 766 | 766 | */ |
| 767 | - protected function _trash_or_restore_price( $trash = TRUE ) { |
|
| 767 | + protected function _trash_or_restore_price($trash = TRUE) { |
|
| 768 | 768 | |
| 769 | 769 | //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 770 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 770 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 771 | 771 | |
| 772 | - require_once(EE_MODELS . 'EEM_Price.model.php'); |
|
| 772 | + require_once(EE_MODELS.'EEM_Price.model.php'); |
|
| 773 | 773 | $PRC = EEM_Price::instance(); |
| 774 | 774 | |
| 775 | 775 | $success = 1; |
@@ -778,18 +778,18 @@ discard block |
||
| 778 | 778 | //get base ticket for updating |
| 779 | 779 | $ticket = EEM_Ticket::instance()->get_one_by_ID(1); |
| 780 | 780 | //Checkboxes |
| 781 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 781 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 782 | 782 | // if array has more than one element than success message should be plural |
| 783 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 783 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 784 | 784 | // cycle thru checkboxes |
| 785 | - while (list( $PRC_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 786 | - if ( ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID) ) ) { |
|
| 785 | + while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 786 | + if ( ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), absint($PRC_ID))) { |
|
| 787 | 787 | $success = 0; |
| 788 | 788 | } else { |
| 789 | 789 | $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
| 790 | - if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) { |
|
| 790 | + if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 791 | 791 | //if trashing then remove relations to base default ticket. If restoring then add back to base default ticket |
| 792 | - if ( $PRC_deleted ) { |
|
| 792 | + if ($PRC_deleted) { |
|
| 793 | 793 | $ticket->_remove_relation_to($PRC_ID, 'Price'); |
| 794 | 794 | } else { |
| 795 | 795 | $ticket->_add_relation_to($PRC_ID, 'Price'); |
@@ -801,14 +801,14 @@ discard block |
||
| 801 | 801 | |
| 802 | 802 | } else { |
| 803 | 803 | // grab single id and delete |
| 804 | - $PRC_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
| 805 | - if ( empty( $PRC_ID ) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID) ) { |
|
| 804 | + $PRC_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
| 805 | + if (empty($PRC_ID) || ! $PRC->update_by_ID(array('PRC_deleted' => $PRC_deleted), $PRC_ID)) { |
|
| 806 | 806 | $success = 0; |
| 807 | 807 | } else { |
| 808 | 808 | $PR = EEM_Price::instance()->get_one_by_ID($PRC_ID); |
| 809 | - if ( $PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax ) { |
|
| 809 | + if ($PR->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) { |
|
| 810 | 810 | //if trashing then remove relations to base default ticket. If restoring then add back to base default ticket |
| 811 | - if ( $PRC_deleted ) { |
|
| 811 | + if ($PRC_deleted) { |
|
| 812 | 812 | $ticket->_remove_relation_to($PRC_ID, 'Price'); |
| 813 | 813 | } else { |
| 814 | 814 | $ticket->_add_relation_to($PRC_ID, 'Price'); |
@@ -822,17 +822,17 @@ discard block |
||
| 822 | 822 | 'action' => 'default' |
| 823 | 823 | ); |
| 824 | 824 | |
| 825 | - if ( $success ) { |
|
| 826 | - if ( $trash ) { |
|
| 825 | + if ($success) { |
|
| 826 | + if ($trash) { |
|
| 827 | 827 | $msg = $success == 2 ? __('The Prices have been trashed.', 'event_espresso') : __('The Price has been trashed.', 'event_espresso'); |
| 828 | 828 | } else { |
| 829 | 829 | $msg = $success == 2 ? __('The Prices have been restored.', 'event_espresso') : __('The Price has been restored.', 'event_espresso'); |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | - EE_Error::add_success( $msg ); |
|
| 832 | + EE_Error::add_success($msg); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
| 835 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
| 836 | 836 | |
| 837 | 837 | } |
| 838 | 838 | |
@@ -849,19 +849,19 @@ discard block |
||
| 849 | 849 | protected function _delete_price() { |
| 850 | 850 | |
| 851 | 851 | //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 852 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 852 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 853 | 853 | |
| 854 | - require_once(EE_MODELS . 'EEM_Price.model.php'); |
|
| 854 | + require_once(EE_MODELS.'EEM_Price.model.php'); |
|
| 855 | 855 | $PRC = EEM_Price::instance(); |
| 856 | 856 | |
| 857 | 857 | $success = 1; |
| 858 | 858 | //Checkboxes |
| 859 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 859 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 860 | 860 | // if array has more than one element than success message should be plural |
| 861 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 861 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 862 | 862 | // cycle thru bulk action checkboxes |
| 863 | - while (list( $PRC_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 864 | - if (!$PRC->delete_permanently_by_ID(absint($PRC_ID))) { |
|
| 863 | + while (list($PRC_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 864 | + if ( ! $PRC->delete_permanently_by_ID(absint($PRC_ID))) { |
|
| 865 | 865 | $success = 0; |
| 866 | 866 | } |
| 867 | 867 | } |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - $this->_redirect_after_action( $success, 'Prices', 'deleted', array() ); |
|
| 878 | + $this->_redirect_after_action($success, 'Prices', 'deleted', array()); |
|
| 879 | 879 | |
| 880 | 880 | } |
| 881 | 881 | |
@@ -883,16 +883,16 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | |
| 885 | 885 | public function update_price_order() { |
| 886 | - $success = __( 'Price order was updated successfully.', 'event_espresso' ); |
|
| 886 | + $success = __('Price order was updated successfully.', 'event_espresso'); |
|
| 887 | 887 | |
| 888 | 888 | // grab our row IDs |
| 889 | - $row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) : FALSE; |
|
| 889 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(',', rtrim($this->_req_data['row_ids'], ',')) : FALSE; |
|
| 890 | 890 | |
| 891 | - if ( is_array( $row_ids )) { |
|
| 892 | - for ( $i = 0; $i < count( $row_ids ); $i++ ) { |
|
| 891 | + if (is_array($row_ids)) { |
|
| 892 | + for ($i = 0; $i < count($row_ids); $i++) { |
|
| 893 | 893 | //Update the prices when re-ordering |
| 894 | 894 | $id = absint($row_ids[$i]); |
| 895 | - if ( EEM_Price::instance()->update ( array( 'PRC_order' => $i+1 ), array(array( 'PRC_ID' => $id ) )) === FALSE ) { |
|
| 895 | + if (EEM_Price::instance()->update(array('PRC_order' => $i + 1), array(array('PRC_ID' => $id))) === FALSE) { |
|
| 896 | 896 | $success = FALSE; |
| 897 | 897 | } |
| 898 | 898 | } |
@@ -900,9 +900,9 @@ discard block |
||
| 900 | 900 | $success = FALSE; |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | - $errors = ! $success ? __( 'An error occurred. The price order was not updated.', 'event_espresso' ) : FALSE; |
|
| 903 | + $errors = ! $success ? __('An error occurred. The price order was not updated.', 'event_espresso') : FALSE; |
|
| 904 | 904 | |
| 905 | - echo wp_json_encode( array( 'return_data' => FALSE, 'success' => $success, 'errors' => $errors )); |
|
| 905 | + echo wp_json_encode(array('return_data' => FALSE, 'success' => $success, 'errors' => $errors)); |
|
| 906 | 906 | die(); |
| 907 | 907 | } |
| 908 | 908 | |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | * @return void |
| 927 | 927 | */ |
| 928 | 928 | protected function _price_types_overview_list_table() { |
| 929 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
| 929 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
| 930 | 930 | 'add_new_price_type', |
| 931 | 931 | 'add_type', |
| 932 | 932 | array(), |
@@ -950,46 +950,46 @@ discard block |
||
| 950 | 950 | * @param boolean $trashed whether the current view is of the trash can - eww yuck! |
| 951 | 951 | * @return mixed (int|array) int = count || array of price objects |
| 952 | 952 | */ |
| 953 | - public function get_price_types_overview_data( $per_page = 10, $count = FALSE, $trashed = FALSE ) { |
|
| 953 | + public function get_price_types_overview_data($per_page = 10, $count = FALSE, $trashed = FALSE) { |
|
| 954 | 954 | |
| 955 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 955 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 956 | 956 | // start with an empty array |
| 957 | 957 | |
| 958 | - require_once( PRICING_ADMIN . 'Price_Types_List_Table.class.php' ); |
|
| 959 | - require_once( EE_MODELS . 'EEM_Price_Type.model.php' ); |
|
| 958 | + require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php'); |
|
| 959 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
| 960 | 960 | |
| 961 | 961 | $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? '' : $this->_req_data['orderby']; |
| 962 | - $order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC'; |
|
| 962 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC'; |
|
| 963 | 963 | switch ($this->_req_data['orderby']) { |
| 964 | 964 | case 'name': |
| 965 | - $orderby = array( 'PRT_name' => $order); |
|
| 965 | + $orderby = array('PRT_name' => $order); |
|
| 966 | 966 | break; |
| 967 | 967 | default: |
| 968 | - $orderby = array( 'PRT_order' => $order); |
|
| 968 | + $orderby = array('PRT_order' => $order); |
|
| 969 | 969 | } |
| 970 | 970 | |
| 971 | 971 | |
| 972 | - $current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1; |
|
| 973 | - $per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page; |
|
| 972 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1; |
|
| 973 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page; |
|
| 974 | 974 | |
| 975 | - $offset = ($current_page-1)*$per_page; |
|
| 976 | - $limit = array( $offset, $per_page ); |
|
| 975 | + $offset = ($current_page - 1) * $per_page; |
|
| 976 | + $limit = array($offset, $per_page); |
|
| 977 | 977 | |
| 978 | - $_where = array('PRT_deleted'=>$trashed, 'PBT_ID' => array('!=', 1 ) ); |
|
| 978 | + $_where = array('PRT_deleted'=>$trashed, 'PBT_ID' => array('!=', 1)); |
|
| 979 | 979 | |
| 980 | - if ( isset( $this->_req_data['s'] ) ) { |
|
| 981 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 980 | + if (isset($this->_req_data['s'])) { |
|
| 981 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 982 | 982 | $_where['OR'] = array( |
| 983 | - 'PRT_name' => array( 'LIKE', $sstr ) |
|
| 983 | + 'PRT_name' => array('LIKE', $sstr) |
|
| 984 | 984 | ); |
| 985 | 985 | } |
| 986 | 986 | $query_params = array( |
| 987 | 987 | $_where, |
| 988 | 988 | 'order_by'=>$orderby, |
| 989 | 989 | 'limit'=>$limit); |
| 990 | - if($count){ |
|
| 990 | + if ($count) { |
|
| 991 | 991 | return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params); |
| 992 | - }else{ |
|
| 992 | + } else { |
|
| 993 | 993 | return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params); |
| 994 | 994 | } |
| 995 | 995 | |
@@ -1009,34 +1009,34 @@ discard block |
||
| 1009 | 1009 | */ |
| 1010 | 1010 | protected function _edit_price_type_details() { |
| 1011 | 1011 | |
| 1012 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1012 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1013 | 1013 | |
| 1014 | 1014 | |
| 1015 | 1015 | // grab price type ID |
| 1016 | - $PRT_ID = isset( $this->_req_data['id'] ) && ! empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE; |
|
| 1016 | + $PRT_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE; |
|
| 1017 | 1017 | // change page title based on request action |
| 1018 | - switch( $this->_req_action ) { |
|
| 1018 | + switch ($this->_req_action) { |
|
| 1019 | 1019 | case 'add_new_price_type' : |
| 1020 | - $this->_admin_page_title = esc_html__( 'Add New Price Type', 'event_espresso' ); |
|
| 1020 | + $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso'); |
|
| 1021 | 1021 | break; |
| 1022 | 1022 | case 'edit_price_type' : |
| 1023 | - $this->_admin_page_title = esc_html__( 'Edit Price Type', 'event_espresso' ); |
|
| 1023 | + $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso'); |
|
| 1024 | 1024 | break; |
| 1025 | 1025 | default : |
| 1026 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
| 1026 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | // add PRT_ID to title if editing |
| 1029 | - $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title; |
|
| 1029 | + $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title; |
|
| 1030 | 1030 | |
| 1031 | 1031 | // require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
| 1032 | 1032 | |
| 1033 | - if ( $PRT_ID ) { |
|
| 1034 | - $price_type = EEM_Price_Type::instance()->get_one_by_ID( $PRT_ID ); |
|
| 1035 | - $additional_hidden_fields = array( 'PRT_ID' => array( 'type' => 'hidden', 'value' => $PRT_ID )); |
|
| 1036 | - $this->_set_add_edit_form_tags( 'update_price_type', $additional_hidden_fields ); |
|
| 1033 | + if ($PRT_ID) { |
|
| 1034 | + $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID); |
|
| 1035 | + $additional_hidden_fields = array('PRT_ID' => array('type' => 'hidden', 'value' => $PRT_ID)); |
|
| 1036 | + $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields); |
|
| 1037 | 1037 | } else { |
| 1038 | 1038 | $price_type = EEM_Price_Type::instance()->get_new_price_type(); |
| 1039 | - $this->_set_add_edit_form_tags( 'insert_price_type' ); |
|
| 1039 | + $this->_set_add_edit_form_tags('insert_price_type'); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | $this->_template_args['PRT_ID'] = $PRT_ID; |
@@ -1045,19 +1045,19 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | $base_types = EEM_Price_Type::instance()->get_base_types(); |
| 1047 | 1047 | $select_values = array(); |
| 1048 | - foreach ( $base_types as $ref => $text ) { |
|
| 1049 | - if ( $ref == EEM_Price_Type::base_type_base_price ) { |
|
| 1048 | + foreach ($base_types as $ref => $text) { |
|
| 1049 | + if ($ref == EEM_Price_Type::base_type_base_price) { |
|
| 1050 | 1050 | //do not allow creation of base_type_base_prices because that's a system only base type. |
| 1051 | 1051 | continue; |
| 1052 | 1052 | } |
| 1053 | - $values[] = array( 'id' => $ref, 'text' => $text ); |
|
| 1053 | + $values[] = array('id' => $ref, 'text' => $text); |
|
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | |
| 1057 | 1057 | $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input('base_type', $values, $price_type->base_type(), 'id="price-type-base-type-slct"'); |
| 1058 | 1058 | $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link(); |
| 1059 | - $redirect_URL = add_query_arg( array( 'action' => 'price_types'), $this->_admin_base_url ); |
|
| 1060 | - $this->_set_publish_post_box_vars( 'id', $PRT_ID, FALSE, $redirect_URL ); |
|
| 1059 | + $redirect_URL = add_query_arg(array('action' => 'price_types'), $this->_admin_base_url); |
|
| 1060 | + $this->_set_publish_post_box_vars('id', $PRT_ID, FALSE, $redirect_URL); |
|
| 1061 | 1061 | // the details template wrapper |
| 1062 | 1062 | $this->display_admin_page_with_sidebar(); |
| 1063 | 1063 | |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | * @return void |
| 1075 | 1075 | */ |
| 1076 | 1076 | protected function _price_type_details_meta_boxes() { |
| 1077 | - add_meta_box( 'edit-price-details-mbox', __( 'Price Type Details', 'event_espresso' ), array( $this, '_edit_price_type_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' ); |
|
| 1077 | + add_meta_box('edit-price-details-mbox', __('Price Type Details', 'event_espresso'), array($this, '_edit_price_type_details_meta_box'), $this->wp_page_slug, 'normal', 'high'); |
|
| 1078 | 1078 | } |
| 1079 | 1079 | |
| 1080 | 1080 | |
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | * @return void |
| 1088 | 1088 | */ |
| 1089 | 1089 | public function _edit_price_type_details_meta_box() { |
| 1090 | - echo EEH_Template::display_template( PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
| 1090 | + echo EEH_Template::display_template(PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php', $this->_template_args, TRUE); |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 | |
@@ -1100,9 +1100,9 @@ discard block |
||
| 1100 | 1100 | */ |
| 1101 | 1101 | protected function set_price_type_column_values() { |
| 1102 | 1102 | |
| 1103 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1103 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1104 | 1104 | |
| 1105 | - $base_type = !empty( $this->_req_data['base_type'] ) ? $this->_req_data['base_type'] : EEM_Price_Type::base_type_base_price; |
|
| 1105 | + $base_type = ! empty($this->_req_data['base_type']) ? $this->_req_data['base_type'] : EEM_Price_Type::base_type_base_price; |
|
| 1106 | 1106 | |
| 1107 | 1107 | switch ($base_type) { |
| 1108 | 1108 | |
@@ -1149,12 +1149,12 @@ discard block |
||
| 1149 | 1149 | * @access protected |
| 1150 | 1150 | * @return void |
| 1151 | 1151 | */ |
| 1152 | - protected function _insert_or_update_price_type( $new_price_type = FALSE ) { |
|
| 1152 | + protected function _insert_or_update_price_type($new_price_type = FALSE) { |
|
| 1153 | 1153 | |
| 1154 | 1154 | // echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 1155 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1155 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1156 | 1156 | |
| 1157 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
| 1157 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
| 1158 | 1158 | $PRT = EEM_Price_Type::instance(); |
| 1159 | 1159 | |
| 1160 | 1160 | // why be so pessimistic ??? : ( |
@@ -1162,24 +1162,24 @@ discard block |
||
| 1162 | 1162 | |
| 1163 | 1163 | $set_column_values = $this->set_price_type_column_values(); |
| 1164 | 1164 | // is this a new Price ? |
| 1165 | - if ( $new_price_type ) { |
|
| 1165 | + if ($new_price_type) { |
|
| 1166 | 1166 | // run the insert |
| 1167 | - if ( $PRT_ID = $PRT->insert( $set_column_values )) { |
|
| 1167 | + if ($PRT_ID = $PRT->insert($set_column_values)) { |
|
| 1168 | 1168 | $success = 1; |
| 1169 | 1169 | } |
| 1170 | 1170 | $action_desc = 'created'; |
| 1171 | 1171 | } else { |
| 1172 | 1172 | $PRT_ID = absint($this->_req_data['PRT_ID']); |
| 1173 | 1173 | // run the update |
| 1174 | - $where_cols_n_values = array('PRT_ID' => $PRT_ID ); |
|
| 1175 | - if ( $PRT->update( $set_column_values, array( $where_cols_n_values ))) { |
|
| 1174 | + $where_cols_n_values = array('PRT_ID' => $PRT_ID); |
|
| 1175 | + if ($PRT->update($set_column_values, array($where_cols_n_values))) { |
|
| 1176 | 1176 | $success = 1; |
| 1177 | 1177 | } |
| 1178 | 1178 | $action_desc = 'updated'; |
| 1179 | 1179 | } |
| 1180 | 1180 | |
| 1181 | - $query_args = array( 'action'=> 'edit_price_type', 'id' => $PRT_ID ); |
|
| 1182 | - $this->_redirect_after_action( $success, 'Price Type', $action_desc, $query_args ); |
|
| 1181 | + $query_args = array('action'=> 'edit_price_type', 'id' => $PRT_ID); |
|
| 1182 | + $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args); |
|
| 1183 | 1183 | |
| 1184 | 1184 | } |
| 1185 | 1185 | |
@@ -1193,49 +1193,49 @@ discard block |
||
| 1193 | 1193 | * @access protected |
| 1194 | 1194 | * @return void |
| 1195 | 1195 | */ |
| 1196 | - protected function _trash_or_restore_price_type( $trash = TRUE ) { |
|
| 1196 | + protected function _trash_or_restore_price_type($trash = TRUE) { |
|
| 1197 | 1197 | |
| 1198 | 1198 | //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 1199 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1199 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1200 | 1200 | |
| 1201 | - require_once(EE_MODELS . 'EEM_Price_Type.model.php'); |
|
| 1201 | + require_once(EE_MODELS.'EEM_Price_Type.model.php'); |
|
| 1202 | 1202 | $PRT = EEM_Price_Type::instance(); |
| 1203 | 1203 | |
| 1204 | 1204 | $success = 1; |
| 1205 | 1205 | $PRT_deleted = $trash ? TRUE : FALSE; |
| 1206 | 1206 | //Checkboxes |
| 1207 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1207 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1208 | 1208 | // if array has more than one element than success message should be plural |
| 1209 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 1210 | - $what = count( $this->_req_data['checkbox'] ) > 1 ? 'Price Types' : 'Price Type'; |
|
| 1209 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1210 | + $what = count($this->_req_data['checkbox']) > 1 ? 'Price Types' : 'Price Type'; |
|
| 1211 | 1211 | // cycle thru checkboxes |
| 1212 | - while (list( $PRT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 1213 | - if ( ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID ) ) { |
|
| 1212 | + while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1213 | + if ( ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) { |
|
| 1214 | 1214 | $success = 0; |
| 1215 | 1215 | } |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | } else { |
| 1219 | 1219 | // grab single id and delete |
| 1220 | - $PRT_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0; |
|
| 1221 | - if ( empty( $PRT_ID ) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID )) { |
|
| 1220 | + $PRT_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0; |
|
| 1221 | + if (empty($PRT_ID) || ! $PRT->update_by_ID(array('PRT_deleted' => $PRT_deleted), $PRT_ID)) { |
|
| 1222 | 1222 | $success = 0; |
| 1223 | 1223 | } |
| 1224 | 1224 | $what = 'Price Type'; |
| 1225 | 1225 | |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - $query_args = array( 'action' => 'price_types' ); |
|
| 1229 | - if ( $success ) { |
|
| 1230 | - if ( $trash ) { |
|
| 1228 | + $query_args = array('action' => 'price_types'); |
|
| 1229 | + if ($success) { |
|
| 1230 | + if ($trash) { |
|
| 1231 | 1231 | $msg = $success > 1 ? __('The Price Types have been trashed.', 'event_espresso') : __('The Price Type has been trashed.', 'event_espresso'); |
| 1232 | 1232 | } else { |
| 1233 | 1233 | $msg = $success > 1 ? __('The Price Types have been restored.', 'event_espresso') : __('The Price Type has been restored.', 'event_espresso'); |
| 1234 | 1234 | } |
| 1235 | - EE_Error::add_success( $msg ); |
|
| 1235 | + EE_Error::add_success($msg); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | - $this->_redirect_after_action( FALSE, '', '', $query_args, TRUE ); |
|
| 1238 | + $this->_redirect_after_action(FALSE, '', '', $query_args, TRUE); |
|
| 1239 | 1239 | |
| 1240 | 1240 | } |
| 1241 | 1241 | |
@@ -1252,19 +1252,19 @@ discard block |
||
| 1252 | 1252 | protected function _delete_price_type() { |
| 1253 | 1253 | |
| 1254 | 1254 | //echo '<h3>'. __CLASS__ . '->' . __FUNCTION__ . ' <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h3>'; |
| 1255 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
| 1255 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1256 | 1256 | |
| 1257 | 1257 | $PRT = EEM_Price_Type::instance(); |
| 1258 | 1258 | |
| 1259 | 1259 | $success = 1; |
| 1260 | 1260 | //Checkboxes |
| 1261 | - if (!empty($this->_req_data['checkbox'])) { |
|
| 1261 | + if ( ! empty($this->_req_data['checkbox'])) { |
|
| 1262 | 1262 | // if array has more than one element than success message should be plural |
| 1263 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
| 1263 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1264 | 1264 | $what = $PRT->item_name($success); |
| 1265 | 1265 | // cycle thru bulk action checkboxes |
| 1266 | - while (list( $PRT_ID, $value ) = each($this->_req_data['checkbox'])) { |
|
| 1267 | - if (!$PRT->delete_permanently_by_ID($PRT_ID) ) { |
|
| 1266 | + while (list($PRT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1267 | + if ( ! $PRT->delete_permanently_by_ID($PRT_ID)) { |
|
| 1268 | 1268 | $success = 0; |
| 1269 | 1269 | } |
| 1270 | 1270 | } |
@@ -1272,8 +1272,8 @@ discard block |
||
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | |
| 1275 | - $query_args = array( 'action'=> 'price_types' ); |
|
| 1276 | - $this->_redirect_after_action( $success, $what, 'deleted', $query_args ); |
|
| 1275 | + $query_args = array('action'=> 'price_types'); |
|
| 1276 | + $this->_redirect_after_action($success, $what, 'deleted', $query_args); |
|
| 1277 | 1277 | |
| 1278 | 1278 | } |
| 1279 | 1279 | |
@@ -1289,7 +1289,7 @@ discard block |
||
| 1289 | 1289 | * @return string |
| 1290 | 1290 | */ |
| 1291 | 1291 | protected function _learn_more_about_pricing_link() { |
| 1292 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how pricing works', 'event_espresso') . '</a>'; |
|
| 1292 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how pricing works', 'event_espresso').'</a>'; |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | |
@@ -1365,17 +1365,17 @@ discard block |
||
| 1365 | 1365 | * @return void |
| 1366 | 1366 | */ |
| 1367 | 1367 | public function _update_tax_settings() { |
| 1368 | - if ( ! isset( EE_Registry::instance()->CFG->tax_settings ) ) { |
|
| 1368 | + if ( ! isset(EE_Registry::instance()->CFG->tax_settings)) { |
|
| 1369 | 1369 | EE_Registry::instance()->CFG->tax_settings = new EE_Tax_Config(); |
| 1370 | 1370 | } |
| 1371 | 1371 | try { |
| 1372 | 1372 | $tax_form = $this->tax_settings_form(); |
| 1373 | 1373 | //check for form submission |
| 1374 | - if ( $tax_form->was_submitted() ) { |
|
| 1374 | + if ($tax_form->was_submitted()) { |
|
| 1375 | 1375 | //capture form data |
| 1376 | 1376 | $tax_form->receive_form_submission(); |
| 1377 | 1377 | //validate form data |
| 1378 | - if ( $tax_form->is_valid() ) { |
|
| 1378 | + if ($tax_form->is_valid()) { |
|
| 1379 | 1379 | //grab validated data from form |
| 1380 | 1380 | $valid_data = $tax_form->valid_data(); |
| 1381 | 1381 | //set data on config |
@@ -1385,7 +1385,7 @@ discard block |
||
| 1385 | 1385 | ->prices_displayed_including_taxes |
| 1386 | 1386 | = $valid_data['tax_settings']['prices_displayed_including_taxes']; |
| 1387 | 1387 | } else { |
| 1388 | - if ( $tax_form->submission_error_message() !== '' ) { |
|
| 1388 | + if ($tax_form->submission_error_message() !== '') { |
|
| 1389 | 1389 | EE_Error::add_error( |
| 1390 | 1390 | $tax_form->submission_error_message(), |
| 1391 | 1391 | __FILE__, |
@@ -1395,8 +1395,8 @@ discard block |
||
| 1395 | 1395 | } |
| 1396 | 1396 | } |
| 1397 | 1397 | } |
| 1398 | - } catch ( EE_Error $e ) { |
|
| 1399 | - EE_Error::add_error( $e->get_error(), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 1398 | + } catch (EE_Error $e) { |
|
| 1399 | + EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__); |
|
| 1400 | 1400 | } |
| 1401 | 1401 | |
| 1402 | 1402 | $what = 'Tax Settings'; |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | __FUNCTION__, |
| 1408 | 1408 | __LINE__ |
| 1409 | 1409 | ); |
| 1410 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'tax_settings' ) ); |
|
| 1410 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'tax_settings')); |
|
| 1411 | 1411 | } |
| 1412 | 1412 | |
| 1413 | 1413 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -16,1229 +16,1229 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Extend_Events_Admin_Page constructor. |
|
| 21 | - * |
|
| 22 | - * @param bool $routing |
|
| 23 | - */ |
|
| 24 | - public function __construct($routing = true) |
|
| 25 | - { |
|
| 26 | - parent::__construct($routing); |
|
| 27 | - if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - protected function _extend_page_config() |
|
| 37 | - { |
|
| 38 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 39 | - //is there a evt_id in the request? |
|
| 40 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 41 | - ? $this->_req_data['EVT_ID'] |
|
| 42 | - : 0; |
|
| 43 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 44 | - //tkt_id? |
|
| 45 | - $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
| 46 | - ? $this->_req_data['TKT_ID'] |
|
| 47 | - : 0; |
|
| 48 | - $new_page_routes = array( |
|
| 49 | - 'duplicate_event' => array( |
|
| 50 | - 'func' => '_duplicate_event', |
|
| 51 | - 'capability' => 'ee_edit_event', |
|
| 52 | - 'obj_id' => $evt_id, |
|
| 53 | - 'noheader' => true, |
|
| 54 | - ), |
|
| 55 | - 'ticket_list_table' => array( |
|
| 56 | - 'func' => '_tickets_overview_list_table', |
|
| 57 | - 'capability' => 'ee_read_default_tickets', |
|
| 58 | - ), |
|
| 59 | - 'trash_ticket' => array( |
|
| 60 | - 'func' => '_trash_or_restore_ticket', |
|
| 61 | - 'capability' => 'ee_delete_default_ticket', |
|
| 62 | - 'obj_id' => $tkt_id, |
|
| 63 | - 'noheader' => true, |
|
| 64 | - 'args' => array('trash' => true), |
|
| 65 | - ), |
|
| 66 | - 'trash_tickets' => array( |
|
| 67 | - 'func' => '_trash_or_restore_ticket', |
|
| 68 | - 'capability' => 'ee_delete_default_tickets', |
|
| 69 | - 'noheader' => true, |
|
| 70 | - 'args' => array('trash' => true), |
|
| 71 | - ), |
|
| 72 | - 'restore_ticket' => array( |
|
| 73 | - 'func' => '_trash_or_restore_ticket', |
|
| 74 | - 'capability' => 'ee_delete_default_ticket', |
|
| 75 | - 'obj_id' => $tkt_id, |
|
| 76 | - 'noheader' => true, |
|
| 77 | - ), |
|
| 78 | - 'restore_tickets' => array( |
|
| 79 | - 'func' => '_trash_or_restore_ticket', |
|
| 80 | - 'capability' => 'ee_delete_default_tickets', |
|
| 81 | - 'noheader' => true, |
|
| 82 | - ), |
|
| 83 | - 'delete_ticket' => array( |
|
| 84 | - 'func' => '_delete_ticket', |
|
| 85 | - 'capability' => 'ee_delete_default_ticket', |
|
| 86 | - 'obj_id' => $tkt_id, |
|
| 87 | - 'noheader' => true, |
|
| 88 | - ), |
|
| 89 | - 'delete_tickets' => array( |
|
| 90 | - 'func' => '_delete_ticket', |
|
| 91 | - 'capability' => 'ee_delete_default_tickets', |
|
| 92 | - 'noheader' => true, |
|
| 93 | - ), |
|
| 94 | - 'import_page' => array( |
|
| 95 | - 'func' => '_import_page', |
|
| 96 | - 'capability' => 'import', |
|
| 97 | - ), |
|
| 98 | - 'import' => array( |
|
| 99 | - 'func' => '_import_events', |
|
| 100 | - 'capability' => 'import', |
|
| 101 | - 'noheader' => true, |
|
| 102 | - ), |
|
| 103 | - 'import_events' => array( |
|
| 104 | - 'func' => '_import_events', |
|
| 105 | - 'capability' => 'import', |
|
| 106 | - 'noheader' => true, |
|
| 107 | - ), |
|
| 108 | - 'export_events' => array( |
|
| 109 | - 'func' => '_events_export', |
|
| 110 | - 'capability' => 'export', |
|
| 111 | - 'noheader' => true, |
|
| 112 | - ), |
|
| 113 | - 'export_categories' => array( |
|
| 114 | - 'func' => '_categories_export', |
|
| 115 | - 'capability' => 'export', |
|
| 116 | - 'noheader' => true, |
|
| 117 | - ), |
|
| 118 | - 'sample_export_file' => array( |
|
| 119 | - 'func' => '_sample_export_file', |
|
| 120 | - 'capability' => 'export', |
|
| 121 | - 'noheader' => true, |
|
| 122 | - ), |
|
| 123 | - 'update_template_settings' => array( |
|
| 124 | - 'func' => '_update_template_settings', |
|
| 125 | - 'capability' => 'manage_options', |
|
| 126 | - 'noheader' => true, |
|
| 127 | - ), |
|
| 128 | - ); |
|
| 129 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 130 | - //partial route/config override |
|
| 131 | - $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
| 132 | - $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 133 | - $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 134 | - $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 135 | - $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 136 | - $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
| 137 | - //add tickets tab but only if there are more than one default ticket! |
|
| 138 | - $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 139 | - array(array('TKT_is_default' => 1)), |
|
| 140 | - 'TKT_ID', |
|
| 141 | - true |
|
| 142 | - ); |
|
| 143 | - if ($tkt_count > 1) { |
|
| 144 | - $new_page_config = array( |
|
| 145 | - 'ticket_list_table' => array( |
|
| 146 | - 'nav' => array( |
|
| 147 | - 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
| 148 | - 'order' => 60, |
|
| 149 | - ), |
|
| 150 | - 'list_table' => 'Tickets_List_Table', |
|
| 151 | - 'require_nonce' => false, |
|
| 152 | - ), |
|
| 153 | - ); |
|
| 154 | - } |
|
| 155 | - //template settings |
|
| 156 | - $new_page_config['template_settings'] = array( |
|
| 157 | - 'nav' => array( |
|
| 158 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 159 | - 'order' => 30, |
|
| 160 | - ), |
|
| 161 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 162 | - 'help_tabs' => array( |
|
| 163 | - 'general_settings_templates_help_tab' => array( |
|
| 164 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 165 | - 'filename' => 'general_settings_templates', |
|
| 166 | - ), |
|
| 167 | - ), |
|
| 168 | - 'help_tour' => array('Templates_Help_Tour'), |
|
| 169 | - 'require_nonce' => false, |
|
| 170 | - ); |
|
| 171 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 172 | - //add filters and actions |
|
| 173 | - //modifying _views |
|
| 174 | - add_filter( |
|
| 175 | - 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
| 176 | - array($this, 'add_additional_datetime_button'), |
|
| 177 | - 10, |
|
| 178 | - 2 |
|
| 179 | - ); |
|
| 180 | - add_filter( |
|
| 181 | - 'FHEE_event_datetime_metabox_clone_button_template', |
|
| 182 | - array($this, 'add_datetime_clone_button'), |
|
| 183 | - 10, |
|
| 184 | - 2 |
|
| 185 | - ); |
|
| 186 | - add_filter( |
|
| 187 | - 'FHEE_event_datetime_metabox_timezones_template', |
|
| 188 | - array($this, 'datetime_timezones_template'), |
|
| 189 | - 10, |
|
| 190 | - 2 |
|
| 191 | - ); |
|
| 192 | - //filters for event list table |
|
| 193 | - add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
| 194 | - add_filter( |
|
| 195 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 196 | - array($this, 'extra_list_table_actions'), |
|
| 197 | - 10, |
|
| 198 | - 2 |
|
| 199 | - ); |
|
| 200 | - //legend item |
|
| 201 | - add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
| 202 | - add_action('admin_init', array($this, 'admin_init')); |
|
| 203 | - //heartbeat stuff |
|
| 204 | - add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * admin_init |
|
| 211 | - */ |
|
| 212 | - public function admin_init() |
|
| 213 | - { |
|
| 214 | - EE_Registry::$i18n_js_strings = array_merge( |
|
| 215 | - EE_Registry::$i18n_js_strings, |
|
| 216 | - array( |
|
| 217 | - 'image_confirm' => esc_html__( |
|
| 218 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 219 | - 'event_espresso' |
|
| 220 | - ), |
|
| 221 | - 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
| 222 | - 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
| 223 | - 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
| 224 | - 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
| 225 | - 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
| 226 | - ) |
|
| 227 | - ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
| 234 | - * accordingly. |
|
| 235 | - * |
|
| 236 | - * @param array $response The existing heartbeat response array. |
|
| 237 | - * @param array $data The incoming data package. |
|
| 238 | - * @return array possibly appended response. |
|
| 239 | - */ |
|
| 240 | - public function heartbeat_response($response, $data) |
|
| 241 | - { |
|
| 242 | - /** |
|
| 243 | - * check whether count of tickets is approaching the potential |
|
| 244 | - * limits for the server. |
|
| 245 | - */ |
|
| 246 | - if ( ! empty($data['input_count'])) { |
|
| 247 | - $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
| 248 | - $data['input_count'] |
|
| 249 | - ); |
|
| 250 | - } |
|
| 251 | - return $response; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - protected function _add_screen_options_ticket_list_table() |
|
| 257 | - { |
|
| 258 | - $this->_per_page_screen_option(); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * @param string $return |
|
| 265 | - * @param int $id |
|
| 266 | - * @param string $new_title |
|
| 267 | - * @param string $new_slug |
|
| 268 | - * @return string |
|
| 269 | - */ |
|
| 270 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 271 | - { |
|
| 272 | - $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
| 273 | - //make sure this is only when editing |
|
| 274 | - if ( ! empty($id)) { |
|
| 275 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
| 276 | - array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
| 277 | - $this->_admin_base_url |
|
| 278 | - ); |
|
| 279 | - $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
| 280 | - $return .= '<a href="' |
|
| 281 | - . $href |
|
| 282 | - . '" title="' |
|
| 283 | - . $title |
|
| 284 | - . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
| 285 | - . $title |
|
| 286 | - . '</button>'; |
|
| 287 | - } |
|
| 288 | - return $return; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - public function _set_list_table_views_ticket_list_table() |
|
| 294 | - { |
|
| 295 | - $this->_views = array( |
|
| 296 | - 'all' => array( |
|
| 297 | - 'slug' => 'all', |
|
| 298 | - 'label' => esc_html__('All', 'event_espresso'), |
|
| 299 | - 'count' => 0, |
|
| 300 | - 'bulk_action' => array( |
|
| 301 | - 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 302 | - ), |
|
| 303 | - ), |
|
| 304 | - 'trashed' => array( |
|
| 305 | - 'slug' => 'trashed', |
|
| 306 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 307 | - 'count' => 0, |
|
| 308 | - 'bulk_action' => array( |
|
| 309 | - 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 310 | - 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 311 | - ), |
|
| 312 | - ), |
|
| 313 | - ); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - |
|
| 318 | - public function load_scripts_styles_edit() |
|
| 319 | - { |
|
| 320 | - wp_register_script( |
|
| 321 | - 'ee-event-editor-heartbeat', |
|
| 322 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 323 | - array('ee_admin_js', 'heartbeat'), |
|
| 324 | - EVENT_ESPRESSO_VERSION, |
|
| 325 | - true |
|
| 326 | - ); |
|
| 327 | - /** |
|
| 328 | - * load accounting js. |
|
| 329 | - */ |
|
| 330 | - add_filter('FHEE_load_accounting_js', '__return_true'); |
|
| 331 | - //styles |
|
| 332 | - wp_enqueue_style('espresso-ui-theme'); |
|
| 333 | - wp_enqueue_script('event_editor_js'); |
|
| 334 | - wp_enqueue_script('ee-event-editor-heartbeat'); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * @param $template |
|
| 341 | - * @param $template_args |
|
| 342 | - * @return mixed |
|
| 343 | - */ |
|
| 344 | - public function add_additional_datetime_button($template, $template_args) |
|
| 345 | - { |
|
| 346 | - return EEH_Template::display_template( |
|
| 347 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
| 348 | - $template_args, |
|
| 349 | - true |
|
| 350 | - ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * @param $template |
|
| 357 | - * @param $template_args |
|
| 358 | - * @return mixed |
|
| 359 | - */ |
|
| 360 | - public function add_datetime_clone_button($template, $template_args) |
|
| 361 | - { |
|
| 362 | - return EEH_Template::display_template( |
|
| 363 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
| 364 | - $template_args, |
|
| 365 | - true |
|
| 366 | - ); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * @param $template |
|
| 373 | - * @param $template_args |
|
| 374 | - * @return mixed |
|
| 375 | - */ |
|
| 376 | - public function datetime_timezones_template($template, $template_args) |
|
| 377 | - { |
|
| 378 | - return EEH_Template::display_template( |
|
| 379 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
| 380 | - $template_args, |
|
| 381 | - true |
|
| 382 | - ); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - |
|
| 387 | - protected function _set_list_table_views_default() |
|
| 388 | - { |
|
| 389 | - parent::_set_list_table_views_default(); |
|
| 390 | - $new_views = array( |
|
| 391 | - 'today' => array( |
|
| 392 | - 'slug' => 'today', |
|
| 393 | - 'label' => esc_html__('Today', 'event_espresso'), |
|
| 394 | - 'count' => $this->total_events_today(), |
|
| 395 | - 'bulk_action' => array( |
|
| 396 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 397 | - ), |
|
| 398 | - ), |
|
| 399 | - 'month' => array( |
|
| 400 | - 'slug' => 'month', |
|
| 401 | - 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 402 | - 'count' => $this->total_events_this_month(), |
|
| 403 | - 'bulk_action' => array( |
|
| 404 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 405 | - ), |
|
| 406 | - ), |
|
| 407 | - ); |
|
| 408 | - $this->_views = array_merge($this->_views, $new_views); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * @param array $action_links |
|
| 415 | - * @param \EE_Event $event |
|
| 416 | - * @return array |
|
| 417 | - */ |
|
| 418 | - public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
| 419 | - { |
|
| 420 | - if ( |
|
| 421 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 422 | - 'ee_read_registrations', |
|
| 423 | - 'espresso_registrations_reports', |
|
| 424 | - $event->ID() |
|
| 425 | - ) |
|
| 426 | - ) { |
|
| 427 | - $reports_query_args = array( |
|
| 428 | - 'action' => 'reports', |
|
| 429 | - 'EVT_ID' => $event->ID(), |
|
| 430 | - ); |
|
| 431 | - $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
| 432 | - $action_links[] = '<a href="' |
|
| 433 | - . $reports_link |
|
| 434 | - . '" title="' |
|
| 435 | - . esc_attr__('View Report', 'event_espresso') |
|
| 436 | - . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
| 437 | - . "\n\t"; |
|
| 438 | - } |
|
| 439 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 440 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 441 | - $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
| 442 | - 'see_notifications_for', |
|
| 443 | - null, |
|
| 444 | - array('EVT_ID' => $event->ID()) |
|
| 445 | - ); |
|
| 446 | - } |
|
| 447 | - return $action_links; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - /** |
|
| 453 | - * @param $items |
|
| 454 | - * @return mixed |
|
| 455 | - */ |
|
| 456 | - public function additional_legend_items($items) |
|
| 457 | - { |
|
| 458 | - if ( |
|
| 459 | - EE_Registry::instance()->CAP->current_user_can( |
|
| 460 | - 'ee_read_registrations', |
|
| 461 | - 'espresso_registrations_reports' |
|
| 462 | - ) |
|
| 463 | - ) { |
|
| 464 | - $items['reports'] = array( |
|
| 465 | - 'class' => 'dashicons dashicons-chart-bar', |
|
| 466 | - 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
| 467 | - ); |
|
| 468 | - } |
|
| 469 | - if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 470 | - $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 471 | - if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 472 | - $items['view_related_messages'] = array( |
|
| 473 | - 'class' => $related_for_icon['css_class'], |
|
| 474 | - 'desc' => $related_for_icon['label'], |
|
| 475 | - ); |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - return $items; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - |
|
| 482 | - |
|
| 483 | - /** |
|
| 484 | - * This is the callback method for the duplicate event route |
|
| 485 | - * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
| 486 | - * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
| 487 | - * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
| 488 | - * After duplication the redirect is to the new event edit page. |
|
| 489 | - * |
|
| 490 | - * @return void |
|
| 491 | - * @access protected |
|
| 492 | - * @throws EE_Error If EE_Event is not available with given ID |
|
| 493 | - */ |
|
| 494 | - protected function _duplicate_event() |
|
| 495 | - { |
|
| 496 | - // first make sure the ID for the event is in the request. |
|
| 497 | - // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
| 498 | - if ( ! isset($this->_req_data['EVT_ID'])) { |
|
| 499 | - EE_Error::add_error( |
|
| 500 | - esc_html__( |
|
| 501 | - 'In order to duplicate an event an Event ID is required. None was given.', |
|
| 502 | - 'event_espresso' |
|
| 503 | - ), |
|
| 504 | - __FILE__, |
|
| 505 | - __FUNCTION__, |
|
| 506 | - __LINE__ |
|
| 507 | - ); |
|
| 508 | - $this->_redirect_after_action(false, '', '', array(), true); |
|
| 509 | - return; |
|
| 510 | - } |
|
| 511 | - //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
| 512 | - $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
| 513 | - if ( ! $orig_event instanceof EE_Event) { |
|
| 514 | - throw new EE_Error( |
|
| 515 | - sprintf( |
|
| 516 | - esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
| 517 | - $this->_req_data['EVT_ID'] |
|
| 518 | - ) |
|
| 519 | - ); |
|
| 520 | - } |
|
| 521 | - //k now let's clone the $orig_event before getting relations |
|
| 522 | - $new_event = clone $orig_event; |
|
| 523 | - //original datetimes |
|
| 524 | - $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
| 525 | - //other original relations |
|
| 526 | - $orig_ven = $orig_event->get_many_related('Venue'); |
|
| 527 | - //reset the ID and modify other details to make it clear this is a dupe |
|
| 528 | - $new_event->set('EVT_ID', 0); |
|
| 529 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 530 | - $new_event->set('EVT_name', $new_name); |
|
| 531 | - $new_event->set( |
|
| 532 | - 'EVT_slug', |
|
| 533 | - wp_unique_post_slug( |
|
| 534 | - sanitize_title($orig_event->name()), |
|
| 535 | - 0, |
|
| 536 | - 'publish', |
|
| 537 | - 'espresso_events', |
|
| 538 | - 0 |
|
| 539 | - ) |
|
| 540 | - ); |
|
| 541 | - $new_event->set('status', 'draft'); |
|
| 542 | - //duplicate discussion settings |
|
| 543 | - $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
| 544 | - $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
| 545 | - //save the new event |
|
| 546 | - $new_event->save(); |
|
| 547 | - //venues |
|
| 548 | - foreach ($orig_ven as $ven) { |
|
| 549 | - $new_event->_add_relation_to($ven, 'Venue'); |
|
| 550 | - } |
|
| 551 | - $new_event->save(); |
|
| 552 | - //now we need to get the question group relations and handle that |
|
| 553 | - //first primary question groups |
|
| 554 | - $orig_primary_qgs = $orig_event->get_many_related( |
|
| 555 | - 'Question_Group', |
|
| 556 | - array(array('Event_Question_Group.EQG_primary' => 1)) |
|
| 557 | - ); |
|
| 558 | - if ( ! empty($orig_primary_qgs)) { |
|
| 559 | - foreach ($orig_primary_qgs as $id => $obj) { |
|
| 560 | - if ($obj instanceof EE_Question_Group) { |
|
| 561 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
| 562 | - } |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - //next additional attendee question groups |
|
| 566 | - $orig_additional_qgs = $orig_event->get_many_related( |
|
| 567 | - 'Question_Group', |
|
| 568 | - array(array('Event_Question_Group.EQG_primary' => 0)) |
|
| 569 | - ); |
|
| 570 | - if ( ! empty($orig_additional_qgs)) { |
|
| 571 | - foreach ($orig_additional_qgs as $id => $obj) { |
|
| 572 | - if ($obj instanceof EE_Question_Group) { |
|
| 573 | - $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - } |
|
| 577 | - //now save |
|
| 578 | - $new_event->save(); |
|
| 579 | - //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
| 580 | - $cloned_tickets = array(); |
|
| 581 | - foreach ($orig_datetimes as $orig_dtt) { |
|
| 582 | - if ( ! $orig_dtt instanceof EE_Datetime) { |
|
| 583 | - continue; |
|
| 584 | - } |
|
| 585 | - $new_dtt = clone $orig_dtt; |
|
| 586 | - $orig_tkts = $orig_dtt->tickets(); |
|
| 587 | - //save new dtt then add to event |
|
| 588 | - $new_dtt->set('DTT_ID', 0); |
|
| 589 | - $new_dtt->set('DTT_sold', 0); |
|
| 590 | - $new_dtt->save(); |
|
| 591 | - $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
| 592 | - $new_event->save(); |
|
| 593 | - //now let's get the ticket relations setup. |
|
| 594 | - foreach ((array)$orig_tkts as $orig_tkt) { |
|
| 595 | - //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
| 596 | - if ( ! $orig_tkt instanceof EE_Ticket) { |
|
| 597 | - continue; |
|
| 598 | - } |
|
| 599 | - //is this ticket archived? If it is then let's skip |
|
| 600 | - if ($orig_tkt->get('TKT_deleted')) { |
|
| 601 | - continue; |
|
| 602 | - } |
|
| 603 | - // does this original ticket already exist in the clone_tickets cache? |
|
| 604 | - // If so we'll just use the new ticket from it. |
|
| 605 | - if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
| 606 | - $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
| 607 | - } else { |
|
| 608 | - $new_tkt = clone $orig_tkt; |
|
| 609 | - //get relations on the $orig_tkt that we need to setup. |
|
| 610 | - $orig_prices = $orig_tkt->prices(); |
|
| 611 | - $new_tkt->set('TKT_ID', 0); |
|
| 612 | - $new_tkt->set('TKT_sold', 0); |
|
| 613 | - $new_tkt->set('TKT_reserved', 0); |
|
| 614 | - $new_tkt->save(); //make sure new ticket has ID. |
|
| 615 | - //price relations on new ticket need to be setup. |
|
| 616 | - foreach ($orig_prices as $orig_price) { |
|
| 617 | - $new_price = clone $orig_price; |
|
| 618 | - $new_price->set('PRC_ID', 0); |
|
| 619 | - $new_price->save(); |
|
| 620 | - $new_tkt->_add_relation_to($new_price, 'Price'); |
|
| 621 | - $new_tkt->save(); |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - // k now we can add the new ticket as a relation to the new datetime |
|
| 625 | - // and make sure its added to our cached $cloned_tickets array |
|
| 626 | - // for use with later datetimes that have the same ticket. |
|
| 627 | - $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
| 628 | - $new_dtt->save(); |
|
| 629 | - $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - //clone taxonomy information |
|
| 633 | - $taxonomies_to_clone_with = apply_filters( |
|
| 634 | - 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
| 635 | - array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
| 636 | - ); |
|
| 637 | - //get terms for original event (notice) |
|
| 638 | - $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
| 639 | - //loop through terms and add them to new event. |
|
| 640 | - foreach ($orig_terms as $term) { |
|
| 641 | - wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
| 642 | - } |
|
| 643 | - do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
| 644 | - //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
| 645 | - if ($new_event->ID()) { |
|
| 646 | - $redirect_args = array( |
|
| 647 | - 'post' => $new_event->ID(), |
|
| 648 | - 'action' => 'edit', |
|
| 649 | - ); |
|
| 650 | - EE_Error::add_success( |
|
| 651 | - esc_html__( |
|
| 652 | - 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
| 653 | - 'event_espresso' |
|
| 654 | - ) |
|
| 655 | - ); |
|
| 656 | - } else { |
|
| 657 | - $redirect_args = array( |
|
| 658 | - 'action' => 'default', |
|
| 659 | - ); |
|
| 660 | - EE_Error::add_error( |
|
| 661 | - esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
| 662 | - __FILE__, |
|
| 663 | - __FUNCTION__, |
|
| 664 | - __LINE__ |
|
| 665 | - ); |
|
| 666 | - } |
|
| 667 | - $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
| 668 | - } |
|
| 19 | + /** |
|
| 20 | + * Extend_Events_Admin_Page constructor. |
|
| 21 | + * |
|
| 22 | + * @param bool $routing |
|
| 23 | + */ |
|
| 24 | + public function __construct($routing = true) |
|
| 25 | + { |
|
| 26 | + parent::__construct($routing); |
|
| 27 | + if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
|
| 28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + protected function _extend_page_config() |
|
| 37 | + { |
|
| 38 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 39 | + //is there a evt_id in the request? |
|
| 40 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
| 41 | + ? $this->_req_data['EVT_ID'] |
|
| 42 | + : 0; |
|
| 43 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
| 44 | + //tkt_id? |
|
| 45 | + $tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) |
|
| 46 | + ? $this->_req_data['TKT_ID'] |
|
| 47 | + : 0; |
|
| 48 | + $new_page_routes = array( |
|
| 49 | + 'duplicate_event' => array( |
|
| 50 | + 'func' => '_duplicate_event', |
|
| 51 | + 'capability' => 'ee_edit_event', |
|
| 52 | + 'obj_id' => $evt_id, |
|
| 53 | + 'noheader' => true, |
|
| 54 | + ), |
|
| 55 | + 'ticket_list_table' => array( |
|
| 56 | + 'func' => '_tickets_overview_list_table', |
|
| 57 | + 'capability' => 'ee_read_default_tickets', |
|
| 58 | + ), |
|
| 59 | + 'trash_ticket' => array( |
|
| 60 | + 'func' => '_trash_or_restore_ticket', |
|
| 61 | + 'capability' => 'ee_delete_default_ticket', |
|
| 62 | + 'obj_id' => $tkt_id, |
|
| 63 | + 'noheader' => true, |
|
| 64 | + 'args' => array('trash' => true), |
|
| 65 | + ), |
|
| 66 | + 'trash_tickets' => array( |
|
| 67 | + 'func' => '_trash_or_restore_ticket', |
|
| 68 | + 'capability' => 'ee_delete_default_tickets', |
|
| 69 | + 'noheader' => true, |
|
| 70 | + 'args' => array('trash' => true), |
|
| 71 | + ), |
|
| 72 | + 'restore_ticket' => array( |
|
| 73 | + 'func' => '_trash_or_restore_ticket', |
|
| 74 | + 'capability' => 'ee_delete_default_ticket', |
|
| 75 | + 'obj_id' => $tkt_id, |
|
| 76 | + 'noheader' => true, |
|
| 77 | + ), |
|
| 78 | + 'restore_tickets' => array( |
|
| 79 | + 'func' => '_trash_or_restore_ticket', |
|
| 80 | + 'capability' => 'ee_delete_default_tickets', |
|
| 81 | + 'noheader' => true, |
|
| 82 | + ), |
|
| 83 | + 'delete_ticket' => array( |
|
| 84 | + 'func' => '_delete_ticket', |
|
| 85 | + 'capability' => 'ee_delete_default_ticket', |
|
| 86 | + 'obj_id' => $tkt_id, |
|
| 87 | + 'noheader' => true, |
|
| 88 | + ), |
|
| 89 | + 'delete_tickets' => array( |
|
| 90 | + 'func' => '_delete_ticket', |
|
| 91 | + 'capability' => 'ee_delete_default_tickets', |
|
| 92 | + 'noheader' => true, |
|
| 93 | + ), |
|
| 94 | + 'import_page' => array( |
|
| 95 | + 'func' => '_import_page', |
|
| 96 | + 'capability' => 'import', |
|
| 97 | + ), |
|
| 98 | + 'import' => array( |
|
| 99 | + 'func' => '_import_events', |
|
| 100 | + 'capability' => 'import', |
|
| 101 | + 'noheader' => true, |
|
| 102 | + ), |
|
| 103 | + 'import_events' => array( |
|
| 104 | + 'func' => '_import_events', |
|
| 105 | + 'capability' => 'import', |
|
| 106 | + 'noheader' => true, |
|
| 107 | + ), |
|
| 108 | + 'export_events' => array( |
|
| 109 | + 'func' => '_events_export', |
|
| 110 | + 'capability' => 'export', |
|
| 111 | + 'noheader' => true, |
|
| 112 | + ), |
|
| 113 | + 'export_categories' => array( |
|
| 114 | + 'func' => '_categories_export', |
|
| 115 | + 'capability' => 'export', |
|
| 116 | + 'noheader' => true, |
|
| 117 | + ), |
|
| 118 | + 'sample_export_file' => array( |
|
| 119 | + 'func' => '_sample_export_file', |
|
| 120 | + 'capability' => 'export', |
|
| 121 | + 'noheader' => true, |
|
| 122 | + ), |
|
| 123 | + 'update_template_settings' => array( |
|
| 124 | + 'func' => '_update_template_settings', |
|
| 125 | + 'capability' => 'manage_options', |
|
| 126 | + 'noheader' => true, |
|
| 127 | + ), |
|
| 128 | + ); |
|
| 129 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 130 | + //partial route/config override |
|
| 131 | + $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes; |
|
| 132 | + $this->_page_config['create_new']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 133 | + $this->_page_config['create_new']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 134 | + $this->_page_config['edit']['qtips'][] = 'EE_Event_Editor_Tips'; |
|
| 135 | + $this->_page_config['edit']['metaboxes'][] = '_premium_event_editor_meta_boxes'; |
|
| 136 | + $this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table'; |
|
| 137 | + //add tickets tab but only if there are more than one default ticket! |
|
| 138 | + $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 139 | + array(array('TKT_is_default' => 1)), |
|
| 140 | + 'TKT_ID', |
|
| 141 | + true |
|
| 142 | + ); |
|
| 143 | + if ($tkt_count > 1) { |
|
| 144 | + $new_page_config = array( |
|
| 145 | + 'ticket_list_table' => array( |
|
| 146 | + 'nav' => array( |
|
| 147 | + 'label' => esc_html__('Default Tickets', 'event_espresso'), |
|
| 148 | + 'order' => 60, |
|
| 149 | + ), |
|
| 150 | + 'list_table' => 'Tickets_List_Table', |
|
| 151 | + 'require_nonce' => false, |
|
| 152 | + ), |
|
| 153 | + ); |
|
| 154 | + } |
|
| 155 | + //template settings |
|
| 156 | + $new_page_config['template_settings'] = array( |
|
| 157 | + 'nav' => array( |
|
| 158 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
| 159 | + 'order' => 30, |
|
| 160 | + ), |
|
| 161 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
| 162 | + 'help_tabs' => array( |
|
| 163 | + 'general_settings_templates_help_tab' => array( |
|
| 164 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
| 165 | + 'filename' => 'general_settings_templates', |
|
| 166 | + ), |
|
| 167 | + ), |
|
| 168 | + 'help_tour' => array('Templates_Help_Tour'), |
|
| 169 | + 'require_nonce' => false, |
|
| 170 | + ); |
|
| 171 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 172 | + //add filters and actions |
|
| 173 | + //modifying _views |
|
| 174 | + add_filter( |
|
| 175 | + 'FHEE_event_datetime_metabox_add_additional_date_time_template', |
|
| 176 | + array($this, 'add_additional_datetime_button'), |
|
| 177 | + 10, |
|
| 178 | + 2 |
|
| 179 | + ); |
|
| 180 | + add_filter( |
|
| 181 | + 'FHEE_event_datetime_metabox_clone_button_template', |
|
| 182 | + array($this, 'add_datetime_clone_button'), |
|
| 183 | + 10, |
|
| 184 | + 2 |
|
| 185 | + ); |
|
| 186 | + add_filter( |
|
| 187 | + 'FHEE_event_datetime_metabox_timezones_template', |
|
| 188 | + array($this, 'datetime_timezones_template'), |
|
| 189 | + 10, |
|
| 190 | + 2 |
|
| 191 | + ); |
|
| 192 | + //filters for event list table |
|
| 193 | + add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2); |
|
| 194 | + add_filter( |
|
| 195 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 196 | + array($this, 'extra_list_table_actions'), |
|
| 197 | + 10, |
|
| 198 | + 2 |
|
| 199 | + ); |
|
| 200 | + //legend item |
|
| 201 | + add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items')); |
|
| 202 | + add_action('admin_init', array($this, 'admin_init')); |
|
| 203 | + //heartbeat stuff |
|
| 204 | + add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * admin_init |
|
| 211 | + */ |
|
| 212 | + public function admin_init() |
|
| 213 | + { |
|
| 214 | + EE_Registry::$i18n_js_strings = array_merge( |
|
| 215 | + EE_Registry::$i18n_js_strings, |
|
| 216 | + array( |
|
| 217 | + 'image_confirm' => esc_html__( |
|
| 218 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
| 219 | + 'event_espresso' |
|
| 220 | + ), |
|
| 221 | + 'event_starts_on' => esc_html__('Event Starts on', 'event_espresso'), |
|
| 222 | + 'event_ends_on' => esc_html__('Event Ends on', 'event_espresso'), |
|
| 223 | + 'event_datetime_actions' => esc_html__('Actions', 'event_espresso'), |
|
| 224 | + 'event_clone_dt_msg' => esc_html__('Clone this Event Date and Time', 'event_espresso'), |
|
| 225 | + 'remove_event_dt_msg' => esc_html__('Remove this Event Time', 'event_espresso'), |
|
| 226 | + ) |
|
| 227 | + ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle |
|
| 234 | + * accordingly. |
|
| 235 | + * |
|
| 236 | + * @param array $response The existing heartbeat response array. |
|
| 237 | + * @param array $data The incoming data package. |
|
| 238 | + * @return array possibly appended response. |
|
| 239 | + */ |
|
| 240 | + public function heartbeat_response($response, $data) |
|
| 241 | + { |
|
| 242 | + /** |
|
| 243 | + * check whether count of tickets is approaching the potential |
|
| 244 | + * limits for the server. |
|
| 245 | + */ |
|
| 246 | + if ( ! empty($data['input_count'])) { |
|
| 247 | + $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check( |
|
| 248 | + $data['input_count'] |
|
| 249 | + ); |
|
| 250 | + } |
|
| 251 | + return $response; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + protected function _add_screen_options_ticket_list_table() |
|
| 257 | + { |
|
| 258 | + $this->_per_page_screen_option(); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * @param string $return |
|
| 265 | + * @param int $id |
|
| 266 | + * @param string $new_title |
|
| 267 | + * @param string $new_slug |
|
| 268 | + * @return string |
|
| 269 | + */ |
|
| 270 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
| 271 | + { |
|
| 272 | + $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
|
| 273 | + //make sure this is only when editing |
|
| 274 | + if ( ! empty($id)) { |
|
| 275 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
| 276 | + array('action' => 'duplicate_event', 'EVT_ID' => $id), |
|
| 277 | + $this->_admin_base_url |
|
| 278 | + ); |
|
| 279 | + $title = esc_attr__('Duplicate Event', 'event_espresso'); |
|
| 280 | + $return .= '<a href="' |
|
| 281 | + . $href |
|
| 282 | + . '" title="' |
|
| 283 | + . $title |
|
| 284 | + . '" id="ee-duplicate-event-button" class="button button-small" value="duplicate_event">' |
|
| 285 | + . $title |
|
| 286 | + . '</button>'; |
|
| 287 | + } |
|
| 288 | + return $return; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + public function _set_list_table_views_ticket_list_table() |
|
| 294 | + { |
|
| 295 | + $this->_views = array( |
|
| 296 | + 'all' => array( |
|
| 297 | + 'slug' => 'all', |
|
| 298 | + 'label' => esc_html__('All', 'event_espresso'), |
|
| 299 | + 'count' => 0, |
|
| 300 | + 'bulk_action' => array( |
|
| 301 | + 'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 302 | + ), |
|
| 303 | + ), |
|
| 304 | + 'trashed' => array( |
|
| 305 | + 'slug' => 'trashed', |
|
| 306 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
| 307 | + 'count' => 0, |
|
| 308 | + 'bulk_action' => array( |
|
| 309 | + 'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'), |
|
| 310 | + 'delete_tickets' => esc_html__('Delete Permanently', 'event_espresso'), |
|
| 311 | + ), |
|
| 312 | + ), |
|
| 313 | + ); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + |
|
| 318 | + public function load_scripts_styles_edit() |
|
| 319 | + { |
|
| 320 | + wp_register_script( |
|
| 321 | + 'ee-event-editor-heartbeat', |
|
| 322 | + EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 323 | + array('ee_admin_js', 'heartbeat'), |
|
| 324 | + EVENT_ESPRESSO_VERSION, |
|
| 325 | + true |
|
| 326 | + ); |
|
| 327 | + /** |
|
| 328 | + * load accounting js. |
|
| 329 | + */ |
|
| 330 | + add_filter('FHEE_load_accounting_js', '__return_true'); |
|
| 331 | + //styles |
|
| 332 | + wp_enqueue_style('espresso-ui-theme'); |
|
| 333 | + wp_enqueue_script('event_editor_js'); |
|
| 334 | + wp_enqueue_script('ee-event-editor-heartbeat'); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * @param $template |
|
| 341 | + * @param $template_args |
|
| 342 | + * @return mixed |
|
| 343 | + */ |
|
| 344 | + public function add_additional_datetime_button($template, $template_args) |
|
| 345 | + { |
|
| 346 | + return EEH_Template::display_template( |
|
| 347 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
| 348 | + $template_args, |
|
| 349 | + true |
|
| 350 | + ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * @param $template |
|
| 357 | + * @param $template_args |
|
| 358 | + * @return mixed |
|
| 359 | + */ |
|
| 360 | + public function add_datetime_clone_button($template, $template_args) |
|
| 361 | + { |
|
| 362 | + return EEH_Template::display_template( |
|
| 363 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
| 364 | + $template_args, |
|
| 365 | + true |
|
| 366 | + ); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * @param $template |
|
| 373 | + * @param $template_args |
|
| 374 | + * @return mixed |
|
| 375 | + */ |
|
| 376 | + public function datetime_timezones_template($template, $template_args) |
|
| 377 | + { |
|
| 378 | + return EEH_Template::display_template( |
|
| 379 | + EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
| 380 | + $template_args, |
|
| 381 | + true |
|
| 382 | + ); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + |
|
| 387 | + protected function _set_list_table_views_default() |
|
| 388 | + { |
|
| 389 | + parent::_set_list_table_views_default(); |
|
| 390 | + $new_views = array( |
|
| 391 | + 'today' => array( |
|
| 392 | + 'slug' => 'today', |
|
| 393 | + 'label' => esc_html__('Today', 'event_espresso'), |
|
| 394 | + 'count' => $this->total_events_today(), |
|
| 395 | + 'bulk_action' => array( |
|
| 396 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 397 | + ), |
|
| 398 | + ), |
|
| 399 | + 'month' => array( |
|
| 400 | + 'slug' => 'month', |
|
| 401 | + 'label' => esc_html__('This Month', 'event_espresso'), |
|
| 402 | + 'count' => $this->total_events_this_month(), |
|
| 403 | + 'bulk_action' => array( |
|
| 404 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
| 405 | + ), |
|
| 406 | + ), |
|
| 407 | + ); |
|
| 408 | + $this->_views = array_merge($this->_views, $new_views); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * @param array $action_links |
|
| 415 | + * @param \EE_Event $event |
|
| 416 | + * @return array |
|
| 417 | + */ |
|
| 418 | + public function extra_list_table_actions(array $action_links, \EE_Event $event) |
|
| 419 | + { |
|
| 420 | + if ( |
|
| 421 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 422 | + 'ee_read_registrations', |
|
| 423 | + 'espresso_registrations_reports', |
|
| 424 | + $event->ID() |
|
| 425 | + ) |
|
| 426 | + ) { |
|
| 427 | + $reports_query_args = array( |
|
| 428 | + 'action' => 'reports', |
|
| 429 | + 'EVT_ID' => $event->ID(), |
|
| 430 | + ); |
|
| 431 | + $reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL); |
|
| 432 | + $action_links[] = '<a href="' |
|
| 433 | + . $reports_link |
|
| 434 | + . '" title="' |
|
| 435 | + . esc_attr__('View Report', 'event_espresso') |
|
| 436 | + . '"><div class="dashicons dashicons-chart-bar"></div></a>' |
|
| 437 | + . "\n\t"; |
|
| 438 | + } |
|
| 439 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 440 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 441 | + $action_links[] = EEH_MSG_Template::get_message_action_link( |
|
| 442 | + 'see_notifications_for', |
|
| 443 | + null, |
|
| 444 | + array('EVT_ID' => $event->ID()) |
|
| 445 | + ); |
|
| 446 | + } |
|
| 447 | + return $action_links; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + /** |
|
| 453 | + * @param $items |
|
| 454 | + * @return mixed |
|
| 455 | + */ |
|
| 456 | + public function additional_legend_items($items) |
|
| 457 | + { |
|
| 458 | + if ( |
|
| 459 | + EE_Registry::instance()->CAP->current_user_can( |
|
| 460 | + 'ee_read_registrations', |
|
| 461 | + 'espresso_registrations_reports' |
|
| 462 | + ) |
|
| 463 | + ) { |
|
| 464 | + $items['reports'] = array( |
|
| 465 | + 'class' => 'dashicons dashicons-chart-bar', |
|
| 466 | + 'desc' => esc_html__('Event Reports', 'event_espresso'), |
|
| 467 | + ); |
|
| 468 | + } |
|
| 469 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) { |
|
| 470 | + $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for'); |
|
| 471 | + if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) { |
|
| 472 | + $items['view_related_messages'] = array( |
|
| 473 | + 'class' => $related_for_icon['css_class'], |
|
| 474 | + 'desc' => $related_for_icon['label'], |
|
| 475 | + ); |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + return $items; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + |
|
| 482 | + |
|
| 483 | + /** |
|
| 484 | + * This is the callback method for the duplicate event route |
|
| 485 | + * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them |
|
| 486 | + * into a new event. We add a hook so that any plugins that add extra event details can hook into this |
|
| 487 | + * action. Note that the dupe will have **DUPLICATE** as its title and slug. |
|
| 488 | + * After duplication the redirect is to the new event edit page. |
|
| 489 | + * |
|
| 490 | + * @return void |
|
| 491 | + * @access protected |
|
| 492 | + * @throws EE_Error If EE_Event is not available with given ID |
|
| 493 | + */ |
|
| 494 | + protected function _duplicate_event() |
|
| 495 | + { |
|
| 496 | + // first make sure the ID for the event is in the request. |
|
| 497 | + // If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?) |
|
| 498 | + if ( ! isset($this->_req_data['EVT_ID'])) { |
|
| 499 | + EE_Error::add_error( |
|
| 500 | + esc_html__( |
|
| 501 | + 'In order to duplicate an event an Event ID is required. None was given.', |
|
| 502 | + 'event_espresso' |
|
| 503 | + ), |
|
| 504 | + __FILE__, |
|
| 505 | + __FUNCTION__, |
|
| 506 | + __LINE__ |
|
| 507 | + ); |
|
| 508 | + $this->_redirect_after_action(false, '', '', array(), true); |
|
| 509 | + return; |
|
| 510 | + } |
|
| 511 | + //k we've got EVT_ID so let's use that to get the event we'll duplicate |
|
| 512 | + $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']); |
|
| 513 | + if ( ! $orig_event instanceof EE_Event) { |
|
| 514 | + throw new EE_Error( |
|
| 515 | + sprintf( |
|
| 516 | + esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'), |
|
| 517 | + $this->_req_data['EVT_ID'] |
|
| 518 | + ) |
|
| 519 | + ); |
|
| 520 | + } |
|
| 521 | + //k now let's clone the $orig_event before getting relations |
|
| 522 | + $new_event = clone $orig_event; |
|
| 523 | + //original datetimes |
|
| 524 | + $orig_datetimes = $orig_event->get_many_related('Datetime'); |
|
| 525 | + //other original relations |
|
| 526 | + $orig_ven = $orig_event->get_many_related('Venue'); |
|
| 527 | + //reset the ID and modify other details to make it clear this is a dupe |
|
| 528 | + $new_event->set('EVT_ID', 0); |
|
| 529 | + $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 530 | + $new_event->set('EVT_name', $new_name); |
|
| 531 | + $new_event->set( |
|
| 532 | + 'EVT_slug', |
|
| 533 | + wp_unique_post_slug( |
|
| 534 | + sanitize_title($orig_event->name()), |
|
| 535 | + 0, |
|
| 536 | + 'publish', |
|
| 537 | + 'espresso_events', |
|
| 538 | + 0 |
|
| 539 | + ) |
|
| 540 | + ); |
|
| 541 | + $new_event->set('status', 'draft'); |
|
| 542 | + //duplicate discussion settings |
|
| 543 | + $new_event->set('comment_status', $orig_event->get('comment_status')); |
|
| 544 | + $new_event->set('ping_status', $orig_event->get('ping_status')); |
|
| 545 | + //save the new event |
|
| 546 | + $new_event->save(); |
|
| 547 | + //venues |
|
| 548 | + foreach ($orig_ven as $ven) { |
|
| 549 | + $new_event->_add_relation_to($ven, 'Venue'); |
|
| 550 | + } |
|
| 551 | + $new_event->save(); |
|
| 552 | + //now we need to get the question group relations and handle that |
|
| 553 | + //first primary question groups |
|
| 554 | + $orig_primary_qgs = $orig_event->get_many_related( |
|
| 555 | + 'Question_Group', |
|
| 556 | + array(array('Event_Question_Group.EQG_primary' => 1)) |
|
| 557 | + ); |
|
| 558 | + if ( ! empty($orig_primary_qgs)) { |
|
| 559 | + foreach ($orig_primary_qgs as $id => $obj) { |
|
| 560 | + if ($obj instanceof EE_Question_Group) { |
|
| 561 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1)); |
|
| 562 | + } |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + //next additional attendee question groups |
|
| 566 | + $orig_additional_qgs = $orig_event->get_many_related( |
|
| 567 | + 'Question_Group', |
|
| 568 | + array(array('Event_Question_Group.EQG_primary' => 0)) |
|
| 569 | + ); |
|
| 570 | + if ( ! empty($orig_additional_qgs)) { |
|
| 571 | + foreach ($orig_additional_qgs as $id => $obj) { |
|
| 572 | + if ($obj instanceof EE_Question_Group) { |
|
| 573 | + $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0)); |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + } |
|
| 577 | + //now save |
|
| 578 | + $new_event->save(); |
|
| 579 | + //k now that we have the new event saved we can loop through the datetimes and start adding relations. |
|
| 580 | + $cloned_tickets = array(); |
|
| 581 | + foreach ($orig_datetimes as $orig_dtt) { |
|
| 582 | + if ( ! $orig_dtt instanceof EE_Datetime) { |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 585 | + $new_dtt = clone $orig_dtt; |
|
| 586 | + $orig_tkts = $orig_dtt->tickets(); |
|
| 587 | + //save new dtt then add to event |
|
| 588 | + $new_dtt->set('DTT_ID', 0); |
|
| 589 | + $new_dtt->set('DTT_sold', 0); |
|
| 590 | + $new_dtt->save(); |
|
| 591 | + $new_event->_add_relation_to($new_dtt, 'Datetime'); |
|
| 592 | + $new_event->save(); |
|
| 593 | + //now let's get the ticket relations setup. |
|
| 594 | + foreach ((array)$orig_tkts as $orig_tkt) { |
|
| 595 | + //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
|
| 596 | + if ( ! $orig_tkt instanceof EE_Ticket) { |
|
| 597 | + continue; |
|
| 598 | + } |
|
| 599 | + //is this ticket archived? If it is then let's skip |
|
| 600 | + if ($orig_tkt->get('TKT_deleted')) { |
|
| 601 | + continue; |
|
| 602 | + } |
|
| 603 | + // does this original ticket already exist in the clone_tickets cache? |
|
| 604 | + // If so we'll just use the new ticket from it. |
|
| 605 | + if (isset($cloned_tickets[$orig_tkt->ID()])) { |
|
| 606 | + $new_tkt = $cloned_tickets[$orig_tkt->ID()]; |
|
| 607 | + } else { |
|
| 608 | + $new_tkt = clone $orig_tkt; |
|
| 609 | + //get relations on the $orig_tkt that we need to setup. |
|
| 610 | + $orig_prices = $orig_tkt->prices(); |
|
| 611 | + $new_tkt->set('TKT_ID', 0); |
|
| 612 | + $new_tkt->set('TKT_sold', 0); |
|
| 613 | + $new_tkt->set('TKT_reserved', 0); |
|
| 614 | + $new_tkt->save(); //make sure new ticket has ID. |
|
| 615 | + //price relations on new ticket need to be setup. |
|
| 616 | + foreach ($orig_prices as $orig_price) { |
|
| 617 | + $new_price = clone $orig_price; |
|
| 618 | + $new_price->set('PRC_ID', 0); |
|
| 619 | + $new_price->save(); |
|
| 620 | + $new_tkt->_add_relation_to($new_price, 'Price'); |
|
| 621 | + $new_tkt->save(); |
|
| 622 | + } |
|
| 623 | + } |
|
| 624 | + // k now we can add the new ticket as a relation to the new datetime |
|
| 625 | + // and make sure its added to our cached $cloned_tickets array |
|
| 626 | + // for use with later datetimes that have the same ticket. |
|
| 627 | + $new_dtt->_add_relation_to($new_tkt, 'Ticket'); |
|
| 628 | + $new_dtt->save(); |
|
| 629 | + $cloned_tickets[$orig_tkt->ID()] = $new_tkt; |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | + //clone taxonomy information |
|
| 633 | + $taxonomies_to_clone_with = apply_filters( |
|
| 634 | + 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', |
|
| 635 | + array('espresso_event_categories', 'espresso_event_type', 'post_tag') |
|
| 636 | + ); |
|
| 637 | + //get terms for original event (notice) |
|
| 638 | + $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with); |
|
| 639 | + //loop through terms and add them to new event. |
|
| 640 | + foreach ($orig_terms as $term) { |
|
| 641 | + wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true); |
|
| 642 | + } |
|
| 643 | + do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event); |
|
| 644 | + //now let's redirect to the edit page for this duplicated event if we have a new event id. |
|
| 645 | + if ($new_event->ID()) { |
|
| 646 | + $redirect_args = array( |
|
| 647 | + 'post' => $new_event->ID(), |
|
| 648 | + 'action' => 'edit', |
|
| 649 | + ); |
|
| 650 | + EE_Error::add_success( |
|
| 651 | + esc_html__( |
|
| 652 | + 'Event successfully duplicated. Please review the details below and make any necessary edits', |
|
| 653 | + 'event_espresso' |
|
| 654 | + ) |
|
| 655 | + ); |
|
| 656 | + } else { |
|
| 657 | + $redirect_args = array( |
|
| 658 | + 'action' => 'default', |
|
| 659 | + ); |
|
| 660 | + EE_Error::add_error( |
|
| 661 | + esc_html__('Not able to duplicate event. Something went wrong.', 'event_espresso'), |
|
| 662 | + __FILE__, |
|
| 663 | + __FUNCTION__, |
|
| 664 | + __LINE__ |
|
| 665 | + ); |
|
| 666 | + } |
|
| 667 | + $this->_redirect_after_action(false, '', '', $redirect_args, true); |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | 670 | |
| 671 | - protected function _import_page() |
|
| 672 | - { |
|
| 673 | - $title = esc_html__('Import', 'event_espresso'); |
|
| 674 | - $intro = esc_html__( |
|
| 675 | - 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
| 676 | - 'event_espresso' |
|
| 677 | - ); |
|
| 678 | - $form_url = EVENTS_ADMIN_URL; |
|
| 679 | - $action = 'import_events'; |
|
| 680 | - $type = 'csv'; |
|
| 681 | - $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
| 682 | - $title, $intro, $form_url, $action, $type |
|
| 683 | - ); |
|
| 684 | - $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 685 | - array('action' => 'sample_export_file'), |
|
| 686 | - $this->_admin_base_url |
|
| 687 | - ); |
|
| 688 | - $content = EEH_Template::display_template( |
|
| 689 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 690 | - $this->_template_args, |
|
| 691 | - true |
|
| 692 | - ); |
|
| 693 | - $this->_template_args['admin_page_content'] = $content; |
|
| 694 | - $this->display_admin_page_with_sidebar(); |
|
| 695 | - } |
|
| 696 | - |
|
| 697 | - |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * _import_events |
|
| 701 | - * This handles displaying the screen and running imports for importing events. |
|
| 702 | - * |
|
| 703 | - * @return void |
|
| 704 | - */ |
|
| 705 | - protected function _import_events() |
|
| 706 | - { |
|
| 707 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 708 | - $success = EE_Import::instance()->import(); |
|
| 709 | - $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
| 710 | - } |
|
| 711 | - |
|
| 712 | - |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * _events_export |
|
| 716 | - * Will export all (or just the given event) to a Excel compatible file. |
|
| 717 | - * |
|
| 718 | - * @access protected |
|
| 719 | - * @return void |
|
| 720 | - */ |
|
| 721 | - protected function _events_export() |
|
| 722 | - { |
|
| 723 | - if (isset($this->_req_data['EVT_ID'])) { |
|
| 724 | - $event_ids = $this->_req_data['EVT_ID']; |
|
| 725 | - } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
| 726 | - $event_ids = $this->_req_data['EVT_IDs']; |
|
| 727 | - } else { |
|
| 728 | - $event_ids = null; |
|
| 729 | - } |
|
| 730 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
| 731 | - $new_request_args = array( |
|
| 732 | - 'export' => 'report', |
|
| 733 | - 'action' => 'all_event_data', |
|
| 734 | - 'EVT_ID' => $event_ids, |
|
| 735 | - ); |
|
| 736 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 737 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 738 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 739 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 740 | - $EE_Export->export(); |
|
| 741 | - } |
|
| 742 | - } |
|
| 743 | - |
|
| 744 | - |
|
| 745 | - |
|
| 746 | - /** |
|
| 747 | - * handle category exports() |
|
| 748 | - * |
|
| 749 | - * @return void |
|
| 750 | - */ |
|
| 751 | - protected function _categories_export() |
|
| 752 | - { |
|
| 753 | - //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
| 754 | - $new_request_args = array( |
|
| 755 | - 'export' => 'report', |
|
| 756 | - 'action' => 'categories', |
|
| 757 | - 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
| 758 | - ); |
|
| 759 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 760 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 761 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 762 | - $EE_Export = EE_Export::instance($this->_req_data); |
|
| 763 | - $EE_Export->export(); |
|
| 764 | - } |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - |
|
| 768 | - |
|
| 769 | - /** |
|
| 770 | - * Creates a sample CSV file for importing |
|
| 771 | - */ |
|
| 772 | - protected function _sample_export_file() |
|
| 773 | - { |
|
| 774 | - // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 775 | - EE_Export::instance()->export_sample(); |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - |
|
| 779 | - |
|
| 780 | - /************* Template Settings *************/ |
|
| 781 | - protected function _template_settings() |
|
| 782 | - { |
|
| 783 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
| 784 | - /** |
|
| 785 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 786 | - * from General_Settings_Admin_Page to here. |
|
| 787 | - */ |
|
| 788 | - $this->_template_args = apply_filters( |
|
| 789 | - 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
| 790 | - $this->_template_args |
|
| 791 | - ); |
|
| 792 | - $this->_set_add_edit_form_tags('update_template_settings'); |
|
| 793 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 794 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 795 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 796 | - $this->_template_args, |
|
| 797 | - true |
|
| 798 | - ); |
|
| 799 | - $this->display_admin_page_with_sidebar(); |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - |
|
| 803 | - |
|
| 804 | - protected function _update_template_settings() |
|
| 805 | - { |
|
| 806 | - /** |
|
| 807 | - * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 808 | - * from General_Settings_Admin_Page to here. |
|
| 809 | - */ |
|
| 810 | - EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
| 811 | - 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
| 812 | - EE_Registry::instance()->CFG->template_settings, |
|
| 813 | - $this->_req_data |
|
| 814 | - ); |
|
| 815 | - //update custom post type slugs and detect if we need to flush rewrite rules |
|
| 816 | - $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 817 | - EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
| 818 | - ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
| 819 | - : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
| 820 | - $what = 'Template Settings'; |
|
| 821 | - $success = $this->_update_espresso_configuration( |
|
| 822 | - $what, |
|
| 823 | - EE_Registry::instance()->CFG->template_settings, |
|
| 824 | - __FILE__, |
|
| 825 | - __FUNCTION__, |
|
| 826 | - __LINE__ |
|
| 827 | - ); |
|
| 828 | - if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
| 829 | - update_option('ee_flush_rewrite_rules', true); |
|
| 830 | - } |
|
| 831 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
| 832 | - } |
|
| 833 | - |
|
| 834 | - |
|
| 835 | - |
|
| 836 | - /** |
|
| 837 | - * _premium_event_editor_meta_boxes |
|
| 838 | - * add all metaboxes related to the event_editor |
|
| 839 | - * |
|
| 840 | - * @access protected |
|
| 841 | - * @return void |
|
| 842 | - */ |
|
| 843 | - protected function _premium_event_editor_meta_boxes() |
|
| 844 | - { |
|
| 845 | - $this->verify_cpt_object(); |
|
| 846 | - add_meta_box( |
|
| 847 | - 'espresso_event_editor_event_options', |
|
| 848 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
| 849 | - array($this, 'registration_options_meta_box'), |
|
| 850 | - $this->page_slug, |
|
| 851 | - 'side', |
|
| 852 | - 'core' |
|
| 853 | - ); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - |
|
| 857 | - |
|
| 858 | - /** |
|
| 859 | - * override caf metabox |
|
| 860 | - * |
|
| 861 | - * @return void |
|
| 862 | - */ |
|
| 863 | - public function registration_options_meta_box() |
|
| 864 | - { |
|
| 865 | - $yes_no_values = array( |
|
| 866 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 867 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 868 | - ); |
|
| 869 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 870 | - array( |
|
| 871 | - EEM_Registration::status_id_cancelled, |
|
| 872 | - EEM_Registration::status_id_declined, |
|
| 873 | - EEM_Registration::status_id_incomplete, |
|
| 874 | - EEM_Registration::status_id_wait_list, |
|
| 875 | - ), |
|
| 876 | - true |
|
| 877 | - ); |
|
| 878 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 879 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
| 880 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 881 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 882 | - 'default_reg_status', |
|
| 883 | - $default_reg_status_values, |
|
| 884 | - $this->_cpt_model_obj->default_registration_status() |
|
| 885 | - ); |
|
| 886 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 887 | - 'display_desc', |
|
| 888 | - $yes_no_values, |
|
| 889 | - $this->_cpt_model_obj->display_description() |
|
| 890 | - ); |
|
| 891 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 892 | - 'display_ticket_selector', |
|
| 893 | - $yes_no_values, |
|
| 894 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
| 895 | - '', |
|
| 896 | - '', |
|
| 897 | - false |
|
| 898 | - ); |
|
| 899 | - $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 900 | - 'EVT_default_registration_status', |
|
| 901 | - $default_reg_status_values, |
|
| 902 | - $this->_cpt_model_obj->default_registration_status() |
|
| 903 | - ); |
|
| 904 | - $template_args['additional_registration_options'] = apply_filters( |
|
| 905 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 906 | - '', |
|
| 907 | - $template_args, |
|
| 908 | - $yes_no_values, |
|
| 909 | - $default_reg_status_values |
|
| 910 | - ); |
|
| 911 | - EEH_Template::display_template( |
|
| 912 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 913 | - $template_args |
|
| 914 | - ); |
|
| 915 | - } |
|
| 916 | - |
|
| 917 | - |
|
| 918 | - |
|
| 919 | - /** |
|
| 920 | - * wp_list_table_mods for caf |
|
| 921 | - * ============================ |
|
| 922 | - */ |
|
| 923 | - /** |
|
| 924 | - * hook into list table filters and provide filters for caffeinated list table |
|
| 925 | - * |
|
| 926 | - * @param array $old_filters any existing filters present |
|
| 927 | - * @param array $list_table_obj the list table object |
|
| 928 | - * @return array new filters |
|
| 929 | - */ |
|
| 930 | - public function list_table_filters($old_filters, $list_table_obj) |
|
| 931 | - { |
|
| 932 | - $filters = array(); |
|
| 933 | - //first month/year filters |
|
| 934 | - $filters[] = $this->espresso_event_months_dropdown(); |
|
| 935 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 936 | - //active status dropdown |
|
| 937 | - if ($status !== 'draft') { |
|
| 938 | - $filters[] = $this->active_status_dropdown( |
|
| 939 | - isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
| 940 | - ); |
|
| 941 | - } |
|
| 942 | - //category filter |
|
| 943 | - $filters[] = $this->category_dropdown(); |
|
| 944 | - return array_merge($old_filters, $filters); |
|
| 945 | - } |
|
| 946 | - |
|
| 947 | - |
|
| 948 | - |
|
| 949 | - /** |
|
| 950 | - * espresso_event_months_dropdown |
|
| 951 | - * |
|
| 952 | - * @access public |
|
| 953 | - * @return string dropdown listing month/year selections for events. |
|
| 954 | - */ |
|
| 955 | - public function espresso_event_months_dropdown() |
|
| 956 | - { |
|
| 957 | - // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
| 958 | - // Note we need to include any other filters that are set! |
|
| 959 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 960 | - //categories? |
|
| 961 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 962 | - ? $this->_req_data['EVT_CAT'] |
|
| 963 | - : null; |
|
| 964 | - //active status? |
|
| 965 | - $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
| 966 | - $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 967 | - return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
| 968 | - } |
|
| 969 | - |
|
| 970 | - |
|
| 971 | - |
|
| 972 | - /** |
|
| 973 | - * returns a list of "active" statuses on the event |
|
| 974 | - * |
|
| 975 | - * @param string $current_value whatever the current active status is |
|
| 976 | - * @return string |
|
| 977 | - */ |
|
| 978 | - public function active_status_dropdown($current_value = '') |
|
| 979 | - { |
|
| 980 | - $select_name = 'active_status'; |
|
| 981 | - $values = array( |
|
| 982 | - 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
| 983 | - 'active' => esc_html__('Active', 'event_espresso'), |
|
| 984 | - 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
| 985 | - 'expired' => esc_html__('Expired', 'event_espresso'), |
|
| 986 | - 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
| 987 | - ); |
|
| 988 | - $id = 'id="espresso-active-status-dropdown-filter"'; |
|
| 989 | - $class = 'wide'; |
|
| 990 | - return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - |
|
| 994 | - |
|
| 995 | - /** |
|
| 996 | - * output a dropdown of the categories for the category filter on the event admin list table |
|
| 997 | - * |
|
| 998 | - * @access public |
|
| 999 | - * @return string html |
|
| 1000 | - */ |
|
| 1001 | - public function category_dropdown() |
|
| 1002 | - { |
|
| 1003 | - $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 1004 | - return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - |
|
| 1008 | - |
|
| 1009 | - /** |
|
| 1010 | - * get total number of events today |
|
| 1011 | - * |
|
| 1012 | - * @access public |
|
| 1013 | - * @return int |
|
| 1014 | - */ |
|
| 1015 | - public function total_events_today() |
|
| 1016 | - { |
|
| 1017 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1018 | - 'DTT_EVT_start', |
|
| 1019 | - date('Y-m-d') . ' 00:00:00', |
|
| 1020 | - 'Y-m-d H:i:s', |
|
| 1021 | - 'UTC' |
|
| 1022 | - ); |
|
| 1023 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1024 | - 'DTT_EVT_start', |
|
| 1025 | - date('Y-m-d') . ' 23:59:59', |
|
| 1026 | - 'Y-m-d H:i:s', |
|
| 1027 | - 'UTC' |
|
| 1028 | - ); |
|
| 1029 | - $where = array( |
|
| 1030 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
| 1031 | - ); |
|
| 1032 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 1033 | - return $count; |
|
| 1034 | - } |
|
| 1035 | - |
|
| 1036 | - |
|
| 1037 | - |
|
| 1038 | - /** |
|
| 1039 | - * get total number of events this month |
|
| 1040 | - * |
|
| 1041 | - * @access public |
|
| 1042 | - * @return int |
|
| 1043 | - */ |
|
| 1044 | - public function total_events_this_month() |
|
| 1045 | - { |
|
| 1046 | - //Dates |
|
| 1047 | - $this_year_r = date('Y'); |
|
| 1048 | - $this_month_r = date('m'); |
|
| 1049 | - $days_this_month = date('t'); |
|
| 1050 | - $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1051 | - 'DTT_EVT_start', |
|
| 1052 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1053 | - 'Y-m-d H:i:s', |
|
| 1054 | - 'UTC' |
|
| 1055 | - ); |
|
| 1056 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1057 | - 'DTT_EVT_start', |
|
| 1058 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1059 | - 'Y-m-d H:i:s', |
|
| 1060 | - 'UTC' |
|
| 1061 | - ); |
|
| 1062 | - $where = array( |
|
| 1063 | - 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
| 1064 | - ); |
|
| 1065 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 1066 | - return $count; |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - |
|
| 1070 | - |
|
| 1071 | - /** DEFAULT TICKETS STUFF **/ |
|
| 1072 | - public function _tickets_overview_list_table() |
|
| 1073 | - { |
|
| 1074 | - $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
| 1075 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - |
|
| 1079 | - |
|
| 1080 | - /** |
|
| 1081 | - * @param int $per_page |
|
| 1082 | - * @param bool $count |
|
| 1083 | - * @param bool $trashed |
|
| 1084 | - * @return \EE_Soft_Delete_Base_Class[]|int |
|
| 1085 | - */ |
|
| 1086 | - public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
| 1087 | - { |
|
| 1088 | - $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
| 1089 | - $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
| 1090 | - switch ($orderby) { |
|
| 1091 | - case 'TKT_name' : |
|
| 1092 | - $orderby = array('TKT_name' => $order); |
|
| 1093 | - break; |
|
| 1094 | - case 'TKT_price' : |
|
| 1095 | - $orderby = array('TKT_price' => $order); |
|
| 1096 | - break; |
|
| 1097 | - case 'TKT_uses' : |
|
| 1098 | - $orderby = array('TKT_uses' => $order); |
|
| 1099 | - break; |
|
| 1100 | - case 'TKT_min' : |
|
| 1101 | - $orderby = array('TKT_min' => $order); |
|
| 1102 | - break; |
|
| 1103 | - case 'TKT_max' : |
|
| 1104 | - $orderby = array('TKT_max' => $order); |
|
| 1105 | - break; |
|
| 1106 | - case 'TKT_qty' : |
|
| 1107 | - $orderby = array('TKT_qty' => $order); |
|
| 1108 | - break; |
|
| 1109 | - } |
|
| 1110 | - $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 1111 | - ? $this->_req_data['paged'] |
|
| 1112 | - : 1; |
|
| 1113 | - $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 1114 | - ? $this->_req_data['perpage'] |
|
| 1115 | - : $per_page; |
|
| 1116 | - $_where = array( |
|
| 1117 | - 'TKT_is_default' => 1, |
|
| 1118 | - 'TKT_deleted' => $trashed, |
|
| 1119 | - ); |
|
| 1120 | - $offset = ($current_page - 1) * $per_page; |
|
| 1121 | - $limit = array($offset, $per_page); |
|
| 1122 | - if (isset($this->_req_data['s'])) { |
|
| 1123 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 1124 | - $_where['OR'] = array( |
|
| 1125 | - 'TKT_name' => array('LIKE', $sstr), |
|
| 1126 | - 'TKT_description' => array('LIKE', $sstr), |
|
| 1127 | - ); |
|
| 1128 | - } |
|
| 1129 | - $query_params = array( |
|
| 1130 | - $_where, |
|
| 1131 | - 'order_by' => $orderby, |
|
| 1132 | - 'limit' => $limit, |
|
| 1133 | - 'group_by' => 'TKT_ID', |
|
| 1134 | - ); |
|
| 1135 | - if ($count) { |
|
| 1136 | - return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
| 1137 | - } else { |
|
| 1138 | - return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 1139 | - } |
|
| 1140 | - } |
|
| 1141 | - |
|
| 1142 | - |
|
| 1143 | - |
|
| 1144 | - /** |
|
| 1145 | - * @param bool $trash |
|
| 1146 | - */ |
|
| 1147 | - protected function _trash_or_restore_ticket($trash = false) |
|
| 1148 | - { |
|
| 1149 | - $success = 1; |
|
| 1150 | - $TKT = EEM_Ticket::instance(); |
|
| 1151 | - //checkboxes? |
|
| 1152 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1153 | - //if array has more than one element then success message should be plural |
|
| 1154 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1155 | - //cycle thru the boxes |
|
| 1156 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1157 | - if ($trash) { |
|
| 1158 | - if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1159 | - $success = 0; |
|
| 1160 | - } |
|
| 1161 | - } else { |
|
| 1162 | - if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1163 | - $success = 0; |
|
| 1164 | - } |
|
| 1165 | - } |
|
| 1166 | - } |
|
| 1167 | - } else { |
|
| 1168 | - //grab single id and trash |
|
| 1169 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
| 1170 | - if ($trash) { |
|
| 1171 | - if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1172 | - $success = 0; |
|
| 1173 | - } |
|
| 1174 | - } else { |
|
| 1175 | - if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1176 | - $success = 0; |
|
| 1177 | - } |
|
| 1178 | - } |
|
| 1179 | - } |
|
| 1180 | - $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
| 1181 | - $query_args = array( |
|
| 1182 | - 'action' => 'ticket_list_table', |
|
| 1183 | - 'status' => $trash ? '' : 'trashed', |
|
| 1184 | - ); |
|
| 1185 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
| 1186 | - } |
|
| 1187 | - |
|
| 1188 | - |
|
| 1189 | - |
|
| 1190 | - protected function _delete_ticket() |
|
| 1191 | - { |
|
| 1192 | - $success = 1; |
|
| 1193 | - //checkboxes? |
|
| 1194 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1195 | - //if array has more than one element then success message should be plural |
|
| 1196 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1197 | - //cycle thru the boxes |
|
| 1198 | - while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1199 | - //delete |
|
| 1200 | - if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1201 | - $success = 0; |
|
| 1202 | - } |
|
| 1203 | - } |
|
| 1204 | - } else { |
|
| 1205 | - //grab single id and trash |
|
| 1206 | - $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
| 1207 | - if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1208 | - $success = 0; |
|
| 1209 | - } |
|
| 1210 | - } |
|
| 1211 | - $action_desc = 'deleted'; |
|
| 1212 | - $query_args = array( |
|
| 1213 | - 'action' => 'ticket_list_table', |
|
| 1214 | - 'status' => 'trashed', |
|
| 1215 | - ); |
|
| 1216 | - //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
| 1217 | - if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 1218 | - array(array('TKT_is_default' => 1)), |
|
| 1219 | - 'TKT_ID', |
|
| 1220 | - true |
|
| 1221 | - ) |
|
| 1222 | - ) { |
|
| 1223 | - $query_args = array(); |
|
| 1224 | - } |
|
| 1225 | - $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - |
|
| 1229 | - |
|
| 1230 | - /** |
|
| 1231 | - * @param int $TKT_ID |
|
| 1232 | - * @return bool|int |
|
| 1233 | - */ |
|
| 1234 | - protected function _delete_the_ticket($TKT_ID) |
|
| 1235 | - { |
|
| 1236 | - $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
| 1237 | - $tkt->_remove_relations('Datetime'); |
|
| 1238 | - //delete all related prices first |
|
| 1239 | - $tkt->delete_related_permanently('Price'); |
|
| 1240 | - return $tkt->delete_permanently(); |
|
| 1241 | - } |
|
| 671 | + protected function _import_page() |
|
| 672 | + { |
|
| 673 | + $title = esc_html__('Import', 'event_espresso'); |
|
| 674 | + $intro = esc_html__( |
|
| 675 | + 'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', |
|
| 676 | + 'event_espresso' |
|
| 677 | + ); |
|
| 678 | + $form_url = EVENTS_ADMIN_URL; |
|
| 679 | + $action = 'import_events'; |
|
| 680 | + $type = 'csv'; |
|
| 681 | + $this->_template_args['form'] = EE_Import::instance()->upload_form( |
|
| 682 | + $title, $intro, $form_url, $action, $type |
|
| 683 | + ); |
|
| 684 | + $this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 685 | + array('action' => 'sample_export_file'), |
|
| 686 | + $this->_admin_base_url |
|
| 687 | + ); |
|
| 688 | + $content = EEH_Template::display_template( |
|
| 689 | + EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 690 | + $this->_template_args, |
|
| 691 | + true |
|
| 692 | + ); |
|
| 693 | + $this->_template_args['admin_page_content'] = $content; |
|
| 694 | + $this->display_admin_page_with_sidebar(); |
|
| 695 | + } |
|
| 696 | + |
|
| 697 | + |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * _import_events |
|
| 701 | + * This handles displaying the screen and running imports for importing events. |
|
| 702 | + * |
|
| 703 | + * @return void |
|
| 704 | + */ |
|
| 705 | + protected function _import_events() |
|
| 706 | + { |
|
| 707 | + require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 708 | + $success = EE_Import::instance()->import(); |
|
| 709 | + $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
|
| 710 | + } |
|
| 711 | + |
|
| 712 | + |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * _events_export |
|
| 716 | + * Will export all (or just the given event) to a Excel compatible file. |
|
| 717 | + * |
|
| 718 | + * @access protected |
|
| 719 | + * @return void |
|
| 720 | + */ |
|
| 721 | + protected function _events_export() |
|
| 722 | + { |
|
| 723 | + if (isset($this->_req_data['EVT_ID'])) { |
|
| 724 | + $event_ids = $this->_req_data['EVT_ID']; |
|
| 725 | + } elseif (isset($this->_req_data['EVT_IDs'])) { |
|
| 726 | + $event_ids = $this->_req_data['EVT_IDs']; |
|
| 727 | + } else { |
|
| 728 | + $event_ids = null; |
|
| 729 | + } |
|
| 730 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
| 731 | + $new_request_args = array( |
|
| 732 | + 'export' => 'report', |
|
| 733 | + 'action' => 'all_event_data', |
|
| 734 | + 'EVT_ID' => $event_ids, |
|
| 735 | + ); |
|
| 736 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 737 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 738 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 739 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 740 | + $EE_Export->export(); |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + |
|
| 745 | + |
|
| 746 | + /** |
|
| 747 | + * handle category exports() |
|
| 748 | + * |
|
| 749 | + * @return void |
|
| 750 | + */ |
|
| 751 | + protected function _categories_export() |
|
| 752 | + { |
|
| 753 | + //todo: I don't like doing this but it'll do until we modify EE_Export Class. |
|
| 754 | + $new_request_args = array( |
|
| 755 | + 'export' => 'report', |
|
| 756 | + 'action' => 'categories', |
|
| 757 | + 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
|
| 758 | + ); |
|
| 759 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 760 | + if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 761 | + require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 762 | + $EE_Export = EE_Export::instance($this->_req_data); |
|
| 763 | + $EE_Export->export(); |
|
| 764 | + } |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + |
|
| 768 | + |
|
| 769 | + /** |
|
| 770 | + * Creates a sample CSV file for importing |
|
| 771 | + */ |
|
| 772 | + protected function _sample_export_file() |
|
| 773 | + { |
|
| 774 | + // require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 775 | + EE_Export::instance()->export_sample(); |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + |
|
| 779 | + |
|
| 780 | + /************* Template Settings *************/ |
|
| 781 | + protected function _template_settings() |
|
| 782 | + { |
|
| 783 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
| 784 | + /** |
|
| 785 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 786 | + * from General_Settings_Admin_Page to here. |
|
| 787 | + */ |
|
| 788 | + $this->_template_args = apply_filters( |
|
| 789 | + 'FHEE__General_Settings_Admin_Page__template_settings__template_args', |
|
| 790 | + $this->_template_args |
|
| 791 | + ); |
|
| 792 | + $this->_set_add_edit_form_tags('update_template_settings'); |
|
| 793 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
| 794 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 795 | + EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 796 | + $this->_template_args, |
|
| 797 | + true |
|
| 798 | + ); |
|
| 799 | + $this->display_admin_page_with_sidebar(); |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + |
|
| 803 | + |
|
| 804 | + protected function _update_template_settings() |
|
| 805 | + { |
|
| 806 | + /** |
|
| 807 | + * Note leaving this filter in for backward compatibility this was moved in 4.6.x |
|
| 808 | + * from General_Settings_Admin_Page to here. |
|
| 809 | + */ |
|
| 810 | + EE_Registry::instance()->CFG->template_settings = apply_filters( |
|
| 811 | + 'FHEE__General_Settings_Admin_Page__update_template_settings__data', |
|
| 812 | + EE_Registry::instance()->CFG->template_settings, |
|
| 813 | + $this->_req_data |
|
| 814 | + ); |
|
| 815 | + //update custom post type slugs and detect if we need to flush rewrite rules |
|
| 816 | + $old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug; |
|
| 817 | + EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) |
|
| 818 | + ? EE_Registry::instance()->CFG->core->event_cpt_slug |
|
| 819 | + : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']); |
|
| 820 | + $what = 'Template Settings'; |
|
| 821 | + $success = $this->_update_espresso_configuration( |
|
| 822 | + $what, |
|
| 823 | + EE_Registry::instance()->CFG->template_settings, |
|
| 824 | + __FILE__, |
|
| 825 | + __FUNCTION__, |
|
| 826 | + __LINE__ |
|
| 827 | + ); |
|
| 828 | + if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) { |
|
| 829 | + update_option('ee_flush_rewrite_rules', true); |
|
| 830 | + } |
|
| 831 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings')); |
|
| 832 | + } |
|
| 833 | + |
|
| 834 | + |
|
| 835 | + |
|
| 836 | + /** |
|
| 837 | + * _premium_event_editor_meta_boxes |
|
| 838 | + * add all metaboxes related to the event_editor |
|
| 839 | + * |
|
| 840 | + * @access protected |
|
| 841 | + * @return void |
|
| 842 | + */ |
|
| 843 | + protected function _premium_event_editor_meta_boxes() |
|
| 844 | + { |
|
| 845 | + $this->verify_cpt_object(); |
|
| 846 | + add_meta_box( |
|
| 847 | + 'espresso_event_editor_event_options', |
|
| 848 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
| 849 | + array($this, 'registration_options_meta_box'), |
|
| 850 | + $this->page_slug, |
|
| 851 | + 'side', |
|
| 852 | + 'core' |
|
| 853 | + ); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + |
|
| 857 | + |
|
| 858 | + /** |
|
| 859 | + * override caf metabox |
|
| 860 | + * |
|
| 861 | + * @return void |
|
| 862 | + */ |
|
| 863 | + public function registration_options_meta_box() |
|
| 864 | + { |
|
| 865 | + $yes_no_values = array( |
|
| 866 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
| 867 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
| 868 | + ); |
|
| 869 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
| 870 | + array( |
|
| 871 | + EEM_Registration::status_id_cancelled, |
|
| 872 | + EEM_Registration::status_id_declined, |
|
| 873 | + EEM_Registration::status_id_incomplete, |
|
| 874 | + EEM_Registration::status_id_wait_list, |
|
| 875 | + ), |
|
| 876 | + true |
|
| 877 | + ); |
|
| 878 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
| 879 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
| 880 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
| 881 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 882 | + 'default_reg_status', |
|
| 883 | + $default_reg_status_values, |
|
| 884 | + $this->_cpt_model_obj->default_registration_status() |
|
| 885 | + ); |
|
| 886 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
| 887 | + 'display_desc', |
|
| 888 | + $yes_no_values, |
|
| 889 | + $this->_cpt_model_obj->display_description() |
|
| 890 | + ); |
|
| 891 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
| 892 | + 'display_ticket_selector', |
|
| 893 | + $yes_no_values, |
|
| 894 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
| 895 | + '', |
|
| 896 | + '', |
|
| 897 | + false |
|
| 898 | + ); |
|
| 899 | + $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input( |
|
| 900 | + 'EVT_default_registration_status', |
|
| 901 | + $default_reg_status_values, |
|
| 902 | + $this->_cpt_model_obj->default_registration_status() |
|
| 903 | + ); |
|
| 904 | + $template_args['additional_registration_options'] = apply_filters( |
|
| 905 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
| 906 | + '', |
|
| 907 | + $template_args, |
|
| 908 | + $yes_no_values, |
|
| 909 | + $default_reg_status_values |
|
| 910 | + ); |
|
| 911 | + EEH_Template::display_template( |
|
| 912 | + EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 913 | + $template_args |
|
| 914 | + ); |
|
| 915 | + } |
|
| 916 | + |
|
| 917 | + |
|
| 918 | + |
|
| 919 | + /** |
|
| 920 | + * wp_list_table_mods for caf |
|
| 921 | + * ============================ |
|
| 922 | + */ |
|
| 923 | + /** |
|
| 924 | + * hook into list table filters and provide filters for caffeinated list table |
|
| 925 | + * |
|
| 926 | + * @param array $old_filters any existing filters present |
|
| 927 | + * @param array $list_table_obj the list table object |
|
| 928 | + * @return array new filters |
|
| 929 | + */ |
|
| 930 | + public function list_table_filters($old_filters, $list_table_obj) |
|
| 931 | + { |
|
| 932 | + $filters = array(); |
|
| 933 | + //first month/year filters |
|
| 934 | + $filters[] = $this->espresso_event_months_dropdown(); |
|
| 935 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 936 | + //active status dropdown |
|
| 937 | + if ($status !== 'draft') { |
|
| 938 | + $filters[] = $this->active_status_dropdown( |
|
| 939 | + isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '' |
|
| 940 | + ); |
|
| 941 | + } |
|
| 942 | + //category filter |
|
| 943 | + $filters[] = $this->category_dropdown(); |
|
| 944 | + return array_merge($old_filters, $filters); |
|
| 945 | + } |
|
| 946 | + |
|
| 947 | + |
|
| 948 | + |
|
| 949 | + /** |
|
| 950 | + * espresso_event_months_dropdown |
|
| 951 | + * |
|
| 952 | + * @access public |
|
| 953 | + * @return string dropdown listing month/year selections for events. |
|
| 954 | + */ |
|
| 955 | + public function espresso_event_months_dropdown() |
|
| 956 | + { |
|
| 957 | + // what we need to do is get all PRIMARY datetimes for all events to filter on. |
|
| 958 | + // Note we need to include any other filters that are set! |
|
| 959 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
| 960 | + //categories? |
|
| 961 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
| 962 | + ? $this->_req_data['EVT_CAT'] |
|
| 963 | + : null; |
|
| 964 | + //active status? |
|
| 965 | + $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null; |
|
| 966 | + $cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : ''; |
|
| 967 | + return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status); |
|
| 968 | + } |
|
| 969 | + |
|
| 970 | + |
|
| 971 | + |
|
| 972 | + /** |
|
| 973 | + * returns a list of "active" statuses on the event |
|
| 974 | + * |
|
| 975 | + * @param string $current_value whatever the current active status is |
|
| 976 | + * @return string |
|
| 977 | + */ |
|
| 978 | + public function active_status_dropdown($current_value = '') |
|
| 979 | + { |
|
| 980 | + $select_name = 'active_status'; |
|
| 981 | + $values = array( |
|
| 982 | + 'none' => esc_html__('Show Active/Inactive', 'event_espresso'), |
|
| 983 | + 'active' => esc_html__('Active', 'event_espresso'), |
|
| 984 | + 'upcoming' => esc_html__('Upcoming', 'event_espresso'), |
|
| 985 | + 'expired' => esc_html__('Expired', 'event_espresso'), |
|
| 986 | + 'inactive' => esc_html__('Inactive', 'event_espresso'), |
|
| 987 | + ); |
|
| 988 | + $id = 'id="espresso-active-status-dropdown-filter"'; |
|
| 989 | + $class = 'wide'; |
|
| 990 | + return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class); |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + |
|
| 994 | + |
|
| 995 | + /** |
|
| 996 | + * output a dropdown of the categories for the category filter on the event admin list table |
|
| 997 | + * |
|
| 998 | + * @access public |
|
| 999 | + * @return string html |
|
| 1000 | + */ |
|
| 1001 | + public function category_dropdown() |
|
| 1002 | + { |
|
| 1003 | + $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1; |
|
| 1004 | + return EEH_Form_Fields::generate_event_category_dropdown($cur_cat); |
|
| 1005 | + } |
|
| 1006 | + |
|
| 1007 | + |
|
| 1008 | + |
|
| 1009 | + /** |
|
| 1010 | + * get total number of events today |
|
| 1011 | + * |
|
| 1012 | + * @access public |
|
| 1013 | + * @return int |
|
| 1014 | + */ |
|
| 1015 | + public function total_events_today() |
|
| 1016 | + { |
|
| 1017 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1018 | + 'DTT_EVT_start', |
|
| 1019 | + date('Y-m-d') . ' 00:00:00', |
|
| 1020 | + 'Y-m-d H:i:s', |
|
| 1021 | + 'UTC' |
|
| 1022 | + ); |
|
| 1023 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1024 | + 'DTT_EVT_start', |
|
| 1025 | + date('Y-m-d') . ' 23:59:59', |
|
| 1026 | + 'Y-m-d H:i:s', |
|
| 1027 | + 'UTC' |
|
| 1028 | + ); |
|
| 1029 | + $where = array( |
|
| 1030 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
| 1031 | + ); |
|
| 1032 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 1033 | + return $count; |
|
| 1034 | + } |
|
| 1035 | + |
|
| 1036 | + |
|
| 1037 | + |
|
| 1038 | + /** |
|
| 1039 | + * get total number of events this month |
|
| 1040 | + * |
|
| 1041 | + * @access public |
|
| 1042 | + * @return int |
|
| 1043 | + */ |
|
| 1044 | + public function total_events_this_month() |
|
| 1045 | + { |
|
| 1046 | + //Dates |
|
| 1047 | + $this_year_r = date('Y'); |
|
| 1048 | + $this_month_r = date('m'); |
|
| 1049 | + $days_this_month = date('t'); |
|
| 1050 | + $start = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1051 | + 'DTT_EVT_start', |
|
| 1052 | + $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1053 | + 'Y-m-d H:i:s', |
|
| 1054 | + 'UTC' |
|
| 1055 | + ); |
|
| 1056 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1057 | + 'DTT_EVT_start', |
|
| 1058 | + $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1059 | + 'Y-m-d H:i:s', |
|
| 1060 | + 'UTC' |
|
| 1061 | + ); |
|
| 1062 | + $where = array( |
|
| 1063 | + 'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)), |
|
| 1064 | + ); |
|
| 1065 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
| 1066 | + return $count; |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + |
|
| 1070 | + |
|
| 1071 | + /** DEFAULT TICKETS STUFF **/ |
|
| 1072 | + public function _tickets_overview_list_table() |
|
| 1073 | + { |
|
| 1074 | + $this->_search_btn_label = esc_html__('Tickets', 'event_espresso'); |
|
| 1075 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + |
|
| 1079 | + |
|
| 1080 | + /** |
|
| 1081 | + * @param int $per_page |
|
| 1082 | + * @param bool $count |
|
| 1083 | + * @param bool $trashed |
|
| 1084 | + * @return \EE_Soft_Delete_Base_Class[]|int |
|
| 1085 | + */ |
|
| 1086 | + public function get_default_tickets($per_page = 10, $count = false, $trashed = false) |
|
| 1087 | + { |
|
| 1088 | + $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby']; |
|
| 1089 | + $order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order']; |
|
| 1090 | + switch ($orderby) { |
|
| 1091 | + case 'TKT_name' : |
|
| 1092 | + $orderby = array('TKT_name' => $order); |
|
| 1093 | + break; |
|
| 1094 | + case 'TKT_price' : |
|
| 1095 | + $orderby = array('TKT_price' => $order); |
|
| 1096 | + break; |
|
| 1097 | + case 'TKT_uses' : |
|
| 1098 | + $orderby = array('TKT_uses' => $order); |
|
| 1099 | + break; |
|
| 1100 | + case 'TKT_min' : |
|
| 1101 | + $orderby = array('TKT_min' => $order); |
|
| 1102 | + break; |
|
| 1103 | + case 'TKT_max' : |
|
| 1104 | + $orderby = array('TKT_max' => $order); |
|
| 1105 | + break; |
|
| 1106 | + case 'TKT_qty' : |
|
| 1107 | + $orderby = array('TKT_qty' => $order); |
|
| 1108 | + break; |
|
| 1109 | + } |
|
| 1110 | + $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) |
|
| 1111 | + ? $this->_req_data['paged'] |
|
| 1112 | + : 1; |
|
| 1113 | + $per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) |
|
| 1114 | + ? $this->_req_data['perpage'] |
|
| 1115 | + : $per_page; |
|
| 1116 | + $_where = array( |
|
| 1117 | + 'TKT_is_default' => 1, |
|
| 1118 | + 'TKT_deleted' => $trashed, |
|
| 1119 | + ); |
|
| 1120 | + $offset = ($current_page - 1) * $per_page; |
|
| 1121 | + $limit = array($offset, $per_page); |
|
| 1122 | + if (isset($this->_req_data['s'])) { |
|
| 1123 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 1124 | + $_where['OR'] = array( |
|
| 1125 | + 'TKT_name' => array('LIKE', $sstr), |
|
| 1126 | + 'TKT_description' => array('LIKE', $sstr), |
|
| 1127 | + ); |
|
| 1128 | + } |
|
| 1129 | + $query_params = array( |
|
| 1130 | + $_where, |
|
| 1131 | + 'order_by' => $orderby, |
|
| 1132 | + 'limit' => $limit, |
|
| 1133 | + 'group_by' => 'TKT_ID', |
|
| 1134 | + ); |
|
| 1135 | + if ($count) { |
|
| 1136 | + return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where)); |
|
| 1137 | + } else { |
|
| 1138 | + return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params); |
|
| 1139 | + } |
|
| 1140 | + } |
|
| 1141 | + |
|
| 1142 | + |
|
| 1143 | + |
|
| 1144 | + /** |
|
| 1145 | + * @param bool $trash |
|
| 1146 | + */ |
|
| 1147 | + protected function _trash_or_restore_ticket($trash = false) |
|
| 1148 | + { |
|
| 1149 | + $success = 1; |
|
| 1150 | + $TKT = EEM_Ticket::instance(); |
|
| 1151 | + //checkboxes? |
|
| 1152 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1153 | + //if array has more than one element then success message should be plural |
|
| 1154 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1155 | + //cycle thru the boxes |
|
| 1156 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1157 | + if ($trash) { |
|
| 1158 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1159 | + $success = 0; |
|
| 1160 | + } |
|
| 1161 | + } else { |
|
| 1162 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1163 | + $success = 0; |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1166 | + } |
|
| 1167 | + } else { |
|
| 1168 | + //grab single id and trash |
|
| 1169 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
| 1170 | + if ($trash) { |
|
| 1171 | + if ( ! $TKT->delete_by_ID($TKT_ID)) { |
|
| 1172 | + $success = 0; |
|
| 1173 | + } |
|
| 1174 | + } else { |
|
| 1175 | + if ( ! $TKT->restore_by_ID($TKT_ID)) { |
|
| 1176 | + $success = 0; |
|
| 1177 | + } |
|
| 1178 | + } |
|
| 1179 | + } |
|
| 1180 | + $action_desc = $trash ? 'moved to the trash' : 'restored'; |
|
| 1181 | + $query_args = array( |
|
| 1182 | + 'action' => 'ticket_list_table', |
|
| 1183 | + 'status' => $trash ? '' : 'trashed', |
|
| 1184 | + ); |
|
| 1185 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
| 1186 | + } |
|
| 1187 | + |
|
| 1188 | + |
|
| 1189 | + |
|
| 1190 | + protected function _delete_ticket() |
|
| 1191 | + { |
|
| 1192 | + $success = 1; |
|
| 1193 | + //checkboxes? |
|
| 1194 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 1195 | + //if array has more than one element then success message should be plural |
|
| 1196 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
| 1197 | + //cycle thru the boxes |
|
| 1198 | + while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 1199 | + //delete |
|
| 1200 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1201 | + $success = 0; |
|
| 1202 | + } |
|
| 1203 | + } |
|
| 1204 | + } else { |
|
| 1205 | + //grab single id and trash |
|
| 1206 | + $TKT_ID = absint($this->_req_data['TKT_ID']); |
|
| 1207 | + if ( ! $this->_delete_the_ticket($TKT_ID)) { |
|
| 1208 | + $success = 0; |
|
| 1209 | + } |
|
| 1210 | + } |
|
| 1211 | + $action_desc = 'deleted'; |
|
| 1212 | + $query_args = array( |
|
| 1213 | + 'action' => 'ticket_list_table', |
|
| 1214 | + 'status' => 'trashed', |
|
| 1215 | + ); |
|
| 1216 | + //fail safe. If the default ticket count === 1 then we need to redirect to event overview. |
|
| 1217 | + if (EEM_Ticket::instance()->count_deleted_and_undeleted( |
|
| 1218 | + array(array('TKT_is_default' => 1)), |
|
| 1219 | + 'TKT_ID', |
|
| 1220 | + true |
|
| 1221 | + ) |
|
| 1222 | + ) { |
|
| 1223 | + $query_args = array(); |
|
| 1224 | + } |
|
| 1225 | + $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args); |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + |
|
| 1229 | + |
|
| 1230 | + /** |
|
| 1231 | + * @param int $TKT_ID |
|
| 1232 | + * @return bool|int |
|
| 1233 | + */ |
|
| 1234 | + protected function _delete_the_ticket($TKT_ID) |
|
| 1235 | + { |
|
| 1236 | + $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID); |
|
| 1237 | + $tkt->_remove_relations('Datetime'); |
|
| 1238 | + //delete all related prices first |
|
| 1239 | + $tkt->delete_related_permanently('Price'); |
|
| 1240 | + return $tkt->delete_permanently(); |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | 1243 | |
| 1244 | 1244 | |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | parent::__construct($routing); |
| 27 | 27 | if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) { |
| 28 | - define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/'); |
|
| 29 | - define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/'); |
|
| 30 | - define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/'); |
|
| 28 | + define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/'); |
|
| 29 | + define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/'); |
|
| 30 | + define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/'); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | protected function _extend_page_config() |
| 37 | 37 | { |
| 38 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events'; |
|
| 38 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events'; |
|
| 39 | 39 | //is there a evt_id in the request? |
| 40 | 40 | $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
| 41 | 41 | ? $this->_req_data['EVT_ID'] |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug); |
| 273 | 273 | //make sure this is only when editing |
| 274 | 274 | if ( ! empty($id)) { |
| 275 | - $href = EE_Admin_Page::add_query_args_and_nonce( |
|
| 275 | + $href = EE_Admin_Page::add_query_args_and_nonce( |
|
| 276 | 276 | array('action' => 'duplicate_event', 'EVT_ID' => $id), |
| 277 | 277 | $this->_admin_base_url |
| 278 | 278 | ); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | wp_register_script( |
| 321 | 321 | 'ee-event-editor-heartbeat', |
| 322 | - EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', |
|
| 322 | + EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', |
|
| 323 | 323 | array('ee_admin_js', 'heartbeat'), |
| 324 | 324 | EVENT_ESPRESSO_VERSION, |
| 325 | 325 | true |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | public function add_additional_datetime_button($template, $template_args) |
| 345 | 345 | { |
| 346 | 346 | return EEH_Template::display_template( |
| 347 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', |
|
| 347 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', |
|
| 348 | 348 | $template_args, |
| 349 | 349 | true |
| 350 | 350 | ); |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | public function add_datetime_clone_button($template, $template_args) |
| 361 | 361 | { |
| 362 | 362 | return EEH_Template::display_template( |
| 363 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', |
|
| 363 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', |
|
| 364 | 364 | $template_args, |
| 365 | 365 | true |
| 366 | 366 | ); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | public function datetime_timezones_template($template, $template_args) |
| 377 | 377 | { |
| 378 | 378 | return EEH_Template::display_template( |
| 379 | - EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', |
|
| 379 | + EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', |
|
| 380 | 380 | $template_args, |
| 381 | 381 | true |
| 382 | 382 | ); |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | $orig_ven = $orig_event->get_many_related('Venue'); |
| 527 | 527 | //reset the ID and modify other details to make it clear this is a dupe |
| 528 | 528 | $new_event->set('EVT_ID', 0); |
| 529 | - $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 529 | + $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso'); |
|
| 530 | 530 | $new_event->set('EVT_name', $new_name); |
| 531 | 531 | $new_event->set( |
| 532 | 532 | 'EVT_slug', |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | $new_event->_add_relation_to($new_dtt, 'Datetime'); |
| 592 | 592 | $new_event->save(); |
| 593 | 593 | //now let's get the ticket relations setup. |
| 594 | - foreach ((array)$orig_tkts as $orig_tkt) { |
|
| 594 | + foreach ((array) $orig_tkts as $orig_tkt) { |
|
| 595 | 595 | //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first. |
| 596 | 596 | if ( ! $orig_tkt instanceof EE_Ticket) { |
| 597 | 597 | continue; |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | array('action' => 'sample_export_file'), |
| 686 | 686 | $this->_admin_base_url |
| 687 | 687 | ); |
| 688 | - $content = EEH_Template::display_template( |
|
| 689 | - EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php', |
|
| 688 | + $content = EEH_Template::display_template( |
|
| 689 | + EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', |
|
| 690 | 690 | $this->_template_args, |
| 691 | 691 | true |
| 692 | 692 | ); |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | */ |
| 705 | 705 | protected function _import_events() |
| 706 | 706 | { |
| 707 | - require_once(EE_CLASSES . 'EE_Import.class.php'); |
|
| 707 | + require_once(EE_CLASSES.'EE_Import.class.php'); |
|
| 708 | 708 | $success = EE_Import::instance()->import(); |
| 709 | 709 | $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true); |
| 710 | 710 | } |
@@ -733,9 +733,9 @@ discard block |
||
| 733 | 733 | 'action' => 'all_event_data', |
| 734 | 734 | 'EVT_ID' => $event_ids, |
| 735 | 735 | ); |
| 736 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 737 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 738 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 736 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 737 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 738 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 739 | 739 | $EE_Export = EE_Export::instance($this->_req_data); |
| 740 | 740 | $EE_Export->export(); |
| 741 | 741 | } |
@@ -756,9 +756,9 @@ discard block |
||
| 756 | 756 | 'action' => 'categories', |
| 757 | 757 | 'category_ids' => $this->_req_data['EVT_CAT_ID'], |
| 758 | 758 | ); |
| 759 | - $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 760 | - if (is_readable(EE_CLASSES . 'EE_Export.class.php')) { |
|
| 761 | - require_once(EE_CLASSES . 'EE_Export.class.php'); |
|
| 759 | + $this->_req_data = array_merge($this->_req_data, $new_request_args); |
|
| 760 | + if (is_readable(EE_CLASSES.'EE_Export.class.php')) { |
|
| 761 | + require_once(EE_CLASSES.'EE_Export.class.php'); |
|
| 762 | 762 | $EE_Export = EE_Export::instance($this->_req_data); |
| 763 | 763 | $EE_Export->export(); |
| 764 | 764 | } |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | $this->_set_add_edit_form_tags('update_template_settings'); |
| 793 | 793 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
| 794 | 794 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 795 | - EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', |
|
| 795 | + EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', |
|
| 796 | 796 | $this->_template_args, |
| 797 | 797 | true |
| 798 | 798 | ); |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | $default_reg_status_values |
| 910 | 910 | ); |
| 911 | 911 | EEH_Template::display_template( |
| 912 | - EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
| 912 | + EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php', |
|
| 913 | 913 | $template_args |
| 914 | 914 | ); |
| 915 | 915 | } |
@@ -1016,13 +1016,13 @@ discard block |
||
| 1016 | 1016 | { |
| 1017 | 1017 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
| 1018 | 1018 | 'DTT_EVT_start', |
| 1019 | - date('Y-m-d') . ' 00:00:00', |
|
| 1019 | + date('Y-m-d').' 00:00:00', |
|
| 1020 | 1020 | 'Y-m-d H:i:s', |
| 1021 | 1021 | 'UTC' |
| 1022 | 1022 | ); |
| 1023 | - $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1023 | + $end = EEM_Datetime::instance()->convert_datetime_for_query( |
|
| 1024 | 1024 | 'DTT_EVT_start', |
| 1025 | - date('Y-m-d') . ' 23:59:59', |
|
| 1025 | + date('Y-m-d').' 23:59:59', |
|
| 1026 | 1026 | 'Y-m-d H:i:s', |
| 1027 | 1027 | 'UTC' |
| 1028 | 1028 | ); |
@@ -1049,13 +1049,13 @@ discard block |
||
| 1049 | 1049 | $days_this_month = date('t'); |
| 1050 | 1050 | $start = EEM_Datetime::instance()->convert_datetime_for_query( |
| 1051 | 1051 | 'DTT_EVT_start', |
| 1052 | - $this_year_r . '-' . $this_month_r . '-01 00:00:00', |
|
| 1052 | + $this_year_r.'-'.$this_month_r.'-01 00:00:00', |
|
| 1053 | 1053 | 'Y-m-d H:i:s', |
| 1054 | 1054 | 'UTC' |
| 1055 | 1055 | ); |
| 1056 | 1056 | $end = EEM_Datetime::instance()->convert_datetime_for_query( |
| 1057 | 1057 | 'DTT_EVT_start', |
| 1058 | - $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', |
|
| 1058 | + $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', |
|
| 1059 | 1059 | 'Y-m-d H:i:s', |
| 1060 | 1060 | 'UTC' |
| 1061 | 1061 | ); |
@@ -1120,7 +1120,7 @@ discard block |
||
| 1120 | 1120 | $offset = ($current_page - 1) * $per_page; |
| 1121 | 1121 | $limit = array($offset, $per_page); |
| 1122 | 1122 | if (isset($this->_req_data['s'])) { |
| 1123 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
| 1123 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
| 1124 | 1124 | $_where['OR'] = array( |
| 1125 | 1125 | 'TKT_name' => array('LIKE', $sstr), |
| 1126 | 1126 | 'TKT_description' => array('LIKE', $sstr), |