@@ -105,41 +105,41 @@ discard block |
||
105 | 105 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
106 | 106 | * @return \EEM_Line_Item |
107 | 107 | */ |
108 | - protected function __construct( $timezone ) { |
|
109 | - $this->singular_item = __('Line Item','event_espresso'); |
|
110 | - $this->plural_item = __('Line Items','event_espresso'); |
|
108 | + protected function __construct($timezone) { |
|
109 | + $this->singular_item = __('Line Item', 'event_espresso'); |
|
110 | + $this->plural_item = __('Line Items', 'event_espresso'); |
|
111 | 111 | |
112 | 112 | $this->_tables = array( |
113 | - 'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID') |
|
113 | + 'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID') |
|
114 | 114 | ); |
115 | - $line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) ); |
|
115 | + $line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event')); |
|
116 | 116 | $this->_fields = array( |
117 | 117 | 'Line_Item' => array( |
118 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ), |
|
119 | - 'LIN_code' => new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ), |
|
120 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ), |
|
121 | - 'LIN_name' => new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ), |
|
122 | - 'LIN_desc' => new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ), |
|
123 | - 'LIN_unit_price' => new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ), |
|
124 | - 'LIN_percent' => new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ), |
|
125 | - 'LIN_is_taxable' => new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ), |
|
126 | - 'LIN_order' => new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ), |
|
127 | - 'LIN_total' => new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ), |
|
128 | - 'LIN_quantity' => new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ), |
|
129 | - 'LIN_parent' => new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ), |
|
130 | - 'LIN_type' => new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array( |
|
118 | + 'LIN_ID' => new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")), |
|
119 | + 'LIN_code' => new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE), |
|
120 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'), |
|
121 | + 'LIN_name' => new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''), |
|
122 | + 'LIN_desc' => new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE), |
|
123 | + 'LIN_unit_price' => new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0), |
|
124 | + 'LIN_percent' => new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0), |
|
125 | + 'LIN_is_taxable' => new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE), |
|
126 | + 'LIN_order' => new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1), |
|
127 | + 'LIN_total' => new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0), |
|
128 | + 'LIN_quantity' => new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1), |
|
129 | + 'LIN_parent' => new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL), |
|
130 | + 'LIN_type' => new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array( |
|
131 | 131 | self::type_line_item => __("Line Item", "event_espresso"), |
132 | 132 | self::type_sub_line_item => __("Sub-Item", "event_espresso"), |
133 | 133 | self::type_sub_total => __("Subtotal", "event_espresso"), |
134 | 134 | self::type_tax_sub_total => __("Tax Subtotal", "event_espresso"), |
135 | 135 | self::type_tax => __("Tax", "event_espresso"), |
136 | 136 | self::type_total => __("Total", "event_espresso"), |
137 | - self::type_cancellation => __( 'Cancellation', 'event_espresso' ) |
|
137 | + self::type_cancellation => __('Cancellation', 'event_espresso') |
|
138 | 138 | ) |
139 | 139 | ), |
140 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ), |
|
141 | - 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ), |
|
142 | - 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
140 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for), |
|
141 | + 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for), |
|
142 | + 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
152 | 152 | $this->_caps_slug = 'transactions'; |
153 | - parent::__construct( $timezone ); |
|
153 | + parent::__construct($timezone); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param EE_Transaction|int $transaction |
162 | 162 | * @return EE_Line_Item[] |
163 | 163 | */ |
164 | - public function get_all_of_type_for_transaction( $line_item_type, $transaction ){ |
|
165 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
166 | - return $this->get_all( array( array( |
|
164 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) { |
|
165 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
166 | + return $this->get_all(array(array( |
|
167 | 167 | 'LIN_type' => $line_item_type, |
168 | 168 | 'TXN_ID' => $transaction |
169 | 169 | ))); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | * @param EE_Transaction|int $transaction |
178 | 178 | * @return EE_Line_Item[] |
179 | 179 | */ |
180 | - public function get_all_non_ticket_line_items_for_transaction( $transaction ) { |
|
181 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
182 | - return $this->get_all( array( array( |
|
180 | + public function get_all_non_ticket_line_items_for_transaction($transaction) { |
|
181 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
182 | + return $this->get_all(array(array( |
|
183 | 183 | 'LIN_type' => self::type_line_item, |
184 | 184 | 'TXN_ID' => $transaction, |
185 | 185 | 'OR' => array( |
186 | - 'OBJ_type*notticket' => array( '!=', 'Ticket'), |
|
187 | - 'OBJ_type*null' => array( 'IS_NULL' )) |
|
186 | + 'OBJ_type*notticket' => array('!=', 'Ticket'), |
|
187 | + 'OBJ_type*null' => array('IS_NULL')) |
|
188 | 188 | ))); |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * because if there are spam bots afoot there will be LOTS of line items |
195 | 195 | * @return int count of how many deleted |
196 | 196 | */ |
197 | - public function delete_line_items_with_no_transaction(){ |
|
197 | + public function delete_line_items_with_no_transaction() { |
|
198 | 198 | /** @type WPDB $wpdb */ |
199 | 199 | global $wpdb; |
200 | 200 | $time_to_leave_alone = apply_filters( |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | ); |
203 | 203 | $query = $wpdb->prepare( |
204 | 204 | 'DELETE li |
205 | - FROM ' . $this->table() . ' li |
|
206 | - LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID |
|
205 | + FROM ' . $this->table().' li |
|
206 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
207 | 207 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
208 | 208 | // use GMT time because that's what TXN_timestamps are in |
209 | - gmdate( 'Y-m-d H:i:s', time() - $time_to_leave_alone ) |
|
209 | + gmdate('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
210 | 210 | ); |
211 | - return $wpdb->query( $query ); |
|
211 | + return $wpdb->query($query); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param \EE_Base_Class $object |
222 | 222 | * @return EE_Line_Item[] |
223 | 223 | */ |
224 | - public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){ |
|
225 | - return $this->get_all( array( array( |
|
224 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) { |
|
225 | + return $this->get_all(array(array( |
|
226 | 226 | 'TXN_ID' => $TXN_ID, |
227 | - 'OBJ_type' => str_replace( 'EE_', '', get_class( $object )), |
|
227 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
228 | 228 | 'OBJ_ID' => $object->ID() |
229 | 229 | ))); |
230 | 230 | } |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * @param array $OBJ_IDs |
241 | 241 | * @return EE_Line_Item[] |
242 | 242 | */ |
243 | - public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){ |
|
243 | + public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) { |
|
244 | 244 | $query_params = array( |
245 | 245 | 'OBJ_type' => $OBJ_type, |
246 | 246 | // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
247 | - 'OBJ_ID' => is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs |
|
247 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs |
|
248 | 248 | ); |
249 | - if ( $TXN_ID ) { |
|
249 | + if ($TXN_ID) { |
|
250 | 250 | $query_params['TXN_ID'] = $TXN_ID; |
251 | 251 | } |
252 | - return $this->get_all( array( $query_params )); |
|
252 | + return $this->get_all(array($query_params)); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return EE_Line_Item[] |
262 | 262 | */ |
263 | - public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) { |
|
264 | - return $this->get_all( array( |
|
263 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) { |
|
264 | + return $this->get_all(array( |
|
265 | 265 | array( |
266 | 266 | 'TXN_ID' => $transaction->ID(), |
267 | 267 | 'OBJ_type' => 'Ticket', |
268 | 268 | ) |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * @param int $TKT_ID |
279 | 279 | * @return \EE_Line_Item |
280 | 280 | */ |
281 | - public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) { |
|
282 | - return $this->get_one( array( |
|
281 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) { |
|
282 | + return $this->get_one(array( |
|
283 | 283 | array( |
284 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ), |
|
284 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
285 | 285 | 'OBJ_ID' => $TKT_ID, |
286 | 286 | 'OBJ_type' => 'Ticket', |
287 | 287 | ) |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param EE_Promotion $promotion |
301 | 301 | * @return EE_Line_Item |
302 | 302 | */ |
303 | - public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) { |
|
304 | - return $this->get_one( array( |
|
303 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) { |
|
304 | + return $this->get_one(array( |
|
305 | 305 | array( |
306 | 306 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
307 | 307 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Line_Item $parent_line_item |
323 | 323 | * @return EE_Line_Item[] |
324 | 324 | */ |
325 | - public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) { |
|
326 | - return $this->get_all( array( |
|
325 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) { |
|
326 | + return $this->get_all(array( |
|
327 | 327 | array( |
328 | 328 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
329 | 329 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param EE_Registration $registration |
341 | 341 | * @return EE_Line_ITem |
342 | 342 | */ |
343 | - public function get_line_item_for_registration( EE_Registration $registration ) { |
|
344 | - return $this->get_one( $this->line_item_for_registration_query_params( $registration )); |
|
343 | + public function get_line_item_for_registration(EE_Registration $registration) { |
|
344 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @param array $original_query_params any extra query params you'd like to be merged with |
351 | 351 | * @return array like EEM_Base::get_all()'s $query_params |
352 | 352 | */ |
353 | - public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) { |
|
354 | - return array_replace_recursive( $original_query_params, array( |
|
353 | + public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) { |
|
354 | + return array_replace_recursive($original_query_params, array( |
|
355 | 355 | array( |
356 | 356 | 'OBJ_ID' => $registration->ticket_ID(), |
357 | 357 | 'OBJ_type' => 'Ticket', |
358 | 358 | 'TXN_ID' => $registration->transaction_ID() |
359 | 359 | ) |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 |
@@ -2,7 +2,7 @@ |
||
2 | 2 | namespace EventEspresso\core\services\commands; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function instance() { |
123 | 123 | // check if class object is instantiated, and instantiated properly |
124 | - if ( ! self::$_instance instanceof EE_Config ) { |
|
124 | + if ( ! self::$_instance instanceof EE_Config) { |
|
125 | 125 | self::$_instance = new self(); |
126 | 126 | } |
127 | 127 | return self::$_instance; |
@@ -141,20 +141,20 @@ discard block |
||
141 | 141 | * site was put into maintenance mode) |
142 | 142 | * @return EE_Config |
143 | 143 | */ |
144 | - public static function reset( $hard_reset = false, $reinstantiate = true ) { |
|
145 | - if ( $hard_reset ) { |
|
144 | + public static function reset($hard_reset = false, $reinstantiate = true) { |
|
145 | + if ($hard_reset) { |
|
146 | 146 | self::$_instance->_addon_option_names = array(); |
147 | 147 | self::$_instance->_initialize_config(); |
148 | 148 | self::$_instance->update_espresso_config(); |
149 | 149 | } |
150 | - if ( self::$_instance instanceof EE_Config ) { |
|
150 | + if (self::$_instance instanceof EE_Config) { |
|
151 | 151 | self::$_instance->update_addon_option_names(); |
152 | 152 | } |
153 | 153 | self::$_instance = null; |
154 | 154 | //we don't need to reset the static properties imo because those should |
155 | 155 | //only change when a module is added or removed. Currently we don't |
156 | 156 | //support removing a module during a request when it previously existed |
157 | - if ( $reinstantiate ) { |
|
157 | + if ($reinstantiate) { |
|
158 | 158 | return self::instance(); |
159 | 159 | } else { |
160 | 160 | return null; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return \EE_Config |
171 | 171 | */ |
172 | 172 | private function __construct() { |
173 | - do_action( 'AHEE__EE_Config__construct__begin', $this ); |
|
173 | + do_action('AHEE__EE_Config__construct__begin', $this); |
|
174 | 174 | // setup empty config classes |
175 | 175 | $this->_initialize_config(); |
176 | 176 | // load existing EE site settings |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | // register shortcodes and modules |
181 | 181 | add_action( |
182 | 182 | 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
183 | - array( $this, 'register_shortcodes_and_modules' ), |
|
183 | + array($this, 'register_shortcodes_and_modules'), |
|
184 | 184 | 999 |
185 | 185 | ); |
186 | 186 | // initialize shortcodes and modules |
187 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'initialize_shortcodes_and_modules' ) ); |
|
187 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules')); |
|
188 | 188 | // register widgets |
189 | - add_action( 'widgets_init', array( $this, 'widgets_init' ), 10 ); |
|
189 | + add_action('widgets_init', array($this, 'widgets_init'), 10); |
|
190 | 190 | // shutdown |
191 | - add_action( 'shutdown', array( $this, 'shutdown' ), 10 ); |
|
191 | + add_action('shutdown', array($this, 'shutdown'), 10); |
|
192 | 192 | // construct__end hook |
193 | - do_action( 'AHEE__EE_Config__construct__end', $this ); |
|
193 | + do_action('AHEE__EE_Config__construct__end', $this); |
|
194 | 194 | // hardcoded hack |
195 | 195 | $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014'; |
196 | 196 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @return string current theme set. |
204 | 204 | */ |
205 | 205 | public static function get_current_theme() { |
206 | - return isset( self::$_instance->template_settings->current_espresso_theme ) |
|
206 | + return isset(self::$_instance->template_settings->current_espresso_theme) |
|
207 | 207 | ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014'; |
208 | 208 | } |
209 | 209 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | private function _initialize_config() { |
219 | 219 | EE_Config::trim_log(); |
220 | 220 | //set defaults |
221 | - $this->_addon_option_names = get_option( EE_Config::ADDON_OPTION_NAMES, array() ); |
|
221 | + $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array()); |
|
222 | 222 | $this->addons = new stdClass(); |
223 | 223 | // set _module_route_map |
224 | 224 | EE_Config::$_module_route_map = array(); |
@@ -238,9 +238,9 @@ discard block |
||
238 | 238 | */ |
239 | 239 | private function _load_core_config() { |
240 | 240 | // load_core_config__start hook |
241 | - do_action( 'AHEE__EE_Config___load_core_config__start', $this ); |
|
241 | + do_action('AHEE__EE_Config___load_core_config__start', $this); |
|
242 | 242 | $espresso_config = $this->get_espresso_config(); |
243 | - foreach ( $espresso_config as $config => $settings ) { |
|
243 | + foreach ($espresso_config as $config => $settings) { |
|
244 | 244 | // load_core_config__start hook |
245 | 245 | $settings = apply_filters( |
246 | 246 | 'FHEE__EE_Config___load_core_config__config_settings', |
@@ -248,22 +248,22 @@ discard block |
||
248 | 248 | $config, |
249 | 249 | $this |
250 | 250 | ); |
251 | - if ( is_object( $settings ) && property_exists( $this, $config ) ) { |
|
252 | - $this->{$config} = apply_filters( 'FHEE__EE_Config___load_core_config__' . $config, $settings ); |
|
251 | + if (is_object($settings) && property_exists($this, $config)) { |
|
252 | + $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings); |
|
253 | 253 | //call configs populate method to ensure any defaults are set for empty values. |
254 | - if ( method_exists( $settings, 'populate' ) ) { |
|
254 | + if (method_exists($settings, 'populate')) { |
|
255 | 255 | $this->{$config}->populate(); |
256 | 256 | } |
257 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
257 | + if (method_exists($settings, 'do_hooks')) { |
|
258 | 258 | $this->{$config}->do_hooks(); |
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | - if ( apply_filters( 'FHEE__EE_Config___load_core_config__update_espresso_config', false ) ) { |
|
262 | + if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) { |
|
263 | 263 | $this->update_espresso_config(); |
264 | 264 | } |
265 | 265 | // load_core_config__end hook |
266 | - do_action( 'AHEE__EE_Config___load_core_config__end', $this ); |
|
266 | + do_action('AHEE__EE_Config___load_core_config__end', $this); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | |
@@ -278,23 +278,23 @@ discard block |
||
278 | 278 | $this->core = $this->core instanceof EE_Core_Config |
279 | 279 | ? $this->core |
280 | 280 | : new EE_Core_Config(); |
281 | - $this->core = apply_filters( 'FHEE__EE_Config___initialize_config__core', $this->core ); |
|
281 | + $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core); |
|
282 | 282 | $this->organization = $this->organization instanceof EE_Organization_Config |
283 | 283 | ? $this->organization |
284 | 284 | : new EE_Organization_Config(); |
285 | - $this->organization = apply_filters( 'FHEE__EE_Config___initialize_config__organization', $this->organization ); |
|
285 | + $this->organization = apply_filters('FHEE__EE_Config___initialize_config__organization', $this->organization); |
|
286 | 286 | $this->currency = $this->currency instanceof EE_Currency_Config |
287 | 287 | ? $this->currency |
288 | 288 | : new EE_Currency_Config(); |
289 | - $this->currency = apply_filters( 'FHEE__EE_Config___initialize_config__currency', $this->currency ); |
|
289 | + $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency); |
|
290 | 290 | $this->registration = $this->registration instanceof EE_Registration_Config |
291 | 291 | ? $this->registration |
292 | 292 | : new EE_Registration_Config(); |
293 | - $this->registration = apply_filters( 'FHEE__EE_Config___initialize_config__registration', $this->registration ); |
|
293 | + $this->registration = apply_filters('FHEE__EE_Config___initialize_config__registration', $this->registration); |
|
294 | 294 | $this->admin = $this->admin instanceof EE_Admin_Config |
295 | 295 | ? $this->admin |
296 | 296 | : new EE_Admin_Config(); |
297 | - $this->admin = apply_filters( 'FHEE__EE_Config___initialize_config__admin', $this->admin ); |
|
297 | + $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin); |
|
298 | 298 | $this->template_settings = $this->template_settings instanceof EE_Template_Config |
299 | 299 | ? $this->template_settings |
300 | 300 | : new EE_Template_Config(); |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | $this->map_settings = $this->map_settings instanceof EE_Map_Config |
306 | 306 | ? $this->map_settings |
307 | 307 | : new EE_Map_Config(); |
308 | - $this->map_settings = apply_filters( 'FHEE__EE_Config___initialize_config__map_settings', $this->map_settings ); |
|
308 | + $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings', $this->map_settings); |
|
309 | 309 | $this->environment = $this->environment instanceof EE_Environment_Config |
310 | 310 | ? $this->environment |
311 | 311 | : new EE_Environment_Config(); |
312 | - $this->environment = apply_filters( 'FHEE__EE_Config___initialize_config__environment', $this->environment ); |
|
312 | + $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment', $this->environment); |
|
313 | 313 | $this->gateway = $this->gateway instanceof EE_Gateway_Config |
314 | 314 | ? $this->gateway |
315 | 315 | : new EE_Gateway_Config(); |
316 | - $this->gateway = apply_filters( 'FHEE__EE_Config___initialize_config__gateway', $this->gateway ); |
|
316 | + $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | // grab espresso configuration |
329 | 329 | return apply_filters( |
330 | 330 | 'FHEE__EE_Config__get_espresso_config__CFG', |
331 | - get_option( EE_Config::OPTION_NAME, array() ) |
|
331 | + get_option(EE_Config::OPTION_NAME, array()) |
|
332 | 332 | ); |
333 | 333 | } |
334 | 334 | |
@@ -342,12 +342,12 @@ discard block |
||
342 | 342 | * @param $old_value |
343 | 343 | * @param $value |
344 | 344 | */ |
345 | - public function double_check_config_comparison( $option = '', $old_value, $value ) { |
|
345 | + public function double_check_config_comparison($option = '', $old_value, $value) { |
|
346 | 346 | // make sure we're checking the ee config |
347 | - if ( $option === EE_Config::OPTION_NAME ) { |
|
347 | + if ($option === EE_Config::OPTION_NAME) { |
|
348 | 348 | // run a loose comparison of the old value against the new value for type and properties, |
349 | 349 | // but NOT exact instance like WP update_option does (ie: NOT type safe comparison) |
350 | - if ( $value != $old_value ) { |
|
350 | + if ($value != $old_value) { |
|
351 | 351 | // if they are NOT the same, then remove the hook, |
352 | 352 | // which means the subsequent update results will be based solely on the update query results |
353 | 353 | // the reason we do this is because, as stated above, |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | // the string it sees in the db looks the same as the new one it has been passed!!! |
363 | 363 | // This results in the query returning an "affected rows" value of ZERO, |
364 | 364 | // which gets returned immediately by WP update_option and looks like an error. |
365 | - remove_action( 'update_option', array( $this, 'check_config_updated' ) ); |
|
365 | + remove_action('update_option', array($this, 'check_config_updated')); |
|
366 | 366 | } |
367 | 367 | } |
368 | 368 | } |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | */ |
378 | 378 | protected function _reset_espresso_addon_config() { |
379 | 379 | $this->_addon_option_names = array(); |
380 | - foreach ( $this->addons as $addon_name => $addon_config_obj ) { |
|
381 | - $addon_config_obj = maybe_unserialize( $addon_config_obj ); |
|
382 | - $config_class = get_class( $addon_config_obj ); |
|
383 | - if ( $addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class ) { |
|
384 | - $this->update_config( 'addons', $addon_name, $addon_config_obj, false ); |
|
380 | + foreach ($this->addons as $addon_name => $addon_config_obj) { |
|
381 | + $addon_config_obj = maybe_unserialize($addon_config_obj); |
|
382 | + $config_class = get_class($addon_config_obj); |
|
383 | + if ($addon_config_obj instanceof $config_class && ! $addon_config_obj instanceof __PHP_Incomplete_Class) { |
|
384 | + $this->update_config('addons', $addon_name, $addon_config_obj, false); |
|
385 | 385 | } |
386 | 386 | $this->addons->{$addon_name} = null; |
387 | 387 | } |
@@ -397,22 +397,22 @@ discard block |
||
397 | 397 | * @param bool $add_error |
398 | 398 | * @return bool |
399 | 399 | */ |
400 | - public function update_espresso_config( $add_success = false, $add_error = true ) { |
|
400 | + public function update_espresso_config($add_success = false, $add_error = true) { |
|
401 | 401 | // don't allow config updates during WP heartbeats |
402 | - if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) { |
|
402 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
403 | 403 | return false; |
404 | 404 | } |
405 | 405 | // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197 |
406 | 406 | //$clone = clone( self::$_instance ); |
407 | 407 | //self::$_instance = NULL; |
408 | - do_action( 'AHEE__EE_Config__update_espresso_config__begin', $this ); |
|
408 | + do_action('AHEE__EE_Config__update_espresso_config__begin', $this); |
|
409 | 409 | $this->_reset_espresso_addon_config(); |
410 | 410 | // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional |
411 | 411 | // but BEFORE the actual update occurs |
412 | - add_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1, 3 ); |
|
412 | + add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3); |
|
413 | 413 | // now update "ee_config" |
414 | - $saved = update_option( EE_Config::OPTION_NAME, $this ); |
|
415 | - EE_Config::log( EE_Config::OPTION_NAME ); |
|
414 | + $saved = update_option(EE_Config::OPTION_NAME, $this); |
|
415 | + EE_Config::log(EE_Config::OPTION_NAME); |
|
416 | 416 | // if not saved... check if the hook we just added still exists; |
417 | 417 | // if it does, it means one of two things: |
418 | 418 | // that update_option bailed at the ( $value === $old_value ) conditional, |
@@ -423,17 +423,17 @@ discard block |
||
423 | 423 | // but just means no update occurred, so don't display an error to the user. |
424 | 424 | // BUT... if update_option returns FALSE, AND the hook is missing, |
425 | 425 | // then it means that something truly went wrong |
426 | - $saved = ! $saved ? has_action( 'update_option', array( $this, 'double_check_config_comparison' ) ) : $saved; |
|
426 | + $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved; |
|
427 | 427 | // remove our action since we don't want it in the system anymore |
428 | - remove_action( 'update_option', array( $this, 'double_check_config_comparison' ), 1 ); |
|
429 | - do_action( 'AHEE__EE_Config__update_espresso_config__end', $this, $saved ); |
|
428 | + remove_action('update_option', array($this, 'double_check_config_comparison'), 1); |
|
429 | + do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved); |
|
430 | 430 | //self::$_instance = $clone; |
431 | 431 | //unset( $clone ); |
432 | 432 | // if config remains the same or was updated successfully |
433 | - if ( $saved ) { |
|
434 | - if ( $add_success ) { |
|
433 | + if ($saved) { |
|
434 | + if ($add_success) { |
|
435 | 435 | EE_Error::add_success( |
436 | - __( 'The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso' ), |
|
436 | + __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'), |
|
437 | 437 | __FILE__, |
438 | 438 | __FUNCTION__, |
439 | 439 | __LINE__ |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | } |
442 | 442 | return true; |
443 | 443 | } else { |
444 | - if ( $add_error ) { |
|
444 | + if ($add_error) { |
|
445 | 445 | EE_Error::add_error( |
446 | - __( 'The Event Espresso Configuration Settings were not updated.', 'event_espresso' ), |
|
446 | + __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'), |
|
447 | 447 | __FILE__, |
448 | 448 | __FUNCTION__, |
449 | 449 | __LINE__ |
@@ -472,16 +472,16 @@ discard block |
||
472 | 472 | $name = '', |
473 | 473 | $config_class = '', |
474 | 474 | $config_obj = null, |
475 | - $tests_to_run = array( 1, 2, 3, 4, 5, 6, 7, 8 ), |
|
475 | + $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8), |
|
476 | 476 | $display_errors = true |
477 | 477 | ) { |
478 | 478 | try { |
479 | - foreach ( $tests_to_run as $test ) { |
|
480 | - switch ( $test ) { |
|
479 | + foreach ($tests_to_run as $test) { |
|
480 | + switch ($test) { |
|
481 | 481 | // TEST #1 : check that section was set |
482 | 482 | case 1 : |
483 | - if ( empty( $section ) ) { |
|
484 | - if ( $display_errors ) { |
|
483 | + if (empty($section)) { |
|
484 | + if ($display_errors) { |
|
485 | 485 | throw new EE_Error( |
486 | 486 | sprintf( |
487 | 487 | __( |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | break; |
498 | 498 | // TEST #2 : check that settings section exists |
499 | 499 | case 2 : |
500 | - if ( ! isset( $this->{$section} ) ) { |
|
501 | - if ( $display_errors ) { |
|
500 | + if ( ! isset($this->{$section} )) { |
|
501 | + if ($display_errors) { |
|
502 | 502 | throw new EE_Error( |
503 | 503 | sprintf( |
504 | - __( 'The "%s" configuration section does not exist.', 'event_espresso' ), |
|
504 | + __('The "%s" configuration section does not exist.', 'event_espresso'), |
|
505 | 505 | $section |
506 | 506 | ) |
507 | 507 | ); |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | // TEST #3 : check that section is the proper format |
513 | 513 | case 3 : |
514 | 514 | if ( |
515 | - ! ( $this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass ) |
|
515 | + ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass) |
|
516 | 516 | ) { |
517 | - if ( $display_errors ) { |
|
517 | + if ($display_errors) { |
|
518 | 518 | throw new EE_Error( |
519 | 519 | sprintf( |
520 | 520 | __( |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | break; |
531 | 531 | // TEST #4 : check that config section name has been set |
532 | 532 | case 4 : |
533 | - if ( empty( $name ) ) { |
|
534 | - if ( $display_errors ) { |
|
533 | + if (empty($name)) { |
|
534 | + if ($display_errors) { |
|
535 | 535 | throw new EE_Error( |
536 | 536 | __( |
537 | 537 | 'No name has been provided for the specific configuration section.', |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | break; |
545 | 545 | // TEST #5 : check that a config class name has been set |
546 | 546 | case 5 : |
547 | - if ( empty( $config_class ) ) { |
|
548 | - if ( $display_errors ) { |
|
547 | + if (empty($config_class)) { |
|
548 | + if ($display_errors) { |
|
549 | 549 | throw new EE_Error( |
550 | 550 | __( |
551 | 551 | 'No class name has been provided for the specific configuration section.', |
@@ -558,8 +558,8 @@ discard block |
||
558 | 558 | break; |
559 | 559 | // TEST #6 : verify config class is accessible |
560 | 560 | case 6 : |
561 | - if ( ! class_exists( $config_class ) ) { |
|
562 | - if ( $display_errors ) { |
|
561 | + if ( ! class_exists($config_class)) { |
|
562 | + if ($display_errors) { |
|
563 | 563 | throw new EE_Error( |
564 | 564 | sprintf( |
565 | 565 | __( |
@@ -575,11 +575,11 @@ discard block |
||
575 | 575 | break; |
576 | 576 | // TEST #7 : check that config has even been set |
577 | 577 | case 7 : |
578 | - if ( ! isset( $this->{$section}->{$name} ) ) { |
|
579 | - if ( $display_errors ) { |
|
578 | + if ( ! isset($this->{$section}->{$name} )) { |
|
579 | + if ($display_errors) { |
|
580 | 580 | throw new EE_Error( |
581 | 581 | sprintf( |
582 | - __( 'No configuration has been set for "%1$s->%2$s".', 'event_espresso' ), |
|
582 | + __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'), |
|
583 | 583 | $section, |
584 | 584 | $name |
585 | 585 | ) |
@@ -588,13 +588,13 @@ discard block |
||
588 | 588 | return false; |
589 | 589 | } else { |
590 | 590 | // and make sure it's not serialized |
591 | - $this->{$section}->{$name} = maybe_unserialize( $this->{$section}->{$name} ); |
|
591 | + $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name} ); |
|
592 | 592 | } |
593 | 593 | break; |
594 | 594 | // TEST #8 : check that config is the requested type |
595 | 595 | case 8 : |
596 | - if ( ! $this->{$section}->{$name} instanceof $config_class ) { |
|
597 | - if ( $display_errors ) { |
|
596 | + if ( ! $this->{$section}->{$name} instanceof $config_class) { |
|
597 | + if ($display_errors) { |
|
598 | 598 | throw new EE_Error( |
599 | 599 | sprintf( |
600 | 600 | __( |
@@ -612,12 +612,12 @@ discard block |
||
612 | 612 | break; |
613 | 613 | // TEST #9 : verify config object |
614 | 614 | case 9 : |
615 | - if ( ! $config_obj instanceof EE_Config_Base ) { |
|
616 | - if ( $display_errors ) { |
|
615 | + if ( ! $config_obj instanceof EE_Config_Base) { |
|
616 | + if ($display_errors) { |
|
617 | 617 | throw new EE_Error( |
618 | 618 | sprintf( |
619 | - __( 'The "%s" class is not an instance of EE_Config_Base.', 'event_espresso' ), |
|
620 | - print_r( $config_obj, true ) |
|
619 | + __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'), |
|
620 | + print_r($config_obj, true) |
|
621 | 621 | ) |
622 | 622 | ); |
623 | 623 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | break; |
627 | 627 | } |
628 | 628 | } |
629 | - } catch ( EE_Error $e ) { |
|
629 | + } catch (EE_Error $e) { |
|
630 | 630 | $e->get_error(); |
631 | 631 | } |
632 | 632 | // you have successfully run the gauntlet |
@@ -643,8 +643,8 @@ discard block |
||
643 | 643 | * @param string $name |
644 | 644 | * @return string |
645 | 645 | */ |
646 | - private function _generate_config_option_name( $section = '', $name = '' ) { |
|
647 | - return 'ee_config-' . strtolower( $section . '-' . str_replace( array( 'EE_', 'EED_' ), '', $name ) ); |
|
646 | + private function _generate_config_option_name($section = '', $name = '') { |
|
647 | + return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name)); |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | |
@@ -658,10 +658,10 @@ discard block |
||
658 | 658 | * @param string $name |
659 | 659 | * @return string |
660 | 660 | */ |
661 | - private function _set_config_class( $config_class = '', $name = '' ) { |
|
662 | - return ! empty( $config_class ) |
|
661 | + private function _set_config_class($config_class = '', $name = '') { |
|
662 | + return ! empty($config_class) |
|
663 | 663 | ? $config_class |
664 | - : str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $name ) ) ) . '_Config'; |
|
664 | + : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config'; |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -676,36 +676,36 @@ discard block |
||
676 | 676 | * @param EE_Config_Base $config_obj |
677 | 677 | * @return EE_Config_Base |
678 | 678 | */ |
679 | - public function set_config( $section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null ) { |
|
679 | + public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null) { |
|
680 | 680 | // ensure config class is set to something |
681 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
681 | + $config_class = $this->_set_config_class($config_class, $name); |
|
682 | 682 | // run tests 1-4, 6, and 7 to verify all config params are set and valid |
683 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) { |
|
683 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
684 | 684 | return null; |
685 | 685 | } |
686 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
686 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
687 | 687 | // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now |
688 | - if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) { |
|
689 | - $this->_addon_option_names[ $config_option_name ] = $config_class; |
|
688 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
689 | + $this->_addon_option_names[$config_option_name] = $config_class; |
|
690 | 690 | $this->update_addon_option_names(); |
691 | 691 | } |
692 | 692 | // verify the incoming config object but suppress errors |
693 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) { |
|
693 | + if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
694 | 694 | $config_obj = new $config_class(); |
695 | 695 | } |
696 | - if ( get_option( $config_option_name ) ) { |
|
697 | - EE_Config::log( $config_option_name ); |
|
698 | - update_option( $config_option_name, $config_obj ); |
|
696 | + if (get_option($config_option_name)) { |
|
697 | + EE_Config::log($config_option_name); |
|
698 | + update_option($config_option_name, $config_obj); |
|
699 | 699 | $this->{$section}->{$name} = $config_obj; |
700 | 700 | return $this->{$section}->{$name}; |
701 | 701 | } else { |
702 | 702 | // create a wp-option for this config |
703 | - if ( add_option( $config_option_name, $config_obj, '', 'no' ) ) { |
|
704 | - $this->{$section}->{$name} = maybe_unserialize( $config_obj ); |
|
703 | + if (add_option($config_option_name, $config_obj, '', 'no')) { |
|
704 | + $this->{$section}->{$name} = maybe_unserialize($config_obj); |
|
705 | 705 | return $this->{$section}->{$name}; |
706 | 706 | } else { |
707 | 707 | EE_Error::add_error( |
708 | - sprintf( __( 'The "%s" could not be saved to the database.', 'event_espresso' ), $config_class ), |
|
708 | + sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class), |
|
709 | 709 | __FILE__, |
710 | 710 | __FUNCTION__, |
711 | 711 | __LINE__ |
@@ -728,44 +728,44 @@ discard block |
||
728 | 728 | * @param bool $throw_errors |
729 | 729 | * @return bool |
730 | 730 | */ |
731 | - public function update_config( $section = '', $name = '', $config_obj = '', $throw_errors = true ) { |
|
731 | + public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true) { |
|
732 | 732 | // don't allow config updates during WP heartbeats |
733 | - if ( \EE_Registry::instance()->REQ->get( 'action', '' ) === 'heartbeat' ) { |
|
733 | + if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') { |
|
734 | 734 | return false; |
735 | 735 | } |
736 | - $config_obj = maybe_unserialize( $config_obj ); |
|
736 | + $config_obj = maybe_unserialize($config_obj); |
|
737 | 737 | // get class name of the incoming object |
738 | - $config_class = get_class( $config_obj ); |
|
738 | + $config_class = get_class($config_obj); |
|
739 | 739 | // run tests 1-5 and 9 to verify config |
740 | 740 | if ( ! $this->_verify_config_params( |
741 | 741 | $section, |
742 | 742 | $name, |
743 | 743 | $config_class, |
744 | 744 | $config_obj, |
745 | - array( 1, 2, 3, 4, 7, 9 ) |
|
745 | + array(1, 2, 3, 4, 7, 9) |
|
746 | 746 | ) |
747 | 747 | ) { |
748 | 748 | return false; |
749 | 749 | } |
750 | - $config_option_name = $this->_generate_config_option_name( $section, $name ); |
|
750 | + $config_option_name = $this->_generate_config_option_name($section, $name); |
|
751 | 751 | // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array |
752 | - if ( ! isset( $this->_addon_option_names[ $config_option_name ] ) ) { |
|
752 | + if ( ! isset($this->_addon_option_names[$config_option_name])) { |
|
753 | 753 | // save new config to db |
754 | - return $this->set_config( $section, $name, $config_class, $config_obj ); |
|
754 | + return $this->set_config($section, $name, $config_class, $config_obj); |
|
755 | 755 | } else { |
756 | 756 | // first check if the record already exists |
757 | - $existing_config = get_option( $config_option_name ); |
|
758 | - $config_obj = serialize( $config_obj ); |
|
757 | + $existing_config = get_option($config_option_name); |
|
758 | + $config_obj = serialize($config_obj); |
|
759 | 759 | // just return if db record is already up to date (NOT type safe comparison) |
760 | - if ( $existing_config == $config_obj ) { |
|
760 | + if ($existing_config == $config_obj) { |
|
761 | 761 | $this->{$section}->{$name} = $config_obj; |
762 | 762 | return true; |
763 | - } else if ( update_option( $config_option_name, $config_obj ) ) { |
|
764 | - EE_Config::log( $config_option_name ); |
|
763 | + } else if (update_option($config_option_name, $config_obj)) { |
|
764 | + EE_Config::log($config_option_name); |
|
765 | 765 | // update wp-option for this config class |
766 | 766 | $this->{$section}->{$name} = $config_obj; |
767 | 767 | return true; |
768 | - } elseif ( $throw_errors ) { |
|
768 | + } elseif ($throw_errors) { |
|
769 | 769 | EE_Error::add_error( |
770 | 770 | sprintf( |
771 | 771 | __( |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | 'event_espresso' |
774 | 774 | ), |
775 | 775 | $config_class, |
776 | - 'EE_Config->' . $section . '->' . $name |
|
776 | + 'EE_Config->'.$section.'->'.$name |
|
777 | 777 | ), |
778 | 778 | __FILE__, |
779 | 779 | __FUNCTION__, |
@@ -795,34 +795,34 @@ discard block |
||
795 | 795 | * @param string $config_class |
796 | 796 | * @return mixed EE_Config_Base | NULL |
797 | 797 | */ |
798 | - public function get_config( $section = '', $name = '', $config_class = '' ) { |
|
798 | + public function get_config($section = '', $name = '', $config_class = '') { |
|
799 | 799 | // ensure config class is set to something |
800 | - $config_class = $this->_set_config_class( $config_class, $name ); |
|
800 | + $config_class = $this->_set_config_class($config_class, $name); |
|
801 | 801 | // run tests 1-4, 6 and 7 to verify that all params have been set |
802 | - if ( ! $this->_verify_config_params( $section, $name, $config_class, null, array( 1, 2, 3, 4, 5, 6 ) ) ) { |
|
802 | + if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) { |
|
803 | 803 | return null; |
804 | 804 | } |
805 | 805 | // now test if the requested config object exists, but suppress errors |
806 | - if ( $this->_verify_config_params( $section, $name, $config_class, null, array( 7, 8 ), false ) ) { |
|
806 | + if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) { |
|
807 | 807 | // config already exists, so pass it back |
808 | 808 | return $this->{$section}->{$name}; |
809 | 809 | } |
810 | 810 | // load config option from db if it exists |
811 | - $config_obj = $this->get_config_option( $this->_generate_config_option_name( $section, $name ) ); |
|
811 | + $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name)); |
|
812 | 812 | // verify the newly retrieved config object, but suppress errors |
813 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ), false ) ) { |
|
813 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) { |
|
814 | 814 | // config is good, so set it and pass it back |
815 | 815 | $this->{$section}->{$name} = $config_obj; |
816 | 816 | return $this->{$section}->{$name}; |
817 | 817 | } |
818 | 818 | // oops! $config_obj is not already set and does not exist in the db, so create a new one |
819 | - $config_obj = $this->set_config( $section, $name, $config_class ); |
|
819 | + $config_obj = $this->set_config($section, $name, $config_class); |
|
820 | 820 | // verify the newly created config object |
821 | - if ( $this->_verify_config_params( $section, $name, $config_class, $config_obj, array( 9 ) ) ) { |
|
821 | + if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) { |
|
822 | 822 | return $this->{$section}->{$name}; |
823 | 823 | } else { |
824 | 824 | EE_Error::add_error( |
825 | - sprintf( __( 'The "%s" could not be retrieved from the database.', 'event_espresso' ), $config_class ), |
|
825 | + sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class), |
|
826 | 826 | __FILE__, |
827 | 827 | __FUNCTION__, |
828 | 828 | __LINE__ |
@@ -840,11 +840,11 @@ discard block |
||
840 | 840 | * @param string $config_option_name |
841 | 841 | * @return mixed EE_Config_Base | FALSE |
842 | 842 | */ |
843 | - public function get_config_option( $config_option_name = '' ) { |
|
843 | + public function get_config_option($config_option_name = '') { |
|
844 | 844 | // retrieve the wp-option for this config class. |
845 | - $config_option = maybe_unserialize( get_option( $config_option_name, array() ) ); |
|
846 | - if ( empty( $config_option ) ) { |
|
847 | - EE_Config::log( $config_option_name . '-NOT-FOUND' ); |
|
845 | + $config_option = maybe_unserialize(get_option($config_option_name, array())); |
|
846 | + if (empty($config_option)) { |
|
847 | + EE_Config::log($config_option_name.'-NOT-FOUND'); |
|
848 | 848 | } |
849 | 849 | return $config_option; |
850 | 850 | } |
@@ -856,17 +856,17 @@ discard block |
||
856 | 856 | * |
857 | 857 | * @param string $config_option_name |
858 | 858 | */ |
859 | - public static function log( $config_option_name = '' ) { |
|
860 | - if ( ! empty( $config_option_name ) ) { |
|
861 | - $config_log = get_option( EE_Config::LOG_NAME, array() ); |
|
859 | + public static function log($config_option_name = '') { |
|
860 | + if ( ! empty($config_option_name)) { |
|
861 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
862 | 862 | //copy incoming $_REQUEST and sanitize it so we can save it |
863 | 863 | $_request = $_REQUEST; |
864 | - array_walk_recursive( $_request, 'sanitize_text_field' ); |
|
865 | - $config_log[ (string) microtime( true ) ] = array( |
|
864 | + array_walk_recursive($_request, 'sanitize_text_field'); |
|
865 | + $config_log[(string) microtime(true)] = array( |
|
866 | 866 | 'config_name' => $config_option_name, |
867 | 867 | 'request' => $_request, |
868 | 868 | ); |
869 | - update_option( EE_Config::LOG_NAME, $config_log ); |
|
869 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 | |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH |
878 | 878 | */ |
879 | 879 | public static function trim_log() { |
880 | - $config_log = get_option( EE_Config::LOG_NAME, array() ); |
|
881 | - $log_length = count( $config_log ); |
|
882 | - if ( $log_length > EE_Config::LOG_LENGTH ) { |
|
883 | - ksort( $config_log ); |
|
884 | - $config_log = array_slice( $config_log, $log_length - EE_Config::LOG_LENGTH, null, true ); |
|
885 | - update_option( EE_Config::LOG_NAME, $config_log ); |
|
880 | + $config_log = get_option(EE_Config::LOG_NAME, array()); |
|
881 | + $log_length = count($config_log); |
|
882 | + if ($log_length > EE_Config::LOG_LENGTH) { |
|
883 | + ksort($config_log); |
|
884 | + $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true); |
|
885 | + update_option(EE_Config::LOG_NAME, $config_log); |
|
886 | 886 | } |
887 | 887 | } |
888 | 888 | |
@@ -897,14 +897,14 @@ discard block |
||
897 | 897 | * @return string |
898 | 898 | */ |
899 | 899 | public static function get_page_for_posts() { |
900 | - $page_for_posts = get_option( 'page_for_posts' ); |
|
901 | - if ( ! $page_for_posts ) { |
|
900 | + $page_for_posts = get_option('page_for_posts'); |
|
901 | + if ( ! $page_for_posts) { |
|
902 | 902 | return 'posts'; |
903 | 903 | } |
904 | 904 | /** @type WPDB $wpdb */ |
905 | 905 | global $wpdb; |
906 | 906 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d"; |
907 | - return $wpdb->get_var( $wpdb->prepare( $SQL, $page_for_posts ) ); |
|
907 | + return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts)); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | |
@@ -960,17 +960,17 @@ discard block |
||
960 | 960 | ) |
961 | 961 | ) { |
962 | 962 | // grab list of installed widgets |
963 | - $widgets_to_register = glob( EE_WIDGETS . '*', GLOB_ONLYDIR ); |
|
963 | + $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR); |
|
964 | 964 | // filter list of modules to register |
965 | 965 | $widgets_to_register = apply_filters( |
966 | 966 | 'FHEE__EE_Config__register_widgets__widgets_to_register', |
967 | 967 | $widgets_to_register |
968 | 968 | ); |
969 | - if ( ! empty( $widgets_to_register ) ) { |
|
969 | + if ( ! empty($widgets_to_register)) { |
|
970 | 970 | // cycle thru widget folders |
971 | - foreach ( $widgets_to_register as $widget_path ) { |
|
971 | + foreach ($widgets_to_register as $widget_path) { |
|
972 | 972 | // add to list of installed widget modules |
973 | - EE_Config::register_ee_widget( $widget_path ); |
|
973 | + EE_Config::register_ee_widget($widget_path); |
|
974 | 974 | } |
975 | 975 | } |
976 | 976 | // filter list of installed modules |
@@ -990,57 +990,57 @@ discard block |
||
990 | 990 | * @param string $widget_path - full path up to and including widget folder |
991 | 991 | * @return void |
992 | 992 | */ |
993 | - public static function register_ee_widget( $widget_path = null ) { |
|
994 | - do_action( 'AHEE__EE_Config__register_widget__begin', $widget_path ); |
|
993 | + public static function register_ee_widget($widget_path = null) { |
|
994 | + do_action('AHEE__EE_Config__register_widget__begin', $widget_path); |
|
995 | 995 | $widget_ext = '.widget.php'; |
996 | 996 | // make all separators match |
997 | - $widget_path = rtrim( str_replace( '/\\', DS, $widget_path ), DS ); |
|
997 | + $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS); |
|
998 | 998 | // does the file path INCLUDE the actual file name as part of the path ? |
999 | - if ( strpos( $widget_path, $widget_ext ) !== false ) { |
|
999 | + if (strpos($widget_path, $widget_ext) !== false) { |
|
1000 | 1000 | // grab and shortcode file name from directory name and break apart at dots |
1001 | - $file_name = explode( '.', basename( $widget_path ) ); |
|
1001 | + $file_name = explode('.', basename($widget_path)); |
|
1002 | 1002 | // take first segment from file name pieces and remove class prefix if it exists |
1003 | - $widget = strpos( $file_name[0], 'EEW_' ) === 0 ? substr( $file_name[0], 4 ) : $file_name[0]; |
|
1003 | + $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0]; |
|
1004 | 1004 | // sanitize shortcode directory name |
1005 | - $widget = sanitize_key( $widget ); |
|
1005 | + $widget = sanitize_key($widget); |
|
1006 | 1006 | // now we need to rebuild the shortcode path |
1007 | - $widget_path = explode( DS, $widget_path ); |
|
1007 | + $widget_path = explode(DS, $widget_path); |
|
1008 | 1008 | // remove last segment |
1009 | - array_pop( $widget_path ); |
|
1009 | + array_pop($widget_path); |
|
1010 | 1010 | // glue it back together |
1011 | - $widget_path = implode( DS, $widget_path ); |
|
1011 | + $widget_path = implode(DS, $widget_path); |
|
1012 | 1012 | } else { |
1013 | 1013 | // grab and sanitize widget directory name |
1014 | - $widget = sanitize_key( basename( $widget_path ) ); |
|
1014 | + $widget = sanitize_key(basename($widget_path)); |
|
1015 | 1015 | } |
1016 | 1016 | // create classname from widget directory name |
1017 | - $widget = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $widget ) ) ); |
|
1017 | + $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget))); |
|
1018 | 1018 | // add class prefix |
1019 | - $widget_class = 'EEW_' . $widget; |
|
1019 | + $widget_class = 'EEW_'.$widget; |
|
1020 | 1020 | // does the widget exist ? |
1021 | - if ( ! is_readable( $widget_path . DS . $widget_class . $widget_ext ) ) { |
|
1021 | + if ( ! is_readable($widget_path.DS.$widget_class.$widget_ext)) { |
|
1022 | 1022 | $msg = sprintf( |
1023 | 1023 | __( |
1024 | 1024 | 'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', |
1025 | 1025 | 'event_espresso' |
1026 | 1026 | ), |
1027 | 1027 | $widget_class, |
1028 | - $widget_path . DS . $widget_class . $widget_ext |
|
1028 | + $widget_path.DS.$widget_class.$widget_ext |
|
1029 | 1029 | ); |
1030 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1030 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1031 | 1031 | return; |
1032 | 1032 | } |
1033 | 1033 | // load the widget class file |
1034 | - require_once( $widget_path . DS . $widget_class . $widget_ext ); |
|
1034 | + require_once($widget_path.DS.$widget_class.$widget_ext); |
|
1035 | 1035 | // verify that class exists |
1036 | - if ( ! class_exists( $widget_class ) ) { |
|
1037 | - $msg = sprintf( __( 'The requested %s widget class does not exist.', 'event_espresso' ), $widget_class ); |
|
1038 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1036 | + if ( ! class_exists($widget_class)) { |
|
1037 | + $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class); |
|
1038 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1039 | 1039 | return; |
1040 | 1040 | } |
1041 | - register_widget( $widget_class ); |
|
1041 | + register_widget($widget_class); |
|
1042 | 1042 | // add to array of registered widgets |
1043 | - EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext; |
|
1043 | + EE_Registry::instance()->widgets->{$widget_class} = $widget_path.DS.$widget_class.$widget_ext; |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | |
@@ -1053,17 +1053,17 @@ discard block |
||
1053 | 1053 | */ |
1054 | 1054 | private function _register_shortcodes() { |
1055 | 1055 | // grab list of installed shortcodes |
1056 | - $shortcodes_to_register = glob( EE_SHORTCODES . '*', GLOB_ONLYDIR ); |
|
1056 | + $shortcodes_to_register = glob(EE_SHORTCODES.'*', GLOB_ONLYDIR); |
|
1057 | 1057 | // filter list of modules to register |
1058 | 1058 | $shortcodes_to_register = apply_filters( |
1059 | 1059 | 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
1060 | 1060 | $shortcodes_to_register |
1061 | 1061 | ); |
1062 | - if ( ! empty( $shortcodes_to_register ) ) { |
|
1062 | + if ( ! empty($shortcodes_to_register)) { |
|
1063 | 1063 | // cycle thru shortcode folders |
1064 | - foreach ( $shortcodes_to_register as $shortcode_path ) { |
|
1064 | + foreach ($shortcodes_to_register as $shortcode_path) { |
|
1065 | 1065 | // add to list of installed shortcode modules |
1066 | - EE_Config::register_shortcode( $shortcode_path ); |
|
1066 | + EE_Config::register_shortcode($shortcode_path); |
|
1067 | 1067 | } |
1068 | 1068 | } |
1069 | 1069 | // filter list of installed modules |
@@ -1082,64 +1082,64 @@ discard block |
||
1082 | 1082 | * @param string $shortcode_path - full path up to and including shortcode folder |
1083 | 1083 | * @return bool |
1084 | 1084 | */ |
1085 | - public static function register_shortcode( $shortcode_path = null ) { |
|
1086 | - do_action( 'AHEE__EE_Config__register_shortcode__begin', $shortcode_path ); |
|
1085 | + public static function register_shortcode($shortcode_path = null) { |
|
1086 | + do_action('AHEE__EE_Config__register_shortcode__begin', $shortcode_path); |
|
1087 | 1087 | $shortcode_ext = '.shortcode.php'; |
1088 | 1088 | // make all separators match |
1089 | - $shortcode_path = str_replace( array( '\\', '/' ), DS, $shortcode_path ); |
|
1089 | + $shortcode_path = str_replace(array('\\', '/'), DS, $shortcode_path); |
|
1090 | 1090 | // does the file path INCLUDE the actual file name as part of the path ? |
1091 | - if ( strpos( $shortcode_path, $shortcode_ext ) !== false ) { |
|
1091 | + if (strpos($shortcode_path, $shortcode_ext) !== false) { |
|
1092 | 1092 | // grab shortcode file name from directory name and break apart at dots |
1093 | - $shortcode_file = explode( '.', basename( $shortcode_path ) ); |
|
1093 | + $shortcode_file = explode('.', basename($shortcode_path)); |
|
1094 | 1094 | // take first segment from file name pieces and remove class prefix if it exists |
1095 | - $shortcode = strpos( $shortcode_file[0], 'EES_' ) === 0 |
|
1096 | - ? substr( $shortcode_file[0], 4 ) |
|
1095 | + $shortcode = strpos($shortcode_file[0], 'EES_') === 0 |
|
1096 | + ? substr($shortcode_file[0], 4) |
|
1097 | 1097 | : $shortcode_file[0]; |
1098 | 1098 | // sanitize shortcode directory name |
1099 | - $shortcode = sanitize_key( $shortcode ); |
|
1099 | + $shortcode = sanitize_key($shortcode); |
|
1100 | 1100 | // now we need to rebuild the shortcode path |
1101 | - $shortcode_path = explode( DS, $shortcode_path ); |
|
1101 | + $shortcode_path = explode(DS, $shortcode_path); |
|
1102 | 1102 | // remove last segment |
1103 | - array_pop( $shortcode_path ); |
|
1103 | + array_pop($shortcode_path); |
|
1104 | 1104 | // glue it back together |
1105 | - $shortcode_path = implode( DS, $shortcode_path ) . DS; |
|
1105 | + $shortcode_path = implode(DS, $shortcode_path).DS; |
|
1106 | 1106 | } else { |
1107 | 1107 | // we need to generate the filename based off of the folder name |
1108 | 1108 | // grab and sanitize shortcode directory name |
1109 | - $shortcode = sanitize_key( basename( $shortcode_path ) ); |
|
1110 | - $shortcode_path = rtrim( $shortcode_path, DS ) . DS; |
|
1109 | + $shortcode = sanitize_key(basename($shortcode_path)); |
|
1110 | + $shortcode_path = rtrim($shortcode_path, DS).DS; |
|
1111 | 1111 | } |
1112 | 1112 | // create classname from shortcode directory or file name |
1113 | - $shortcode = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $shortcode ) ) ); |
|
1113 | + $shortcode = str_replace(' ', '_', ucwords(str_replace('_', ' ', $shortcode))); |
|
1114 | 1114 | // add class prefix |
1115 | - $shortcode_class = 'EES_' . $shortcode; |
|
1115 | + $shortcode_class = 'EES_'.$shortcode; |
|
1116 | 1116 | // does the shortcode exist ? |
1117 | - if ( ! is_readable( $shortcode_path . DS . $shortcode_class . $shortcode_ext ) ) { |
|
1117 | + if ( ! is_readable($shortcode_path.DS.$shortcode_class.$shortcode_ext)) { |
|
1118 | 1118 | $msg = sprintf( |
1119 | 1119 | __( |
1120 | 1120 | 'The requested %s shortcode file could not be found or is not readable due to file permissions. It should be in %s', |
1121 | 1121 | 'event_espresso' |
1122 | 1122 | ), |
1123 | 1123 | $shortcode_class, |
1124 | - $shortcode_path . DS . $shortcode_class . $shortcode_ext |
|
1124 | + $shortcode_path.DS.$shortcode_class.$shortcode_ext |
|
1125 | 1125 | ); |
1126 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1126 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1127 | 1127 | return false; |
1128 | 1128 | } |
1129 | 1129 | // load the shortcode class file |
1130 | - require_once( $shortcode_path . $shortcode_class . $shortcode_ext ); |
|
1130 | + require_once($shortcode_path.$shortcode_class.$shortcode_ext); |
|
1131 | 1131 | // verify that class exists |
1132 | - if ( ! class_exists( $shortcode_class ) ) { |
|
1132 | + if ( ! class_exists($shortcode_class)) { |
|
1133 | 1133 | $msg = sprintf( |
1134 | - __( 'The requested %s shortcode class does not exist.', 'event_espresso' ), |
|
1134 | + __('The requested %s shortcode class does not exist.', 'event_espresso'), |
|
1135 | 1135 | $shortcode_class |
1136 | 1136 | ); |
1137 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1137 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1138 | 1138 | return false; |
1139 | 1139 | } |
1140 | - $shortcode = strtoupper( $shortcode ); |
|
1140 | + $shortcode = strtoupper($shortcode); |
|
1141 | 1141 | // add to array of registered shortcodes |
1142 | - EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path . $shortcode_class . $shortcode_ext; |
|
1142 | + EE_Registry::instance()->shortcodes->{$shortcode} = $shortcode_path.$shortcode_class.$shortcode_ext; |
|
1143 | 1143 | return true; |
1144 | 1144 | } |
1145 | 1145 | |
@@ -1153,22 +1153,22 @@ discard block |
||
1153 | 1153 | */ |
1154 | 1154 | private function _register_modules() { |
1155 | 1155 | // grab list of installed modules |
1156 | - $modules_to_register = glob( EE_MODULES . '*', GLOB_ONLYDIR ); |
|
1156 | + $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR); |
|
1157 | 1157 | // filter list of modules to register |
1158 | 1158 | $modules_to_register = apply_filters( |
1159 | 1159 | 'FHEE__EE_Config__register_modules__modules_to_register', |
1160 | 1160 | $modules_to_register |
1161 | 1161 | ); |
1162 | - if ( ! empty( $modules_to_register ) ) { |
|
1162 | + if ( ! empty($modules_to_register)) { |
|
1163 | 1163 | // loop through folders |
1164 | - foreach ( $modules_to_register as $module_path ) { |
|
1164 | + foreach ($modules_to_register as $module_path) { |
|
1165 | 1165 | /**TEMPORARILY EXCLUDE gateways from modules for time being**/ |
1166 | 1166 | if ( |
1167 | - $module_path !== EE_MODULES . 'zzz-copy-this-module-template' |
|
1168 | - && $module_path !== EE_MODULES . 'gateways' |
|
1167 | + $module_path !== EE_MODULES.'zzz-copy-this-module-template' |
|
1168 | + && $module_path !== EE_MODULES.'gateways' |
|
1169 | 1169 | ) { |
1170 | 1170 | // add to list of installed modules |
1171 | - EE_Config::register_module( $module_path ); |
|
1171 | + EE_Config::register_module($module_path); |
|
1172 | 1172 | } |
1173 | 1173 | } |
1174 | 1174 | } |
@@ -1188,39 +1188,39 @@ discard block |
||
1188 | 1188 | * @param string $module_path - full path up to and including module folder |
1189 | 1189 | * @return bool |
1190 | 1190 | */ |
1191 | - public static function register_module( $module_path = null ) { |
|
1192 | - do_action( 'AHEE__EE_Config__register_module__begin', $module_path ); |
|
1191 | + public static function register_module($module_path = null) { |
|
1192 | + do_action('AHEE__EE_Config__register_module__begin', $module_path); |
|
1193 | 1193 | $module_ext = '.module.php'; |
1194 | 1194 | // make all separators match |
1195 | - $module_path = str_replace( array( '\\', '/' ), DS, $module_path ); |
|
1195 | + $module_path = str_replace(array('\\', '/'), DS, $module_path); |
|
1196 | 1196 | // does the file path INCLUDE the actual file name as part of the path ? |
1197 | - if ( strpos( $module_path, $module_ext ) !== false ) { |
|
1197 | + if (strpos($module_path, $module_ext) !== false) { |
|
1198 | 1198 | // grab and shortcode file name from directory name and break apart at dots |
1199 | - $module_file = explode( '.', basename( $module_path ) ); |
|
1199 | + $module_file = explode('.', basename($module_path)); |
|
1200 | 1200 | // now we need to rebuild the shortcode path |
1201 | - $module_path = explode( DS, $module_path ); |
|
1201 | + $module_path = explode(DS, $module_path); |
|
1202 | 1202 | // remove last segment |
1203 | - array_pop( $module_path ); |
|
1203 | + array_pop($module_path); |
|
1204 | 1204 | // glue it back together |
1205 | - $module_path = implode( DS, $module_path ) . DS; |
|
1205 | + $module_path = implode(DS, $module_path).DS; |
|
1206 | 1206 | // take first segment from file name pieces and sanitize it |
1207 | - $module = preg_replace( '/[^a-zA-Z0-9_\-]/', '', $module_file[0] ); |
|
1207 | + $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]); |
|
1208 | 1208 | // ensure class prefix is added |
1209 | - $module_class = strpos( $module, 'EED_' ) !== 0 ? 'EED_' . $module : $module; |
|
1209 | + $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module; |
|
1210 | 1210 | } else { |
1211 | 1211 | // we need to generate the filename based off of the folder name |
1212 | 1212 | // grab and sanitize module name |
1213 | - $module = strtolower( basename( $module_path ) ); |
|
1214 | - $module = preg_replace( '/[^a-z0-9_\-]/', '', $module ); |
|
1213 | + $module = strtolower(basename($module_path)); |
|
1214 | + $module = preg_replace('/[^a-z0-9_\-]/', '', $module); |
|
1215 | 1215 | // like trailingslashit() |
1216 | - $module_path = rtrim( $module_path, DS ) . DS; |
|
1216 | + $module_path = rtrim($module_path, DS).DS; |
|
1217 | 1217 | // create classname from module directory name |
1218 | - $module = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $module ) ) ); |
|
1218 | + $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module))); |
|
1219 | 1219 | // add class prefix |
1220 | - $module_class = 'EED_' . $module; |
|
1220 | + $module_class = 'EED_'.$module; |
|
1221 | 1221 | } |
1222 | 1222 | // does the module exist ? |
1223 | - if ( ! is_readable( $module_path . DS . $module_class . $module_ext ) ) { |
|
1223 | + if ( ! is_readable($module_path.DS.$module_class.$module_ext)) { |
|
1224 | 1224 | $msg = sprintf( |
1225 | 1225 | __( |
1226 | 1226 | 'The requested %s module file could not be found or is not readable due to file permissions.', |
@@ -1228,19 +1228,19 @@ discard block |
||
1228 | 1228 | ), |
1229 | 1229 | $module |
1230 | 1230 | ); |
1231 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1231 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1232 | 1232 | return false; |
1233 | 1233 | } |
1234 | 1234 | // load the module class file |
1235 | - require_once( $module_path . $module_class . $module_ext ); |
|
1235 | + require_once($module_path.$module_class.$module_ext); |
|
1236 | 1236 | // verify that class exists |
1237 | - if ( ! class_exists( $module_class ) ) { |
|
1238 | - $msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class ); |
|
1239 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1237 | + if ( ! class_exists($module_class)) { |
|
1238 | + $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class); |
|
1239 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1240 | 1240 | return false; |
1241 | 1241 | } |
1242 | 1242 | // add to array of registered modules |
1243 | - EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext; |
|
1243 | + EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext; |
|
1244 | 1244 | do_action( |
1245 | 1245 | 'AHEE__EE_Config__register_module__complete', |
1246 | 1246 | $module_class, |
@@ -1260,26 +1260,26 @@ discard block |
||
1260 | 1260 | */ |
1261 | 1261 | private function _initialize_shortcodes() { |
1262 | 1262 | // cycle thru shortcode folders |
1263 | - foreach ( EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path ) { |
|
1263 | + foreach (EE_Registry::instance()->shortcodes as $shortcode => $shortcode_path) { |
|
1264 | 1264 | // add class prefix |
1265 | - $shortcode_class = 'EES_' . $shortcode; |
|
1265 | + $shortcode_class = 'EES_'.$shortcode; |
|
1266 | 1266 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1267 | 1267 | // which set hooks ? |
1268 | - if ( is_admin() ) { |
|
1268 | + if (is_admin()) { |
|
1269 | 1269 | // fire immediately |
1270 | - call_user_func( array( $shortcode_class, 'set_hooks_admin' ) ); |
|
1270 | + call_user_func(array($shortcode_class, 'set_hooks_admin')); |
|
1271 | 1271 | } else { |
1272 | 1272 | // delay until other systems are online |
1273 | 1273 | add_action( |
1274 | 1274 | 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
1275 | - array( $shortcode_class, 'set_hooks' ) |
|
1275 | + array($shortcode_class, 'set_hooks') |
|
1276 | 1276 | ); |
1277 | 1277 | // convert classname to UPPERCASE and create WP shortcode. |
1278 | - $shortcode_tag = strtoupper( $shortcode ); |
|
1278 | + $shortcode_tag = strtoupper($shortcode); |
|
1279 | 1279 | // but first check if the shortcode has already been added before assigning 'fallback_shortcode_processor' |
1280 | - if ( ! shortcode_exists( $shortcode_tag ) ) { |
|
1280 | + if ( ! shortcode_exists($shortcode_tag)) { |
|
1281 | 1281 | // NOTE: this shortcode declaration will get overridden if the shortcode is successfully detected in the post content in EE_Front_Controller->_initialize_shortcodes() |
1282 | - add_shortcode( $shortcode_tag, array( $shortcode_class, 'fallback_shortcode_processor' ) ); |
|
1282 | + add_shortcode($shortcode_tag, array($shortcode_class, 'fallback_shortcode_processor')); |
|
1283 | 1283 | } |
1284 | 1284 | } |
1285 | 1285 | } |
@@ -1296,17 +1296,17 @@ discard block |
||
1296 | 1296 | */ |
1297 | 1297 | private function _initialize_modules() { |
1298 | 1298 | // cycle thru shortcode folders |
1299 | - foreach ( EE_Registry::instance()->modules as $module_class => $module_path ) { |
|
1299 | + foreach (EE_Registry::instance()->modules as $module_class => $module_path) { |
|
1300 | 1300 | // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system |
1301 | 1301 | // which set hooks ? |
1302 | - if ( is_admin() ) { |
|
1302 | + if (is_admin()) { |
|
1303 | 1303 | // fire immediately |
1304 | - call_user_func( array( $module_class, 'set_hooks_admin' ) ); |
|
1304 | + call_user_func(array($module_class, 'set_hooks_admin')); |
|
1305 | 1305 | } else { |
1306 | 1306 | // delay until other systems are online |
1307 | 1307 | add_action( |
1308 | 1308 | 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', |
1309 | - array( $module_class, 'set_hooks' ) |
|
1309 | + array($module_class, 'set_hooks') |
|
1310 | 1310 | ); |
1311 | 1311 | } |
1312 | 1312 | } |
@@ -1324,29 +1324,29 @@ discard block |
||
1324 | 1324 | * @param string $key - url param key indicating a route is being called |
1325 | 1325 | * @return bool |
1326 | 1326 | */ |
1327 | - public static function register_route( $route = null, $module = null, $method_name = null, $key = 'ee' ) { |
|
1328 | - do_action( 'AHEE__EE_Config__register_route__begin', $route, $module, $method_name ); |
|
1329 | - $module = str_replace( 'EED_', '', $module ); |
|
1330 | - $module_class = 'EED_' . $module; |
|
1331 | - if ( ! isset( EE_Registry::instance()->modules->{$module_class} ) ) { |
|
1332 | - $msg = sprintf( __( 'The module %s has not been registered.', 'event_espresso' ), $module ); |
|
1333 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1327 | + public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee') { |
|
1328 | + do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name); |
|
1329 | + $module = str_replace('EED_', '', $module); |
|
1330 | + $module_class = 'EED_'.$module; |
|
1331 | + if ( ! isset(EE_Registry::instance()->modules->{$module_class} )) { |
|
1332 | + $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module); |
|
1333 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1334 | 1334 | return false; |
1335 | 1335 | } |
1336 | - if ( empty( $route ) ) { |
|
1337 | - $msg = sprintf( __( 'No route has been supplied.', 'event_espresso' ), $route ); |
|
1338 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1336 | + if (empty($route)) { |
|
1337 | + $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route); |
|
1338 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1339 | 1339 | return false; |
1340 | 1340 | } |
1341 | - if ( ! method_exists( 'EED_' . $module, $method_name ) ) { |
|
1341 | + if ( ! method_exists('EED_'.$module, $method_name)) { |
|
1342 | 1342 | $msg = sprintf( |
1343 | - __( 'A valid class method for the %s route has not been supplied.', 'event_espresso' ), |
|
1343 | + __('A valid class method for the %s route has not been supplied.', 'event_espresso'), |
|
1344 | 1344 | $route |
1345 | 1345 | ); |
1346 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1346 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1347 | 1347 | return false; |
1348 | 1348 | } |
1349 | - EE_Config::$_module_route_map[ $key ][ $route ] = array( 'EED_' . $module, $method_name ); |
|
1349 | + EE_Config::$_module_route_map[$key][$route] = array('EED_'.$module, $method_name); |
|
1350 | 1350 | return true; |
1351 | 1351 | } |
1352 | 1352 | |
@@ -1360,11 +1360,11 @@ discard block |
||
1360 | 1360 | * @param string $key - url param key indicating a route is being called |
1361 | 1361 | * @return string |
1362 | 1362 | */ |
1363 | - public static function get_route( $route = null, $key = 'ee' ) { |
|
1364 | - do_action( 'AHEE__EE_Config__get_route__begin', $route ); |
|
1365 | - $route = (string) apply_filters( 'FHEE__EE_Config__get_route', $route ); |
|
1366 | - if ( isset( EE_Config::$_module_route_map[ $key ][ $route ] ) ) { |
|
1367 | - return EE_Config::$_module_route_map[ $key ][ $route ]; |
|
1363 | + public static function get_route($route = null, $key = 'ee') { |
|
1364 | + do_action('AHEE__EE_Config__get_route__begin', $route); |
|
1365 | + $route = (string) apply_filters('FHEE__EE_Config__get_route', $route); |
|
1366 | + if (isset(EE_Config::$_module_route_map[$key][$route])) { |
|
1367 | + return EE_Config::$_module_route_map[$key][$route]; |
|
1368 | 1368 | } |
1369 | 1369 | return null; |
1370 | 1370 | } |
@@ -1394,49 +1394,49 @@ discard block |
||
1394 | 1394 | * @param string $key - url param key indicating a route is being called |
1395 | 1395 | * @return bool |
1396 | 1396 | */ |
1397 | - public static function register_forward( $route = null, $status = 0, $forward = null, $key = 'ee' ) { |
|
1398 | - do_action( 'AHEE__EE_Config__register_forward', $route, $status, $forward ); |
|
1399 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) { |
|
1397 | + public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee') { |
|
1398 | + do_action('AHEE__EE_Config__register_forward', $route, $status, $forward); |
|
1399 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1400 | 1400 | $msg = sprintf( |
1401 | - __( 'The module route %s for this forward has not been registered.', 'event_espresso' ), |
|
1401 | + __('The module route %s for this forward has not been registered.', 'event_espresso'), |
|
1402 | 1402 | $route |
1403 | 1403 | ); |
1404 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1404 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1405 | 1405 | return false; |
1406 | 1406 | } |
1407 | - if ( empty( $forward ) ) { |
|
1408 | - $msg = sprintf( __( 'No forwarding route has been supplied.', 'event_espresso' ), $route ); |
|
1409 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1407 | + if (empty($forward)) { |
|
1408 | + $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route); |
|
1409 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1410 | 1410 | return false; |
1411 | 1411 | } |
1412 | - if ( is_array( $forward ) ) { |
|
1413 | - if ( ! isset( $forward[1] ) ) { |
|
1412 | + if (is_array($forward)) { |
|
1413 | + if ( ! isset($forward[1])) { |
|
1414 | 1414 | $msg = sprintf( |
1415 | - __( 'A class method for the %s forwarding route has not been supplied.', 'event_espresso' ), |
|
1415 | + __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'), |
|
1416 | 1416 | $route |
1417 | 1417 | ); |
1418 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1418 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1419 | 1419 | return false; |
1420 | 1420 | } |
1421 | - if ( ! method_exists( $forward[0], $forward[1] ) ) { |
|
1421 | + if ( ! method_exists($forward[0], $forward[1])) { |
|
1422 | 1422 | $msg = sprintf( |
1423 | - __( 'The class method %s for the %s forwarding route is in invalid.', 'event_espresso' ), |
|
1423 | + __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1424 | 1424 | $forward[1], |
1425 | 1425 | $route |
1426 | 1426 | ); |
1427 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1427 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1428 | 1428 | return false; |
1429 | 1429 | } |
1430 | - } else if ( ! function_exists( $forward ) ) { |
|
1430 | + } else if ( ! function_exists($forward)) { |
|
1431 | 1431 | $msg = sprintf( |
1432 | - __( 'The function %s for the %s forwarding route is in invalid.', 'event_espresso' ), |
|
1432 | + __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'), |
|
1433 | 1433 | $forward, |
1434 | 1434 | $route |
1435 | 1435 | ); |
1436 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1436 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1437 | 1437 | return false; |
1438 | 1438 | } |
1439 | - EE_Config::$_module_forward_map[ $key ][ $route ][ absint( $status ) ] = $forward; |
|
1439 | + EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward; |
|
1440 | 1440 | return true; |
1441 | 1441 | } |
1442 | 1442 | |
@@ -1452,12 +1452,12 @@ discard block |
||
1452 | 1452 | * @param string $key - url param key indicating a route is being called |
1453 | 1453 | * @return string |
1454 | 1454 | */ |
1455 | - public static function get_forward( $route = null, $status = 0, $key = 'ee' ) { |
|
1456 | - do_action( 'AHEE__EE_Config__get_forward__begin', $route, $status ); |
|
1457 | - if ( isset( EE_Config::$_module_forward_map[ $key ][ $route ][ $status ] ) ) { |
|
1455 | + public static function get_forward($route = null, $status = 0, $key = 'ee') { |
|
1456 | + do_action('AHEE__EE_Config__get_forward__begin', $route, $status); |
|
1457 | + if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) { |
|
1458 | 1458 | return apply_filters( |
1459 | 1459 | 'FHEE__EE_Config__get_forward', |
1460 | - EE_Config::$_module_forward_map[ $key ][ $route ][ $status ], |
|
1460 | + EE_Config::$_module_forward_map[$key][$route][$status], |
|
1461 | 1461 | $route, |
1462 | 1462 | $status |
1463 | 1463 | ); |
@@ -1479,17 +1479,17 @@ discard block |
||
1479 | 1479 | * @param string $key - url param key indicating a route is being called |
1480 | 1480 | * @return bool |
1481 | 1481 | */ |
1482 | - public static function register_view( $route = null, $status = 0, $view = null, $key = 'ee' ) { |
|
1483 | - do_action( 'AHEE__EE_Config__register_view__begin', $route, $status, $view ); |
|
1484 | - if ( ! isset( EE_Config::$_module_route_map[ $key ][ $route ] ) || empty( $route ) ) { |
|
1482 | + public static function register_view($route = null, $status = 0, $view = null, $key = 'ee') { |
|
1483 | + do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view); |
|
1484 | + if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) { |
|
1485 | 1485 | $msg = sprintf( |
1486 | - __( 'The module route %s for this view has not been registered.', 'event_espresso' ), |
|
1486 | + __('The module route %s for this view has not been registered.', 'event_espresso'), |
|
1487 | 1487 | $route |
1488 | 1488 | ); |
1489 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1489 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1490 | 1490 | return false; |
1491 | 1491 | } |
1492 | - if ( ! is_readable( $view ) ) { |
|
1492 | + if ( ! is_readable($view)) { |
|
1493 | 1493 | $msg = sprintf( |
1494 | 1494 | __( |
1495 | 1495 | 'The %s view file could not be found or is not readable due to file permissions.', |
@@ -1497,10 +1497,10 @@ discard block |
||
1497 | 1497 | ), |
1498 | 1498 | $view |
1499 | 1499 | ); |
1500 | - EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1500 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
1501 | 1501 | return false; |
1502 | 1502 | } |
1503 | - EE_Config::$_module_view_map[ $key ][ $route ][ absint( $status ) ] = $view; |
|
1503 | + EE_Config::$_module_view_map[$key][$route][absint($status)] = $view; |
|
1504 | 1504 | return true; |
1505 | 1505 | } |
1506 | 1506 | |
@@ -1516,12 +1516,12 @@ discard block |
||
1516 | 1516 | * @param string $key - url param key indicating a route is being called |
1517 | 1517 | * @return string |
1518 | 1518 | */ |
1519 | - public static function get_view( $route = null, $status = 0, $key = 'ee' ) { |
|
1520 | - do_action( 'AHEE__EE_Config__get_view__begin', $route, $status ); |
|
1521 | - if ( isset( EE_Config::$_module_view_map[ $key ][ $route ][ $status ] ) ) { |
|
1519 | + public static function get_view($route = null, $status = 0, $key = 'ee') { |
|
1520 | + do_action('AHEE__EE_Config__get_view__begin', $route, $status); |
|
1521 | + if (isset(EE_Config::$_module_view_map[$key][$route][$status])) { |
|
1522 | 1522 | return apply_filters( |
1523 | 1523 | 'FHEE__EE_Config__get_view', |
1524 | - EE_Config::$_module_view_map[ $key ][ $route ][ $status ], |
|
1524 | + EE_Config::$_module_view_map[$key][$route][$status], |
|
1525 | 1525 | $route, |
1526 | 1526 | $status |
1527 | 1527 | ); |
@@ -1532,7 +1532,7 @@ discard block |
||
1532 | 1532 | |
1533 | 1533 | |
1534 | 1534 | public function update_addon_option_names() { |
1535 | - update_option( EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names ); |
|
1535 | + update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names); |
|
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | |
@@ -1560,22 +1560,22 @@ discard block |
||
1560 | 1560 | * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned. |
1561 | 1561 | * @throws \EE_Error |
1562 | 1562 | */ |
1563 | - public function get_pretty( $property ) { |
|
1564 | - if ( ! property_exists( $this, $property ) ) { |
|
1563 | + public function get_pretty($property) { |
|
1564 | + if ( ! property_exists($this, $property)) { |
|
1565 | 1565 | throw new EE_Error( |
1566 | 1566 | sprintf( |
1567 | 1567 | __( |
1568 | 1568 | '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.', |
1569 | 1569 | 'event_espresso' |
1570 | 1570 | ), |
1571 | - get_class( $this ), |
|
1571 | + get_class($this), |
|
1572 | 1572 | $property |
1573 | 1573 | ) |
1574 | 1574 | ); |
1575 | 1575 | } |
1576 | 1576 | //just handling escaping of strings for now. |
1577 | - if ( is_string( $this->{$property} ) ) { |
|
1578 | - return stripslashes( $this->{$property} ); |
|
1577 | + if (is_string($this->{$property} )) { |
|
1578 | + return stripslashes($this->{$property} ); |
|
1579 | 1579 | } |
1580 | 1580 | return $this->{$property}; |
1581 | 1581 | } |
@@ -1584,17 +1584,17 @@ discard block |
||
1584 | 1584 | |
1585 | 1585 | public function populate() { |
1586 | 1586 | //grab defaults via a new instance of this class. |
1587 | - $class_name = get_class( $this ); |
|
1587 | + $class_name = get_class($this); |
|
1588 | 1588 | $defaults = new $class_name; |
1589 | 1589 | //loop through the properties for this class and see if they are set. If they are NOT, then grab the |
1590 | 1590 | //default from our $defaults object. |
1591 | - foreach ( get_object_vars( $defaults ) as $property => $value ) { |
|
1592 | - if ( $this->{$property} === null ) { |
|
1591 | + foreach (get_object_vars($defaults) as $property => $value) { |
|
1592 | + if ($this->{$property} === null) { |
|
1593 | 1593 | $this->{$property} = $value; |
1594 | 1594 | } |
1595 | 1595 | } |
1596 | 1596 | //cleanup |
1597 | - unset( $defaults ); |
|
1597 | + unset($defaults); |
|
1598 | 1598 | } |
1599 | 1599 | |
1600 | 1600 | |
@@ -1610,7 +1610,7 @@ discard block |
||
1610 | 1610 | * @param $a |
1611 | 1611 | * @return bool |
1612 | 1612 | */ |
1613 | - public function __isset( $a ) { |
|
1613 | + public function __isset($a) { |
|
1614 | 1614 | return false; |
1615 | 1615 | } |
1616 | 1616 | |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | * @param $a |
1623 | 1623 | * @return bool |
1624 | 1624 | */ |
1625 | - public function __unset( $a ) { |
|
1625 | + public function __unset($a) { |
|
1626 | 1626 | return false; |
1627 | 1627 | } |
1628 | 1628 | |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | $this->current_blog_id = get_current_blog_id(); |
1734 | 1734 | $this->current_blog_id = $this->current_blog_id === NULL ? 1 : $this->current_blog_id; |
1735 | 1735 | $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin(); |
1736 | - $this->ee_ueip_has_notified = is_main_site() ? get_option( 'ee_ueip_has_notified', false ) : true; |
|
1736 | + $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true; |
|
1737 | 1737 | $this->post_shortcodes = array(); |
1738 | 1738 | $this->module_route_map = array(); |
1739 | 1739 | $this->module_forward_map = array(); |
@@ -1749,9 +1749,9 @@ discard block |
||
1749 | 1749 | $this->thank_you_page_url = ''; |
1750 | 1750 | $this->cancel_page_url = ''; |
1751 | 1751 | //cpt slugs |
1752 | - $this->event_cpt_slug = __( 'events', 'event_espresso' ); |
|
1752 | + $this->event_cpt_slug = __('events', 'event_espresso'); |
|
1753 | 1753 | //ueip constant check |
1754 | - if ( defined( 'EE_DISABLE_UXIP' ) && EE_DISABLE_UXIP ) { |
|
1754 | + if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) { |
|
1755 | 1755 | $this->ee_ueip_optin = false; |
1756 | 1756 | $this->ee_ueip_has_notified = true; |
1757 | 1757 | } |
@@ -1794,11 +1794,11 @@ discard block |
||
1794 | 1794 | * @return string |
1795 | 1795 | */ |
1796 | 1796 | public function reg_page_url() { |
1797 | - if ( ! $this->reg_page_url ) { |
|
1797 | + if ( ! $this->reg_page_url) { |
|
1798 | 1798 | $this->reg_page_url = add_query_arg( |
1799 | - array( 'uts' => time() ), |
|
1800 | - get_permalink( $this->reg_page_id ) |
|
1801 | - ) . '#checkout'; |
|
1799 | + array('uts' => time()), |
|
1800 | + get_permalink($this->reg_page_id) |
|
1801 | + ).'#checkout'; |
|
1802 | 1802 | } |
1803 | 1803 | return $this->reg_page_url; |
1804 | 1804 | } |
@@ -1813,12 +1813,12 @@ discard block |
||
1813 | 1813 | * @access public |
1814 | 1814 | * @return string |
1815 | 1815 | */ |
1816 | - public function txn_page_url( $query_args = array() ) { |
|
1817 | - if ( ! $this->txn_page_url ) { |
|
1818 | - $this->txn_page_url = get_permalink( $this->txn_page_id ); |
|
1816 | + public function txn_page_url($query_args = array()) { |
|
1817 | + if ( ! $this->txn_page_url) { |
|
1818 | + $this->txn_page_url = get_permalink($this->txn_page_id); |
|
1819 | 1819 | } |
1820 | - if ( $query_args ) { |
|
1821 | - return add_query_arg( $query_args, $this->txn_page_url ); |
|
1820 | + if ($query_args) { |
|
1821 | + return add_query_arg($query_args, $this->txn_page_url); |
|
1822 | 1822 | } else { |
1823 | 1823 | return $this->txn_page_url; |
1824 | 1824 | } |
@@ -1834,12 +1834,12 @@ discard block |
||
1834 | 1834 | * @access public |
1835 | 1835 | * @return string |
1836 | 1836 | */ |
1837 | - public function thank_you_page_url( $query_args = array() ) { |
|
1838 | - if ( ! $this->thank_you_page_url ) { |
|
1839 | - $this->thank_you_page_url = get_permalink( $this->thank_you_page_id ); |
|
1837 | + public function thank_you_page_url($query_args = array()) { |
|
1838 | + if ( ! $this->thank_you_page_url) { |
|
1839 | + $this->thank_you_page_url = get_permalink($this->thank_you_page_id); |
|
1840 | 1840 | } |
1841 | - if ( $query_args ) { |
|
1842 | - return add_query_arg( $query_args, $this->thank_you_page_url ); |
|
1841 | + if ($query_args) { |
|
1842 | + return add_query_arg($query_args, $this->thank_you_page_url); |
|
1843 | 1843 | } else { |
1844 | 1844 | return $this->thank_you_page_url; |
1845 | 1845 | } |
@@ -1854,8 +1854,8 @@ discard block |
||
1854 | 1854 | * @return string |
1855 | 1855 | */ |
1856 | 1856 | public function cancel_page_url() { |
1857 | - if ( ! $this->cancel_page_url ) { |
|
1858 | - $this->cancel_page_url = get_permalink( $this->cancel_page_id ); |
|
1857 | + if ( ! $this->cancel_page_url) { |
|
1858 | + $this->cancel_page_url = get_permalink($this->cancel_page_id); |
|
1859 | 1859 | } |
1860 | 1860 | return $this->cancel_page_url; |
1861 | 1861 | } |
@@ -1884,22 +1884,22 @@ discard block |
||
1884 | 1884 | */ |
1885 | 1885 | protected function _get_main_ee_ueip_optin() { |
1886 | 1886 | //if this is the main site then we can just bypass our direct query. |
1887 | - if ( is_main_site() ) { |
|
1888 | - return get_option( 'ee_ueip_optin', false ); |
|
1887 | + if (is_main_site()) { |
|
1888 | + return get_option('ee_ueip_optin', false); |
|
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | //is this already cached for this request? If so use it. |
1892 | - if ( ! empty( EE_Core_Config::$ee_ueip_option ) ) { |
|
1892 | + if ( ! empty(EE_Core_Config::$ee_ueip_option)) { |
|
1893 | 1893 | return EE_Core_Config::$ee_ueip_option; |
1894 | 1894 | } |
1895 | 1895 | |
1896 | 1896 | global $wpdb; |
1897 | 1897 | $current_network_main_site = is_multisite() ? get_current_site() : null; |
1898 | - $current_main_site_id = ! empty( $current_network_main_site ) ? $current_network_main_site->blog_id : 1; |
|
1898 | + $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1; |
|
1899 | 1899 | $option = 'ee_ueip_optin'; |
1900 | 1900 | |
1901 | 1901 | //set correct table for query |
1902 | - $table_name = $wpdb->get_blog_prefix( $current_main_site_id ) . 'options'; |
|
1902 | + $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options'; |
|
1903 | 1903 | |
1904 | 1904 | |
1905 | 1905 | //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because |
@@ -1907,20 +1907,20 @@ discard block |
||
1907 | 1907 | //re-constructed on the blog switch. Note, we are still executing any core wp filters on this option retrieval. |
1908 | 1908 | //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog |
1909 | 1909 | //for the purpose of caching. |
1910 | - $pre = apply_filters( 'pre_option_' . $option, false, $option ); |
|
1911 | - if ( false !== $pre ) { |
|
1910 | + $pre = apply_filters('pre_option_'.$option, false, $option); |
|
1911 | + if (false !== $pre) { |
|
1912 | 1912 | EE_Core_Config::$ee_ueip_option = $pre; |
1913 | 1913 | return EE_Core_Config::$ee_ueip_option; |
1914 | 1914 | } |
1915 | 1915 | |
1916 | - $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option ) ); |
|
1917 | - if ( is_object( $row ) ) { |
|
1916 | + $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1", $option)); |
|
1917 | + if (is_object($row)) { |
|
1918 | 1918 | $value = $row->option_value; |
1919 | 1919 | } else { //option does not exist so use default. |
1920 | - return apply_filters( 'default_option_' . $option, false, $option ); |
|
1920 | + return apply_filters('default_option_'.$option, false, $option); |
|
1921 | 1921 | } |
1922 | 1922 | |
1923 | - EE_Core_Config::$ee_ueip_option = apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option ); |
|
1923 | + EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option); |
|
1924 | 1924 | return EE_Core_Config::$ee_ueip_option; |
1925 | 1925 | } |
1926 | 1926 | |
@@ -1936,7 +1936,7 @@ discard block |
||
1936 | 1936 | //reset all url properties |
1937 | 1937 | $this->_reset_urls(); |
1938 | 1938 | //return what to save to db |
1939 | - return array_keys( get_object_vars( $this ) ); |
|
1939 | + return array_keys(get_object_vars($this)); |
|
1940 | 1940 | } |
1941 | 1941 | |
1942 | 1942 | } |
@@ -2084,14 +2084,14 @@ discard block |
||
2084 | 2084 | */ |
2085 | 2085 | public function __construct() { |
2086 | 2086 | // set default organization settings |
2087 | - $this->name = get_bloginfo( 'name' ); |
|
2087 | + $this->name = get_bloginfo('name'); |
|
2088 | 2088 | $this->address_1 = '123 Onna Road'; |
2089 | 2089 | $this->address_2 = 'PO Box 123'; |
2090 | 2090 | $this->city = 'Inna City'; |
2091 | 2091 | $this->STA_ID = 4; |
2092 | 2092 | $this->CNT_ISO = 'US'; |
2093 | 2093 | $this->zip = '12345'; |
2094 | - $this->email = get_bloginfo( 'admin_email' ); |
|
2094 | + $this->email = get_bloginfo('admin_email'); |
|
2095 | 2095 | $this->phone = ''; |
2096 | 2096 | $this->vat = '123456789'; |
2097 | 2097 | $this->logo_url = ''; |
@@ -2179,44 +2179,44 @@ discard block |
||
2179 | 2179 | * @param string $CNT_ISO |
2180 | 2180 | * @return \EE_Currency_Config |
2181 | 2181 | */ |
2182 | - public function __construct( $CNT_ISO = '' ) { |
|
2182 | + public function __construct($CNT_ISO = '') { |
|
2183 | 2183 | // get country code from organization settings or use default |
2184 | - $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) |
|
2184 | + $ORG_CNT = isset(EE_Registry::instance()->CFG->organization) |
|
2185 | 2185 | && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
2186 | 2186 | ? EE_Registry::instance()->CFG->organization->CNT_ISO |
2187 | 2187 | : ''; |
2188 | 2188 | // but override if requested |
2189 | - $CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : $ORG_CNT; |
|
2189 | + $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT; |
|
2190 | 2190 | // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists |
2191 | 2191 | if ( |
2192 | - ! empty( $CNT_ISO ) |
|
2192 | + ! empty($CNT_ISO) |
|
2193 | 2193 | && EE_Maintenance_Mode::instance()->models_can_query() |
2194 | - && EEH_Activation::table_exists( EE_Registry::instance()->load_model( 'Country' )->table() ) |
|
2194 | + && EEH_Activation::table_exists(EE_Registry::instance()->load_model('Country')->table()) |
|
2195 | 2195 | ) { |
2196 | 2196 | // retrieve the country settings from the db, just in case they have been customized |
2197 | - $country = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $CNT_ISO ); |
|
2198 | - if ( $country instanceof EE_Country ) { |
|
2199 | - $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2200 | - $this->name = $country->currency_name_single(); // Dollar |
|
2201 | - $this->plural = $country->currency_name_plural(); // Dollars |
|
2202 | - $this->sign = $country->currency_sign(); // currency sign: $ |
|
2203 | - $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2204 | - $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2205 | - $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2206 | - $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2197 | + $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO); |
|
2198 | + if ($country instanceof EE_Country) { |
|
2199 | + $this->code = $country->currency_code(); // currency code: USD, CAD, EUR |
|
2200 | + $this->name = $country->currency_name_single(); // Dollar |
|
2201 | + $this->plural = $country->currency_name_plural(); // Dollars |
|
2202 | + $this->sign = $country->currency_sign(); // currency sign: $ |
|
2203 | + $this->sign_b4 = $country->currency_sign_before(); // currency sign before or after: $TRUE or FALSE$ |
|
2204 | + $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00 3 = 0.000 |
|
2205 | + $this->dec_mrk = $country->currency_decimal_mark(); // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2206 | + $this->thsnds = $country->currency_thousands_separator(); // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2207 | 2207 | } |
2208 | 2208 | } |
2209 | 2209 | // fallback to hardcoded defaults, in case the above failed |
2210 | - if ( empty( $this->code ) ) { |
|
2210 | + if (empty($this->code)) { |
|
2211 | 2211 | // set default currency settings |
2212 | - $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2213 | - $this->name = __( 'Dollar', 'event_espresso' ); // Dollar |
|
2214 | - $this->plural = __( 'Dollars', 'event_espresso' ); // Dollars |
|
2215 | - $this->sign = '$'; // currency sign: $ |
|
2216 | - $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2217 | - $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2218 | - $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2219 | - $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2212 | + $this->code = 'USD'; // currency code: USD, CAD, EUR |
|
2213 | + $this->name = __('Dollar', 'event_espresso'); // Dollar |
|
2214 | + $this->plural = __('Dollars', 'event_espresso'); // Dollars |
|
2215 | + $this->sign = '$'; // currency sign: $ |
|
2216 | + $this->sign_b4 = true; // currency sign before or after: $TRUE or FALSE$ |
|
2217 | + $this->dec_plc = 2; // decimal places: 2 = 0.00 3 = 0.000 |
|
2218 | + $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01 or (decimal) '.' = 0.01 |
|
2219 | + $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000 or (decimal) '.' = 1.000 |
|
2220 | 2220 | } |
2221 | 2221 | } |
2222 | 2222 | } |
@@ -2379,7 +2379,7 @@ discard block |
||
2379 | 2379 | * @since 4.8.8.rc.019 |
2380 | 2380 | */ |
2381 | 2381 | public function do_hooks() { |
2382 | - add_action( 'AHEE__EE_Config___load_core_config__end', array( $this, 'set_default_reg_status_on_EEM_Event' ) ); |
|
2382 | + add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event')); |
|
2383 | 2383 | } |
2384 | 2384 | |
2385 | 2385 | |
@@ -2388,7 +2388,7 @@ discard block |
||
2388 | 2388 | * @return void |
2389 | 2389 | */ |
2390 | 2390 | public function set_default_reg_status_on_EEM_Event() { |
2391 | - EEM_Event::set_default_reg_status( $this->default_STS_ID ); |
|
2391 | + EEM_Event::set_default_reg_status($this->default_STS_ID); |
|
2392 | 2392 | } |
2393 | 2393 | |
2394 | 2394 | |
@@ -2493,10 +2493,10 @@ discard block |
||
2493 | 2493 | * @param bool $reset |
2494 | 2494 | * @return string |
2495 | 2495 | */ |
2496 | - public function log_file_name( $reset = false ) { |
|
2497 | - if ( empty( $this->log_file_name ) || $reset ) { |
|
2498 | - $this->log_file_name = sanitize_key( 'espresso_log_' . md5( uniqid( '', true ) ) ) . '.txt'; |
|
2499 | - EE_Config::instance()->update_espresso_config( false, false ); |
|
2496 | + public function log_file_name($reset = false) { |
|
2497 | + if (empty($this->log_file_name) || $reset) { |
|
2498 | + $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt'; |
|
2499 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2500 | 2500 | } |
2501 | 2501 | return $this->log_file_name; |
2502 | 2502 | } |
@@ -2507,10 +2507,10 @@ discard block |
||
2507 | 2507 | * @param bool $reset |
2508 | 2508 | * @return string |
2509 | 2509 | */ |
2510 | - public function debug_file_name( $reset = false ) { |
|
2511 | - if ( empty( $this->debug_file_name ) || $reset ) { |
|
2512 | - $this->debug_file_name = sanitize_key( 'espresso_debug_' . md5( uniqid( '', true ) ) ) . '.txt'; |
|
2513 | - EE_Config::instance()->update_espresso_config( false, false ); |
|
2510 | + public function debug_file_name($reset = false) { |
|
2511 | + if (empty($this->debug_file_name) || $reset) { |
|
2512 | + $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt'; |
|
2513 | + EE_Config::instance()->update_espresso_config(false, false); |
|
2514 | 2514 | } |
2515 | 2515 | return $this->debug_file_name; |
2516 | 2516 | } |
@@ -2688,21 +2688,21 @@ discard block |
||
2688 | 2688 | $this->use_google_maps = true; |
2689 | 2689 | $this->google_map_api_key = ''; |
2690 | 2690 | // for event details pages (reg page) |
2691 | - $this->event_details_map_width = 585; // ee_map_width_single |
|
2692 | - $this->event_details_map_height = 362; // ee_map_height_single |
|
2693 | - $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2694 | - $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2695 | - $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2696 | - $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2697 | - $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2691 | + $this->event_details_map_width = 585; // ee_map_width_single |
|
2692 | + $this->event_details_map_height = 362; // ee_map_height_single |
|
2693 | + $this->event_details_map_zoom = 14; // ee_map_zoom_single |
|
2694 | + $this->event_details_display_nav = true; // ee_map_nav_display_single |
|
2695 | + $this->event_details_nav_size = false; // ee_map_nav_size_single |
|
2696 | + $this->event_details_control_type = 'default'; // ee_map_type_control_single |
|
2697 | + $this->event_details_map_align = 'center'; // ee_map_align_single |
|
2698 | 2698 | // for event list pages |
2699 | - $this->event_list_map_width = 300; // ee_map_width |
|
2700 | - $this->event_list_map_height = 185; // ee_map_height |
|
2701 | - $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2702 | - $this->event_list_display_nav = false; // ee_map_nav_display |
|
2703 | - $this->event_list_nav_size = true; // ee_map_nav_size |
|
2704 | - $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2705 | - $this->event_list_map_align = 'center'; // ee_map_align |
|
2699 | + $this->event_list_map_width = 300; // ee_map_width |
|
2700 | + $this->event_list_map_height = 185; // ee_map_height |
|
2701 | + $this->event_list_map_zoom = 12; // ee_map_zoom |
|
2702 | + $this->event_list_display_nav = false; // ee_map_nav_display |
|
2703 | + $this->event_list_nav_size = true; // ee_map_nav_size |
|
2704 | + $this->event_list_control_type = 'dropdown'; // ee_map_type_control |
|
2705 | + $this->event_list_map_align = 'center'; // ee_map_align |
|
2706 | 2706 | } |
2707 | 2707 | |
2708 | 2708 | } |
@@ -2855,7 +2855,7 @@ discard block |
||
2855 | 2855 | * @return void |
2856 | 2856 | */ |
2857 | 2857 | protected function _set_php_values() { |
2858 | - $this->php->max_input_vars = ini_get( 'max_input_vars' ); |
|
2858 | + $this->php->max_input_vars = ini_get('max_input_vars'); |
|
2859 | 2859 | $this->php->version = phpversion(); |
2860 | 2860 | } |
2861 | 2861 | |
@@ -2874,10 +2874,10 @@ discard block |
||
2874 | 2874 | * @type string $msg Any message to be displayed. |
2875 | 2875 | * } |
2876 | 2876 | */ |
2877 | - public function max_input_vars_limit_check( $input_count = 0 ) { |
|
2878 | - if ( ! empty( $this->php->max_input_vars ) |
|
2879 | - && ( $input_count >= $this->php->max_input_vars ) |
|
2880 | - && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
2877 | + public function max_input_vars_limit_check($input_count = 0) { |
|
2878 | + if ( ! empty($this->php->max_input_vars) |
|
2879 | + && ($input_count >= $this->php->max_input_vars) |
|
2880 | + && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9) |
|
2881 | 2881 | ) { |
2882 | 2882 | return sprintf( |
2883 | 2883 | __( |
@@ -2943,7 +2943,7 @@ discard block |
||
2943 | 2943 | */ |
2944 | 2944 | public function __construct() { |
2945 | 2945 | $this->payment_settings = array(); |
2946 | - $this->active_gateways = array( 'Invoice' => false ); |
|
2946 | + $this->active_gateways = array('Invoice' => false); |
|
2947 | 2947 | } |
2948 | 2948 | } |
2949 | 2949 |
@@ -70,26 +70,26 @@ discard block |
||
70 | 70 | * @param \EE_Line_Item $parent_line_item |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - public function display_line_item( EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null ) { |
|
73 | + public function display_line_item(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) { |
|
74 | 74 | |
75 | 75 | $html = ''; |
76 | 76 | // set some default options and merge with incoming |
77 | 77 | $default_options = array( |
78 | - 'show_desc' => true, // true false |
|
78 | + 'show_desc' => true, // true false |
|
79 | 79 | 'odd' => false |
80 | 80 | ); |
81 | - $options = array_merge( $default_options, (array)$options ); |
|
81 | + $options = array_merge($default_options, (array) $options); |
|
82 | 82 | |
83 | - switch( $line_item->type() ) { |
|
83 | + switch ($line_item->type()) { |
|
84 | 84 | |
85 | 85 | case EEM_Line_Item::type_line_item: |
86 | 86 | $this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes; |
87 | - if ( $line_item->OBJ_type() == 'Ticket' ) { |
|
87 | + if ($line_item->OBJ_type() == 'Ticket') { |
|
88 | 88 | // item row |
89 | - $html .= $this->_ticket_row( $line_item, $options ); |
|
89 | + $html .= $this->_ticket_row($line_item, $options); |
|
90 | 90 | } else { |
91 | 91 | // item row |
92 | - $html .= $this->_item_row( $line_item, $options ); |
|
92 | + $html .= $this->_item_row($line_item, $options); |
|
93 | 93 | } |
94 | 94 | if ( |
95 | 95 | apply_filters( |
@@ -98,76 +98,76 @@ discard block |
||
98 | 98 | ) |
99 | 99 | ) { |
100 | 100 | // got any kids? |
101 | - foreach ( $line_item->children() as $child_line_item ) { |
|
102 | - $html .= $this->display_line_item( $child_line_item, $options, $line_item ); |
|
101 | + foreach ($line_item->children() as $child_line_item) { |
|
102 | + $html .= $this->display_line_item($child_line_item, $options, $line_item); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | break; |
106 | 106 | |
107 | 107 | case EEM_Line_Item::type_sub_line_item: |
108 | - $html .= $this->_sub_item_row( $line_item, $options, $parent_line_item ); |
|
108 | + $html .= $this->_sub_item_row($line_item, $options, $parent_line_item); |
|
109 | 109 | break; |
110 | 110 | |
111 | 111 | case EEM_Line_Item::type_sub_total: |
112 | 112 | static $sub_total = 0; |
113 | 113 | $event_sub_total = 0; |
114 | - $text = __( 'Sub-Total', 'event_espresso' ); |
|
115 | - if ( $line_item->OBJ_type() == 'Event' ) { |
|
116 | - $options[ 'event_id' ] = $event_id = $line_item->OBJ_ID(); |
|
117 | - if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
118 | - $event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] ); |
|
119 | - if ( $event instanceof EE_Event ) { |
|
120 | - if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) { |
|
114 | + $text = __('Sub-Total', 'event_espresso'); |
|
115 | + if ($line_item->OBJ_type() == 'Event') { |
|
116 | + $options['event_id'] = $event_id = $line_item->OBJ_ID(); |
|
117 | + if ( ! isset($this->_events[$options['event_id']])) { |
|
118 | + $event = EEM_Event::instance()->get_one_by_ID($options['event_id']); |
|
119 | + if ($event instanceof EE_Event) { |
|
120 | + if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) { |
|
121 | 121 | return ''; |
122 | 122 | } |
123 | 123 | } |
124 | - $this->_events[ $options[ 'event_id' ] ] = 0; |
|
125 | - $html .= $this->_event_row( $line_item ); |
|
126 | - $text = __( 'Event Sub-Total', 'event_espresso' ); |
|
124 | + $this->_events[$options['event_id']] = 0; |
|
125 | + $html .= $this->_event_row($line_item); |
|
126 | + $text = __('Event Sub-Total', 'event_espresso'); |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | $child_line_items = $line_item->children(); |
130 | 130 | // loop thru children |
131 | - foreach( $child_line_items as $child_line_item ) { |
|
131 | + foreach ($child_line_items as $child_line_item) { |
|
132 | 132 | // recursively feed children back into this method |
133 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
133 | + $html .= $this->display_line_item($child_line_item, $options); |
|
134 | 134 | } |
135 | - $event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0; |
|
135 | + $event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0; |
|
136 | 136 | $sub_total += $event_sub_total; |
137 | 137 | if ( |
138 | 138 | ( |
139 | 139 | // event subtotals |
140 | 140 | $line_item->code() != 'pre-tax-subtotal' && |
141 | - count( $child_line_items ) > 1 |
|
141 | + count($child_line_items) > 1 |
|
142 | 142 | ) |
143 | 143 | || |
144 | 144 | ( |
145 | 145 | // pre-tax subtotals |
146 | 146 | $line_item->code() == 'pre-tax-subtotal' && |
147 | - count( $this->_events ) > 1 |
|
147 | + count($this->_events) > 1 |
|
148 | 148 | ) |
149 | 149 | ) { |
150 | 150 | $options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total; |
151 | - $html .= $this->_sub_total_row( $line_item, $text, $options ); |
|
151 | + $html .= $this->_sub_total_row($line_item, $text, $options); |
|
152 | 152 | } |
153 | 153 | break; |
154 | 154 | |
155 | 155 | case EEM_Line_Item::type_tax: |
156 | - if ( $this->_show_taxes ) { |
|
157 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
156 | + if ($this->_show_taxes) { |
|
157 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
158 | 158 | } |
159 | 159 | break; |
160 | 160 | |
161 | 161 | case EEM_Line_Item::type_tax_sub_total: |
162 | - if ( $this->_show_taxes ) { |
|
162 | + if ($this->_show_taxes) { |
|
163 | 163 | $child_line_items = $line_item->children(); |
164 | 164 | // loop thru children |
165 | - foreach( $child_line_items as $child_line_item ) { |
|
165 | + foreach ($child_line_items as $child_line_item) { |
|
166 | 166 | // recursively feed children back into this method |
167 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
167 | + $html .= $this->display_line_item($child_line_item, $options); |
|
168 | 168 | } |
169 | - if ( count( $child_line_items ) > 1 ) { |
|
170 | - $this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) ); |
|
169 | + if (count($child_line_items) > 1) { |
|
170 | + $this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso')); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | break; |
@@ -176,25 +176,25 @@ discard block |
||
176 | 176 | // get all child line items |
177 | 177 | $children = $line_item->children(); |
178 | 178 | // loop thru all non-tax child line items |
179 | - foreach( $children as $child_line_item ) { |
|
180 | - if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) { |
|
179 | + foreach ($children as $child_line_item) { |
|
180 | + if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) { |
|
181 | 181 | // recursively feed children back into this method |
182 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
182 | + $html .= $this->display_line_item($child_line_item, $options); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
186 | 186 | // now loop thru tax child line items |
187 | - foreach( $children as $child_line_item ) { |
|
188 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) { |
|
187 | + foreach ($children as $child_line_item) { |
|
188 | + if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) { |
|
189 | 189 | // recursively feed children back into this method |
190 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
190 | + $html .= $this->display_line_item($child_line_item, $options); |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | $html .= $this->_taxes_html; |
194 | - $html .= $this->_total_row( $line_item, __('Total', 'event_espresso') ); |
|
194 | + $html .= $this->_total_row($line_item, __('Total', 'event_espresso')); |
|
195 | 195 | |
196 | 196 | |
197 | - $html .= $this->_payments_and_amount_owing_rows( $line_item, $options ); |
|
197 | + $html .= $this->_payments_and_amount_owing_rows($line_item, $options); |
|
198 | 198 | break; |
199 | 199 | |
200 | 200 | } |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param EE_Line_Item $line_item |
210 | 210 | * @return mixed |
211 | 211 | */ |
212 | - private function _event_row( EE_Line_Item $line_item ) { |
|
212 | + private function _event_row(EE_Line_Item $line_item) { |
|
213 | 213 | // start of row |
214 | - $html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' ); |
|
214 | + $html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd'); |
|
215 | 215 | // event name td |
216 | - $html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' ); |
|
216 | + $html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"'); |
|
217 | 217 | // end of row |
218 | 218 | $html .= EEH_HTML::trx(); |
219 | 219 | return $html; |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * @param array $options |
229 | 229 | * @return mixed |
230 | 230 | */ |
231 | - private function _ticket_row( EE_Line_Item $line_item, $options = array() ) { |
|
231 | + private function _ticket_row(EE_Line_Item $line_item, $options = array()) { |
|
232 | 232 | // start of row |
233 | 233 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
234 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
234 | + $html = EEH_HTML::tr('', '', $row_class); |
|
235 | 235 | // name && desc |
236 | 236 | $name_and_desc = apply_filters( |
237 | 237 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
@@ -240,23 +240,23 @@ discard block |
||
240 | 240 | ); |
241 | 241 | $name_and_desc .= apply_filters( |
242 | 242 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
243 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
243 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
244 | 244 | $line_item, |
245 | 245 | $options |
246 | 246 | ); |
247 | 247 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
248 | 248 | // name td |
249 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
249 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' ); |
|
250 | 250 | // price td |
251 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
251 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
252 | 252 | // quantity td |
253 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
253 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
254 | 254 | $this->_total_items += $line_item->quantity(); |
255 | 255 | // determine total for line item |
256 | 256 | $total = $line_item->total(); |
257 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
257 | + $this->_events[$options['event_id']] += $total; |
|
258 | 258 | // total td |
259 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
259 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
260 | 260 | // end of row |
261 | 261 | $html .= EEH_HTML::trx(); |
262 | 262 | return $html; |
@@ -271,41 +271,41 @@ discard block |
||
271 | 271 | * @param array $options |
272 | 272 | * @return mixed |
273 | 273 | */ |
274 | - private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
274 | + private function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
275 | 275 | // start of row |
276 | 276 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
277 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
278 | - $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() . ': ' : ''; |
|
277 | + $html = EEH_HTML::tr('', '', $row_class); |
|
278 | + $obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n().': ' : ''; |
|
279 | 279 | // name && desc |
280 | 280 | $name_and_desc = apply_filters( |
281 | 281 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name', |
282 | - $obj_name . $line_item->name(), |
|
282 | + $obj_name.$line_item->name(), |
|
283 | 283 | $line_item |
284 | 284 | ); |
285 | 285 | $name_and_desc .= apply_filters( |
286 | 286 | 'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', |
287 | - ( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ), |
|
287 | + ($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''), |
|
288 | 288 | $line_item, |
289 | 289 | $options |
290 | 290 | ); |
291 | 291 | $name_and_desc .= $line_item->is_taxable() ? ' * ' : ''; |
292 | 292 | // name td |
293 | - $html .= EEH_HTML::td( $name_and_desc, '', 'item_l' ); |
|
293 | + $html .= EEH_HTML::td($name_and_desc, '', 'item_l'); |
|
294 | 294 | // price td |
295 | - if ( $line_item->is_percent() ) { |
|
296 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' ); |
|
295 | + if ($line_item->is_percent()) { |
|
296 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght'); |
|
297 | 297 | } else { |
298 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
298 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
299 | 299 | } |
300 | 300 | // quantity td |
301 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
|
301 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght'); |
|
302 | 302 | //$total = $line_item->total() * $line_item->quantity(); |
303 | 303 | $total = $line_item->total(); |
304 | - if( isset( $options[ 'event_id' ] ) && isset( $this->_events[ $options[ 'event_id' ] ] ) ) { |
|
305 | - $this->_events[ $options[ 'event_id' ] ] += $total; |
|
304 | + if (isset($options['event_id']) && isset($this->_events[$options['event_id']])) { |
|
305 | + $this->_events[$options['event_id']] += $total; |
|
306 | 306 | } |
307 | 307 | // total td |
308 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '', 'item_r jst-rght' ); |
|
308 | + $html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght'); |
|
309 | 309 | // end of row |
310 | 310 | $html .= EEH_HTML::trx(); |
311 | 311 | return $html; |
@@ -321,25 +321,25 @@ discard block |
||
321 | 321 | * @param \EE_Line_Item $parent_line_item |
322 | 322 | * @return mixed |
323 | 323 | */ |
324 | - private function _sub_item_row( EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null ) { |
|
324 | + private function _sub_item_row(EE_Line_Item $line_item, $options = array(), EE_Line_Item $parent_line_item = null) { |
|
325 | 325 | // start of row |
326 | - $html = EEH_HTML::tr( '', '', 'item sub-item-row' ); |
|
326 | + $html = EEH_HTML::tr('', '', 'item sub-item-row'); |
|
327 | 327 | // name && desc |
328 | - $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right' ) . $line_item->name(); |
|
329 | - $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : ''; |
|
328 | + $name_and_desc = EEH_HTML::span('', '', 'sub-item-row-bullet dashicons dashicons-arrow-right').$line_item->name(); |
|
329 | + $name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''; |
|
330 | 330 | // name td |
331 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
331 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
332 | 332 | // discount/surcharge td |
333 | - if ( $line_item->is_percent() ) { |
|
333 | + if ($line_item->is_percent()) { |
|
334 | 334 | $html .= EEH_HTML::td( |
335 | 335 | EEH_Template::format_currency( |
336 | 336 | $line_item->total() / $parent_line_item->quantity(), |
337 | 337 | false, false |
338 | 338 | ), |
339 | - '', 'item_c jst-rght' |
|
339 | + '', 'item_c jst-rght' |
|
340 | 340 | ); |
341 | 341 | } else { |
342 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' ); |
|
342 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght'); |
|
343 | 343 | } |
344 | 344 | // no quantity td |
345 | 345 | $html .= EEH_HTML::td(); |
@@ -359,21 +359,21 @@ discard block |
||
359 | 359 | * @param array $options |
360 | 360 | * @return mixed |
361 | 361 | */ |
362 | - private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
362 | + private function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
363 | 363 | // start of row |
364 | - $html = EEH_HTML::tr( '', 'item sub-item tax-total' ); |
|
364 | + $html = EEH_HTML::tr('', 'item sub-item tax-total'); |
|
365 | 365 | // name && desc |
366 | 366 | $name_and_desc = $line_item->name(); |
367 | - $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>'; |
|
368 | - $name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : ''; |
|
367 | + $name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>'; |
|
368 | + $name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : ''; |
|
369 | 369 | // name td |
370 | - $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
370 | + $html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' ); |
|
371 | 371 | // percent td |
372 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', ' jst-rght', '' ); |
|
372 | + $html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', ''); |
|
373 | 373 | // empty td (price) |
374 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
374 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
375 | 375 | // total td |
376 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'item_r jst-rght' ); |
|
376 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght'); |
|
377 | 377 | // end of row |
378 | 378 | $html .= EEH_HTML::trx(); |
379 | 379 | return $html; |
@@ -388,17 +388,17 @@ discard block |
||
388 | 388 | * @param string $text |
389 | 389 | * @return mixed |
390 | 390 | */ |
391 | - private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) { |
|
391 | + private function _total_tax_row(EE_Line_Item $line_item, $text = '') { |
|
392 | 392 | $html = ''; |
393 | - if ( $line_item->total() ) { |
|
393 | + if ($line_item->total()) { |
|
394 | 394 | // start of row |
395 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
395 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
396 | 396 | // total td |
397 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' ); |
|
397 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"'); |
|
398 | 398 | // empty td (price) |
399 | - $html .= EEH_HTML::td( EEH_HTML::nbsp() ); |
|
399 | + $html .= EEH_HTML::td(EEH_HTML::nbsp()); |
|
400 | 400 | // total td |
401 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
401 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
402 | 402 | // end of row |
403 | 403 | $html .= EEH_HTML::trx(); |
404 | 404 | } |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * @param array $options |
416 | 416 | * @return mixed |
417 | 417 | */ |
418 | - private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
418 | + private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
419 | 419 | $html = ''; |
420 | - if ( $line_item->total() ) { |
|
420 | + if ($line_item->total()) { |
|
421 | 421 | // start of row |
422 | - $html = EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
422 | + $html = EEH_HTML::tr('', '', 'total_tr odd'); |
|
423 | 423 | // total td |
424 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
424 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
425 | 425 | // total td |
426 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' ); |
|
426 | + $html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght'); |
|
427 | 427 | // end of row |
428 | 428 | $html .= EEH_HTML::trx(); |
429 | 429 | } |
@@ -440,13 +440,13 @@ discard block |
||
440 | 440 | * @param string $text |
441 | 441 | * @return mixed |
442 | 442 | */ |
443 | - private function _total_row( EE_Line_Item $line_item, $text = '' ) { |
|
443 | + private function _total_row(EE_Line_Item $line_item, $text = '') { |
|
444 | 444 | // start of row |
445 | - $html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' ); |
|
445 | + $html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd'); |
|
446 | 446 | // total td |
447 | - $html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' ); |
|
447 | + $html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"'); |
|
448 | 448 | // total td |
449 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' ); |
|
449 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght'); |
|
450 | 450 | // end of row |
451 | 451 | $html .= EEH_HTML::trx(); |
452 | 452 | return $html; |
@@ -461,30 +461,30 @@ discard block |
||
461 | 461 | * @param array $options |
462 | 462 | * @return mixed |
463 | 463 | */ |
464 | - private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) { |
|
464 | + private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) { |
|
465 | 465 | $html = ''; |
466 | 466 | $owing = $line_item->total(); |
467 | - $transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() ); |
|
468 | - if ( $transaction instanceof EE_Transaction ) { |
|
467 | + $transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID()); |
|
468 | + if ($transaction instanceof EE_Transaction) { |
|
469 | 469 | $registration_payments = array(); |
470 | - $registrations = ! empty( $options['registrations'] ) |
|
471 | - ? $options[ 'registrations' ] |
|
470 | + $registrations = ! empty($options['registrations']) |
|
471 | + ? $options['registrations'] |
|
472 | 472 | : $transaction->registrations(); |
473 | - foreach ( $registrations as $registration ) { |
|
474 | - if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) { |
|
473 | + foreach ($registrations as $registration) { |
|
474 | + if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) { |
|
475 | 475 | $registration_payments = $registration_payments + $registration->registration_payments(); |
476 | 476 | } |
477 | 477 | } |
478 | - if ( ! empty( $registration_payments )) { |
|
479 | - foreach ( $registration_payments as $registration_payment ) { |
|
480 | - if ( $registration_payment instanceof EE_Registration_Payment ) { |
|
478 | + if ( ! empty($registration_payments)) { |
|
479 | + foreach ($registration_payments as $registration_payment) { |
|
480 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
481 | 481 | $owing = $owing - $registration_payment->amount(); |
482 | 482 | $payment = $registration_payment->payment(); |
483 | - if ( $payment instanceof EE_Payment ) { |
|
483 | + if ($payment instanceof EE_Payment) { |
|
484 | 484 | $payment_desc = sprintf( |
485 | - __( 'Payment%1$s Received: %2$s', 'event_espresso' ), |
|
485 | + __('Payment%1$s Received: %2$s', 'event_espresso'), |
|
486 | 486 | $payment->txn_id_chq_nmbr() != '' |
487 | - ? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> ' |
|
487 | + ? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> ' |
|
488 | 488 | : '', |
489 | 489 | $payment->timestamp() |
490 | 490 | ); |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | $payment_desc = ''; |
493 | 493 | } |
494 | 494 | // start of row |
495 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
495 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
496 | 496 | // payment desc |
497 | - $html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' ); |
|
497 | + $html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"'); |
|
498 | 498 | // total td |
499 | 499 | $html .= EEH_HTML::td( |
500 | - EEH_Template::format_currency( $registration_payment->amount(), false, false ), |
|
500 | + EEH_Template::format_currency($registration_payment->amount(), false, false), |
|
501 | 501 | '', |
502 | 502 | 'total jst-rght' |
503 | 503 | ); |
@@ -505,17 +505,17 @@ discard block |
||
505 | 505 | $html .= EEH_HTML::trx(); |
506 | 506 | } |
507 | 507 | } |
508 | - if ( $line_item->total() ) { |
|
508 | + if ($line_item->total()) { |
|
509 | 509 | // start of row |
510 | - $html .= EEH_HTML::tr( '', '', 'total_tr odd' ); |
|
510 | + $html .= EEH_HTML::tr('', '', 'total_tr odd'); |
|
511 | 511 | // total td |
512 | 512 | $html .= EEH_HTML::td( |
513 | 513 | __('Amount Owing', 'event_espresso'), |
514 | - '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
514 | + '', 'total_currency total jst-rght', '', ' colspan="3"' |
|
515 | 515 | ); |
516 | 516 | // total td |
517 | 517 | $html .= EEH_HTML::td( |
518 | - EEH_Template::format_currency( $owing, false, false ), '', 'total jst-rght' |
|
518 | + EEH_Template::format_currency($owing, false, false), '', 'total jst-rght' |
|
519 | 519 | ); |
520 | 520 | // end of row |
521 | 521 | $html .= EEH_HTML::trx(); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | |
45 | -if ( function_exists( 'espresso_version' ) ) { |
|
45 | +if (function_exists('espresso_version')) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function espresso_duplicate_plugin_error() { |
52 | 52 | ?> |
53 | 53 | <div class="error"> |
54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
55 | 55 | </div> |
56 | 56 | <?php |
57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
58 | 58 | } |
59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
@@ -67,103 +67,103 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | */ |
69 | 69 | function espresso_version() { |
70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.10.rc.006' ); |
|
70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.10.rc.006'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // define versions |
74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
79 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
80 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
79 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
80 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
81 | 81 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
82 | - if ( ! defined( 'DS' ) ) { |
|
83 | - define( 'DS', '/' ); |
|
82 | + if ( ! defined('DS')) { |
|
83 | + define('DS', '/'); |
|
84 | 84 | } |
85 | - if ( ! defined( 'PS' ) ) { |
|
86 | - define( 'PS', PATH_SEPARATOR ); |
|
85 | + if ( ! defined('PS')) { |
|
86 | + define('PS', PATH_SEPARATOR); |
|
87 | 87 | } |
88 | - if ( ! defined( 'SP' ) ) { |
|
89 | - define( 'SP', ' ' ); |
|
88 | + if ( ! defined('SP')) { |
|
89 | + define('SP', ' '); |
|
90 | 90 | } |
91 | - if ( ! defined( 'EENL' ) ) { |
|
92 | - define( 'EENL', "\n" ); |
|
91 | + if ( ! defined('EENL')) { |
|
92 | + define('EENL', "\n"); |
|
93 | 93 | } |
94 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
94 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
95 | 95 | // define the plugin directory and URL |
96 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
98 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
99 | 99 | // main root folder paths |
100 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
101 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
102 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
103 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
104 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
105 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
106 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
107 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
100 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
101 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
102 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
103 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
104 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
105 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
106 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
107 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
108 | 108 | // core system paths |
109 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
110 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
111 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
112 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
113 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
114 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
115 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
116 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
117 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
118 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
119 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
120 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
109 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
110 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
111 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
112 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
113 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
114 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
115 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
116 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
117 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
118 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
119 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
120 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
121 | 121 | // gateways |
122 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
123 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
122 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
123 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
124 | 124 | // asset URL paths |
125 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
126 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
127 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
128 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
129 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
130 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
125 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
126 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
127 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
128 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
129 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
130 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
131 | 131 | // define upload paths |
132 | 132 | $uploads = wp_upload_dir(); |
133 | 133 | // define the uploads directory and URL |
134 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
135 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
135 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
136 | 136 | // define the templates directory and URL |
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
138 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
138 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
139 | 139 | // define the gateway directory and URL |
140 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
141 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
142 | 142 | // languages folder/path |
143 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
144 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
143 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
144 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
145 | 145 | //check for dompdf fonts in uploads |
146 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
147 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
146 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
147 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
148 | 148 | } |
149 | 149 | //ajax constants |
150 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
151 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
150 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
151 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
152 | 152 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
153 | 153 | //you're better to use this than its straight value (currently -1) in case you ever |
154 | 154 | //want to change its default value! or find when -1 means infinity |
155 | - define( 'EE_INF_IN_DB', -1 ); |
|
156 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
157 | - define( 'EE_DEBUG', false ); |
|
155 | + define('EE_INF_IN_DB', -1); |
|
156 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
157 | + define('EE_DEBUG', false); |
|
158 | 158 | |
159 | 159 | /** |
160 | 160 | * espresso_plugin_activation |
161 | 161 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
162 | 162 | */ |
163 | 163 | function espresso_plugin_activation() { |
164 | - update_option( 'ee_espresso_activation', true ); |
|
164 | + update_option('ee_espresso_activation', true); |
|
165 | 165 | } |
166 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
166 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
167 | 167 | |
168 | 168 | |
169 | 169 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | // } |
178 | 178 | // |
179 | 179 | } |
180 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
180 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
181 | 181 | |
182 | 182 | |
183 | 183 | |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function espresso_load_error_handling() { |
189 | 189 | // load debugging tools |
190 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
191 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
190 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
191 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
192 | 192 | EEH_Debug_Tools::instance(); |
193 | 193 | } |
194 | 194 | // load error handling |
195 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
196 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
195 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
196 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
197 | 197 | } else { |
198 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
198 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -209,25 +209,25 @@ discard block |
||
209 | 209 | * @param string $full_path_to_file |
210 | 210 | * @throws EE_Error |
211 | 211 | */ |
212 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
212 | + function espresso_load_required($classname, $full_path_to_file) { |
|
213 | 213 | static $error_handling_loaded = false; |
214 | - if ( ! $error_handling_loaded ) { |
|
214 | + if ( ! $error_handling_loaded) { |
|
215 | 215 | espresso_load_error_handling(); |
216 | 216 | $error_handling_loaded = true; |
217 | 217 | } |
218 | - if ( is_readable( $full_path_to_file ) ) { |
|
219 | - require_once( $full_path_to_file ); |
|
218 | + if (is_readable($full_path_to_file)) { |
|
219 | + require_once($full_path_to_file); |
|
220 | 220 | } else { |
221 | - throw new EE_Error ( sprintf( |
|
222 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
221 | + throw new EE_Error(sprintf( |
|
222 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
223 | 223 | $classname |
224 | - ) ); |
|
224 | + )); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
229 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
230 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
228 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
229 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
230 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
231 | 231 | new EE_Bootstrap(); |
232 | 232 | |
233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | |
238 | 238 | |
239 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
239 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
240 | 240 | /** |
241 | 241 | * deactivate_plugin |
242 | 242 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
249 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
250 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
248 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
249 | + if ( ! function_exists('deactivate_plugins')) { |
|
250 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
251 | 251 | } |
252 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
253 | - deactivate_plugins( $plugin_basename ); |
|
252 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
253 | + deactivate_plugins($plugin_basename); |
|
254 | 254 | } |
255 | 255 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,36 +35,36 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_reserved'=>new EE_Integer_Field('TKT_reserved', __('Quantity of this ticket that is reserved, but not yet fully purchased','event_espresso'), false, 0 ), |
|
59 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
60 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
61 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
62 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_reserved'=>new EE_Integer_Field('TKT_reserved', __('Quantity of this ticket that is reserved, but not yet fully purchased', 'event_espresso'), false, 0), |
|
59 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
60 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
61 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
62 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
63 | 63 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
64 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
64 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
65 | 65 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
66 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
67 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
66 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
67 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
68 | 68 | )); |
69 | 69 | $this->_model_relations = array( |
70 | 70 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | ); |
77 | 77 | |
78 | 78 | //this model is generally available for reading |
79 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
80 | 80 | //account for default tickets in the caps |
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
84 | - parent::__construct( $timezone ); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
84 | + parent::__construct($timezone); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public function get_all_default_tickets() { |
94 | 94 | /** @type EE_Ticket[] $tickets */ |
95 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
95 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
96 | 96 | //we need to set the start date and end date to today's date and the start of the default dtt |
97 | - return $this->_set_default_dates( $tickets ); |
|
97 | + return $this->_set_default_dates($tickets); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @param EE_Ticket[] $tickets |
105 | 105 | * @return EE_Ticket[] |
106 | 106 | */ |
107 | - private function _set_default_dates( $tickets ) { |
|
108 | - foreach ( $tickets as $ticket ) { |
|
109 | - $ticket->set('TKT_start_date', (int)$this->current_time_for_query('TKT_start_date', true) ); |
|
110 | - $ticket->set('TKT_end_date', (int)$this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
111 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
107 | + private function _set_default_dates($tickets) { |
|
108 | + foreach ($tickets as $ticket) { |
|
109 | + $ticket->set('TKT_start_date', (int) $this->current_time_for_query('TKT_start_date', true)); |
|
110 | + $ticket->set('TKT_end_date', (int) $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
111 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | return $tickets; |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param array $query_params |
124 | 124 | * @return int |
125 | 125 | */ |
126 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
127 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
126 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
127 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @param EE_Ticket[] $tickets |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - public function update_tickets_sold($tickets){ |
|
138 | - foreach($tickets as $ticket){ |
|
137 | + public function update_tickets_sold($tickets) { |
|
138 | + foreach ($tickets as $ticket) { |
|
139 | 139 | /* @var $ticket EE_Ticket */ |
140 | 140 | $ticket->update_tickets_sold(); |
141 | 141 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Datetime.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Datetime.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Datetime extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,28 +35,28 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Datetime','event_espresso'); |
|
40 | - $this->plural_item = __('Datetimes','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Datetime', 'event_espresso'); |
|
40 | + $this->plural_item = __('Datetimes', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Datetime'=>array( |
47 | - 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')), |
|
48 | - 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'), |
|
47 | + 'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')), |
|
48 | + 'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'), |
|
49 | 49 | 'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''), |
50 | 50 | 'DTT_description' => new EE_Post_Content_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''), |
51 | - 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
52 | - 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
53 | - 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF), |
|
54 | - 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ), |
|
55 | - 'DTT_reserved' => new EE_Integer_Field('DTT_reserved',__('Quantity of tickets that are reserved, but not yet fully purchased','event_espresso'),false,0), |
|
56 | - 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false), |
|
51 | + 'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
52 | + 'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
53 | + 'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF), |
|
54 | + 'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0), |
|
55 | + 'DTT_reserved' => new EE_Integer_Field('DTT_reserved', __('Quantity of tickets that are reserved, but not yet fully purchased', 'event_espresso'), false, 0), |
|
56 | + 'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false), |
|
57 | 57 | 'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0), |
58 | - 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ), |
|
59 | - 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ), |
|
58 | + 'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0), |
|
59 | + 'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false), |
|
60 | 60 | )); |
61 | 61 | $this->_model_relations = array( |
62 | 62 | 'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | ); |
66 | 66 | $this->_model_chain_to_wp_user = 'Event'; |
67 | 67 | //this model is generally available for reading |
68 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' ); |
|
69 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
70 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' ); |
|
71 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit ); |
|
72 | - parent::__construct( $timezone ); |
|
68 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event'); |
|
69 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
70 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event'); |
|
71 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit); |
|
72 | + parent::__construct($timezone); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | public function create_new_blank_datetime() { |
85 | 85 | $blank_datetime = EE_Datetime::new_instance( |
86 | 86 | array( |
87 | - 'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30), |
|
88 | - 'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30), |
|
87 | + 'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30), |
|
88 | + 'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30), |
|
89 | 89 | 'DTT_order' => 1, |
90 | 90 | 'DTT_reg_limit' => EE_INF |
91 | 91 | ), |
92 | 92 | $this->_timezone |
93 | 93 | ); |
94 | - $blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) ); |
|
95 | - $blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) ); |
|
96 | - return array( $blank_datetime ); |
|
94 | + $blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone)); |
|
95 | + $blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone)); |
|
96 | + return array($blank_datetime); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param int $EVT_ID |
108 | 108 | * @return EE_Datetime[] array on success, FALSE on fail |
109 | 109 | */ |
110 | - public function get_all_event_dates( $EVT_ID = 0 ) { |
|
111 | - if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0 |
|
110 | + public function get_all_event_dates($EVT_ID = 0) { |
|
111 | + if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0 |
|
112 | 112 | return $this->create_new_blank_datetime(); |
113 | 113 | } |
114 | - $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
114 | + $results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID); |
|
115 | 115 | |
116 | - if ( empty( $results ) ) { |
|
116 | + if (empty($results)) { |
|
117 | 117 | return $this->create_new_blank_datetime(); |
118 | 118 | } |
119 | 119 | |
@@ -134,26 +134,26 @@ discard block |
||
134 | 134 | * the given number |
135 | 135 | * @return EE_Datetime[] |
136 | 136 | */ |
137 | - public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL ) { |
|
137 | + public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) { |
|
138 | 138 | |
139 | 139 | //sanitize EVT_ID |
140 | - $EVT_ID = intval( $EVT_ID ); |
|
140 | + $EVT_ID = intval($EVT_ID); |
|
141 | 141 | |
142 | 142 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
143 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
144 | - $where_params = array( 'Event.EVT_ID' => $EVT_ID ); |
|
143 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
144 | + $where_params = array('Event.EVT_ID' => $EVT_ID); |
|
145 | 145 | |
146 | - $query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ); |
|
146 | + $query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none'); |
|
147 | 147 | |
148 | - if( ! $include_expired){ |
|
149 | - $query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) ); |
|
148 | + if ( ! $include_expired) { |
|
149 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
150 | 150 | } |
151 | - if( $include_deleted){ |
|
152 | - $query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE )); |
|
151 | + if ($include_deleted) { |
|
152 | + $query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE)); |
|
153 | 153 | } |
154 | 154 | |
155 | - $result = $this->get_all( $query_params ); |
|
156 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
155 | + $result = $this->get_all($query_params); |
|
156 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
157 | 157 | return $result; |
158 | 158 | } |
159 | 159 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param int $limit |
169 | 169 | * @return EE_Datetime[] |
170 | 170 | */ |
171 | - public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){ |
|
172 | - return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID), |
|
171 | + public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) { |
|
172 | + return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID), |
|
173 | 173 | 'limit'=>$limit, |
174 | 174 | 'order_by'=>array('DTT_EVT_start'=>'ASC'), |
175 | 175 | 'default_where_conditions' => 'none')); |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @param boolean $include_deleted |
185 | 185 | * @return EE_Datetime |
186 | 186 | */ |
187 | - public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){ |
|
188 | - $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | - if($results){ |
|
187 | + public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) { |
|
188 | + $results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1); |
|
189 | + if ($results) { |
|
190 | 190 | return array_shift($results); |
191 | - }else{ |
|
191 | + } else { |
|
192 | 192 | return NULL; |
193 | 193 | } |
194 | 194 | } |
@@ -202,16 +202,16 @@ discard block |
||
202 | 202 | * @param bool $try_to_exclude_deleted |
203 | 203 | * @return \EE_Datetime |
204 | 204 | */ |
205 | - public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){ |
|
206 | - if($try_to_exclude_expired){ |
|
207 | - $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false); |
|
208 | - if($non_expired){ |
|
205 | + public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) { |
|
206 | + if ($try_to_exclude_expired) { |
|
207 | + $non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false); |
|
208 | + if ($non_expired) { |
|
209 | 209 | return $non_expired; |
210 | 210 | } |
211 | 211 | } |
212 | - if($try_to_exclude_deleted){ |
|
212 | + if ($try_to_exclude_deleted) { |
|
213 | 213 | $expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true); |
214 | - if($expired_even){ |
|
214 | + if ($expired_even) { |
|
215 | 215 | return $expired_even; |
216 | 216 | } |
217 | 217 | } |
@@ -230,23 +230,23 @@ discard block |
||
230 | 230 | * @param int $limit |
231 | 231 | * @return EE_Datetime[] |
232 | 232 | */ |
233 | - public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){ |
|
233 | + public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
234 | 234 | //sanitize EVT_ID |
235 | - $EVT_ID = intval( $EVT_ID ); |
|
235 | + $EVT_ID = intval($EVT_ID); |
|
236 | 236 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
237 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
238 | - $query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | - if( ! $include_expired){ |
|
240 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
237 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
238 | + $query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
239 | + if ( ! $include_expired) { |
|
240 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
241 | 241 | } |
242 | - if( $include_deleted){ |
|
243 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
242 | + if ($include_deleted) { |
|
243 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
244 | 244 | } |
245 | - if($limit){ |
|
245 | + if ($limit) { |
|
246 | 246 | $query_params['limit'] = $limit; |
247 | 247 | } |
248 | - $result = $this->get_all( $query_params ); |
|
249 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
248 | + $result = $this->get_all($query_params); |
|
249 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
250 | 250 | return $result; |
251 | 251 | } |
252 | 252 | |
@@ -259,23 +259,23 @@ discard block |
||
259 | 259 | * @param int $limit |
260 | 260 | * @return EE_Datetime[] |
261 | 261 | */ |
262 | - public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){ |
|
262 | + public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
263 | 263 | //sanitize TKT_ID |
264 | - $TKT_ID = intval( $TKT_ID ); |
|
264 | + $TKT_ID = intval($TKT_ID); |
|
265 | 265 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
266 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
267 | - $query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | - if( ! $include_expired){ |
|
269 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
266 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
267 | + $query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc')); |
|
268 | + if ( ! $include_expired) { |
|
269 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
270 | 270 | } |
271 | - if( $include_deleted){ |
|
272 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
271 | + if ($include_deleted) { |
|
272 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
273 | 273 | } |
274 | - if($limit){ |
|
274 | + if ($limit) { |
|
275 | 275 | $query_params['limit'] = $limit; |
276 | 276 | } |
277 | - $result = $this->get_all( $query_params ); |
|
278 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
277 | + $result = $this->get_all($query_params); |
|
278 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
279 | 279 | return $result; |
280 | 280 | } |
281 | 281 | |
@@ -291,24 +291,24 @@ discard block |
||
291 | 291 | * that number |
292 | 292 | * @return EE_Datetime[] |
293 | 293 | */ |
294 | - public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) { |
|
294 | + public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) { |
|
295 | 295 | //sanitize id. |
296 | - $TKT_ID = intval( $TKT_ID ); |
|
296 | + $TKT_ID = intval($TKT_ID); |
|
297 | 297 | $old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object(); |
298 | - $this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db ); |
|
299 | - $where_params = array( 'Ticket.TKT_ID' => $TKT_ID ); |
|
300 | - $query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) ); |
|
301 | - if( ! $include_expired){ |
|
302 | - $query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE)); |
|
298 | + $this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db); |
|
299 | + $where_params = array('Ticket.TKT_ID' => $TKT_ID); |
|
300 | + $query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC')); |
|
301 | + if ( ! $include_expired) { |
|
302 | + $query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE)); |
|
303 | 303 | } |
304 | - if( $include_deleted){ |
|
305 | - $query_params[0]['DTT_deleted'] = array('IN',array(true,false)); |
|
304 | + if ($include_deleted) { |
|
305 | + $query_params[0]['DTT_deleted'] = array('IN', array(true, false)); |
|
306 | 306 | } |
307 | - if($limit){ |
|
307 | + if ($limit) { |
|
308 | 308 | $query_params['limit'] = $limit; |
309 | 309 | } |
310 | - $result = $this->get_all( $query_params ); |
|
311 | - $this->assume_values_already_prepared_by_model_object( $old_assumption ); |
|
310 | + $result = $this->get_all($query_params); |
|
311 | + $this->assume_values_already_prepared_by_model_object($old_assumption); |
|
312 | 312 | return $result; |
313 | 313 | } |
314 | 314 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | * @param int $EVT_ID |
320 | 320 | * @return EE_Datetime |
321 | 321 | */ |
322 | - public function get_most_important_datetime_for_event($EVT_ID){ |
|
322 | + public function get_most_important_datetime_for_event($EVT_ID) { |
|
323 | 323 | $results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1); |
324 | - if($results){ |
|
324 | + if ($results) { |
|
325 | 325 | return array_shift($results); |
326 | - }else{ |
|
326 | + } else { |
|
327 | 327 | return null; |
328 | 328 | } |
329 | 329 | } |
@@ -342,77 +342,77 @@ discard block |
||
342 | 342 | * - inactive = Events that are either not published. |
343 | 343 | * @return wpdb results array |
344 | 344 | */ |
345 | - public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) { |
|
346 | - $current_time_for_DTT_EVT_start = $this->current_time_for_query( 'DTT_EVT_start' ); |
|
347 | - $current_time_for_DTT_EVT_end = $this->current_time_for_query( 'DTT_EVT_end' ); |
|
345 | + public function get_dtt_months_and_years($where_params, $evt_active_status = '') { |
|
346 | + $current_time_for_DTT_EVT_start = $this->current_time_for_query('DTT_EVT_start'); |
|
347 | + $current_time_for_DTT_EVT_end = $this->current_time_for_query('DTT_EVT_end'); |
|
348 | 348 | |
349 | - switch ( $evt_active_status ) { |
|
349 | + switch ($evt_active_status) { |
|
350 | 350 | case 'upcoming' : |
351 | 351 | $where_params['Event.status'] = 'publish'; |
352 | 352 | //if there are already query_params matching DTT_EVT_start then we need to modify that to add them. |
353 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
353 | + if (isset($where_params['DTT_EVT_start'])) { |
|
354 | 354 | $where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start']; |
355 | 355 | } |
356 | - $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start ); |
|
356 | + $where_params['DTT_EVT_start'] = array('>', $current_time_for_DTT_EVT_start); |
|
357 | 357 | break; |
358 | 358 | |
359 | 359 | case 'expired' : |
360 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
360 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
361 | 361 | //get events to exclude |
362 | - $exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $current_time_for_DTT_EVT_end ) ) ); |
|
362 | + $exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $current_time_for_DTT_EVT_end))); |
|
363 | 363 | //first get all events that have datetimes where its not expired. |
364 | - $event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' ); |
|
365 | - $event_ids = array_keys( $event_ids ); |
|
364 | + $event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID'); |
|
365 | + $event_ids = array_keys($event_ids); |
|
366 | 366 | |
367 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
367 | + if (isset($where_params['DTT_EVT_end'])) { |
|
368 | 368 | $where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
369 | 369 | } |
370 | - $where_params['DTT_EVT_end'] = array( '<', $current_time_for_DTT_EVT_end ); |
|
371 | - $where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids ); |
|
370 | + $where_params['DTT_EVT_end'] = array('<', $current_time_for_DTT_EVT_end); |
|
371 | + $where_params['Event.EVT_ID'] = array('NOT IN', $event_ids); |
|
372 | 372 | break; |
373 | 373 | |
374 | 374 | case 'active' : |
375 | 375 | $where_params['Event.status'] = 'publish'; |
376 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
376 | + if (isset($where_params['DTT_EVT_start'])) { |
|
377 | 377 | $where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start']; |
378 | 378 | } |
379 | - if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) { |
|
379 | + if (isset($where_params['Datetime.DTT_EVT_end'])) { |
|
380 | 380 | $where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end']; |
381 | 381 | } |
382 | - $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start ); |
|
383 | - $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end ); |
|
382 | + $where_params['DTT_EVT_start'] = array('<', $current_time_for_DTT_EVT_start); |
|
383 | + $where_params['DTT_EVT_end'] = array('>', $current_time_for_DTT_EVT_end); |
|
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'inactive' : |
387 | - if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] ); |
|
388 | - if ( isset( $where_params['OR'] ) ) { |
|
387 | + if (isset($where_params['Event.status'])) unset($where_params['Event.status']); |
|
388 | + if (isset($where_params['OR'])) { |
|
389 | 389 | $where_params['AND']['OR'] = $where_params['OR']; |
390 | 390 | } |
391 | - if ( isset( $where_params['DTT_EVT_end'] ) ) { |
|
391 | + if (isset($where_params['DTT_EVT_end'])) { |
|
392 | 392 | $where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end']; |
393 | - unset( $where_params['DTT_EVT_end'] ); |
|
393 | + unset($where_params['DTT_EVT_end']); |
|
394 | 394 | } |
395 | 395 | |
396 | - if ( isset( $where_params['DTT_EVT_start'] ) ) { |
|
396 | + if (isset($where_params['DTT_EVT_start'])) { |
|
397 | 397 | $where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start']; |
398 | - unset( $where_params['DTT_EVT_start'] ); |
|
398 | + unset($where_params['DTT_EVT_start']); |
|
399 | 399 | } |
400 | - $where_params['AND']['Event.status'] = array( '!=', 'publish' ); |
|
400 | + $where_params['AND']['Event.status'] = array('!=', 'publish'); |
|
401 | 401 | break; |
402 | 402 | } |
403 | 403 | |
404 | 404 | $query_params[0] = $where_params; |
405 | 405 | $query_params['group_by'] = array('dtt_year', 'dtt_month'); |
406 | - $query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' ); |
|
406 | + $query_params['order_by'] = array('DTT_EVT_start' => 'DESC'); |
|
407 | 407 | |
408 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset( $this->get_timezone(), 'DTT_EVT_start' ); |
|
408 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'DTT_EVT_start'); |
|
409 | 409 | |
410 | 410 | $columns_to_select = array( |
411 | - 'dtt_year' => array('YEAR(' . $query_interval . ')', '%s'), |
|
412 | - 'dtt_month' => array('MONTHNAME(' . $query_interval . ')', '%s'), |
|
413 | - 'dtt_month_num' => array('MONTH(' . $query_interval .')', '%s') |
|
411 | + 'dtt_year' => array('YEAR('.$query_interval.')', '%s'), |
|
412 | + 'dtt_month' => array('MONTHNAME('.$query_interval.')', '%s'), |
|
413 | + 'dtt_month_num' => array('MONTH('.$query_interval.')', '%s') |
|
414 | 414 | ); |
415 | - return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select ); |
|
415 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -420,8 +420,8 @@ discard block |
||
420 | 420 | * for the tickets for each datetime) |
421 | 421 | * @param EE_Datetime[] $datetimes |
422 | 422 | */ |
423 | - public function update_sold($datetimes){ |
|
424 | - foreach($datetimes as $datetime){ |
|
423 | + public function update_sold($datetimes) { |
|
424 | + foreach ($datetimes as $datetime) { |
|
425 | 425 | $datetime->update_sold(); |
426 | 426 | } |
427 | 427 | } |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | * @param array $query_params |
437 | 437 | * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF, IF there are NO tickets attached to datetime then FALSE is returned. |
438 | 438 | */ |
439 | - public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) { |
|
440 | - $datetime = $this->get_one_by_ID( $DTT_ID ); |
|
441 | - if ( $datetime instanceof EE_Datetime ) { |
|
442 | - return $datetime->tickets_remaining( $query_params ); |
|
439 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
440 | + $datetime = $this->get_one_by_ID($DTT_ID); |
|
441 | + if ($datetime instanceof EE_Datetime) { |
|
442 | + return $datetime->tickets_remaining($query_params); |
|
443 | 443 | } |
444 | 444 | return 0; |
445 | 445 | } |
@@ -461,36 +461,36 @@ discard block |
||
461 | 461 | * EE_Datetime::upcoming |
462 | 462 | * EE_Datetime::expired |
463 | 463 | */ |
464 | - public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) { |
|
464 | + public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) { |
|
465 | 465 | //only accept where conditions for this query. |
466 | - $_where = isset( $query_params[0] ) ? $query_params[0] : array(); |
|
466 | + $_where = isset($query_params[0]) ? $query_params[0] : array(); |
|
467 | 467 | $status_query_args = array( |
468 | 468 | EE_Datetime::active => array_merge( |
469 | 469 | $_where, |
470 | - array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) ) |
|
470 | + array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time())) |
|
471 | 471 | ), |
472 | 472 | EE_Datetime::upcoming => array_merge( |
473 | 473 | $_where, |
474 | - array( 'DTT_EVT_start' => array( '>', time() ) ) |
|
474 | + array('DTT_EVT_start' => array('>', time())) |
|
475 | 475 | ), |
476 | 476 | EE_Datetime::expired => array_merge( |
477 | 477 | $_where, |
478 | - array( 'DTT_EVT_end' => array('<', time() ) ) |
|
478 | + array('DTT_EVT_end' => array('<', time())) |
|
479 | 479 | ) |
480 | 480 | ); |
481 | 481 | |
482 | - if ( ! empty( $stati_to_include ) ) { |
|
483 | - foreach( array_keys( $status_query_args ) as $status ) { |
|
484 | - if ( ! in_array( $status, $stati_to_include ) ) { |
|
485 | - unset( $status_query_args[$status] ); |
|
482 | + if ( ! empty($stati_to_include)) { |
|
483 | + foreach (array_keys($status_query_args) as $status) { |
|
484 | + if ( ! in_array($status, $stati_to_include)) { |
|
485 | + unset($status_query_args[$status]); |
|
486 | 486 | } |
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
490 | 490 | //loop through and query counts for each stati. |
491 | 491 | $status_query_results = array(); |
492 | - foreach( $status_query_args as $status => $status_where_conditions ) { |
|
493 | - $status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true ); |
|
492 | + foreach ($status_query_args as $status => $status_where_conditions) { |
|
493 | + $status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | return $status_query_results; |
@@ -504,9 +504,9 @@ discard block |
||
504 | 504 | * @param array $query_params |
505 | 505 | * @return int |
506 | 506 | */ |
507 | - public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) { |
|
508 | - $count = $this->get_datetime_counts_by_status( array( $status ), $query_params ); |
|
509 | - return ! empty( $count[$status] ) ? $count[$status] : 0; |
|
507 | + public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) { |
|
508 | + $count = $this->get_datetime_counts_by_status(array($status), $query_params); |
|
509 | + return ! empty($count[$status]) ? $count[$status] : 0; |
|
510 | 510 | } |
511 | 511 | |
512 | 512 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * EEH_Line_Item |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @return boolean success |
46 | 46 | * @throws \EE_Error |
47 | 47 | */ |
48 | - public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL ){ |
|
49 | - $items_subtotal = self::get_pre_tax_subtotal( $parent_line_item ); |
|
48 | + public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) { |
|
49 | + $items_subtotal = self::get_pre_tax_subtotal($parent_line_item); |
|
50 | 50 | $line_item = EE_Line_Item::new_instance(array( |
51 | 51 | 'LIN_name' => $name, |
52 | 52 | 'LIN_desc' => $description, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'LIN_quantity' => $quantity, |
55 | 55 | 'LIN_percent' => null, |
56 | 56 | 'LIN_is_taxable' => $taxable, |
57 | - 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0, |
|
57 | + 'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0, |
|
58 | 58 | 'LIN_total' => (float) $unit_price * (int) $quantity, |
59 | 59 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
60 | 60 | 'LIN_code' => $code, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $line_item, |
65 | 65 | $parent_line_item |
66 | 66 | ); |
67 | - return self::add_item( $parent_line_item, $line_item ); |
|
67 | + return self::add_item($parent_line_item, $line_item); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return boolean success |
87 | 87 | * @throws \EE_Error |
88 | 88 | */ |
89 | - public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){ |
|
89 | + public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) { |
|
90 | 90 | $line_item = EE_Line_Item::new_instance(array( |
91 | 91 | 'LIN_name' => $name, |
92 | 92 | 'LIN_desc' => $description, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | 'LIN_percent' => $percentage_amount, |
95 | 95 | 'LIN_quantity' => NULL, |
96 | 96 | 'LIN_is_taxable' => $taxable, |
97 | - 'LIN_total' => (float) ( $percentage_amount * ( $parent_line_item->total() / 100 ) ), |
|
97 | + 'LIN_total' => (float) ($percentage_amount * ($parent_line_item->total() / 100)), |
|
98 | 98 | 'LIN_type'=> EEM_Line_Item::type_line_item, |
99 | 99 | 'LIN_parent' => $parent_line_item->ID() |
100 | 100 | )); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'FHEE__EEH_Line_Item__add_percentage_based_item__line_item', |
103 | 103 | $line_item |
104 | 104 | ); |
105 | - return self::add_item( $parent_line_item, $line_item ); |
|
105 | + return self::add_item($parent_line_item, $line_item); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | * @return \EE_Line_Item |
124 | 124 | * @throws \EE_Error |
125 | 125 | */ |
126 | - public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){ |
|
127 | - if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) { |
|
128 | - throw new EE_Error( sprintf( __( 'A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) ); |
|
126 | + public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
127 | + if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) { |
|
128 | + throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID())); |
|
129 | 129 | } |
130 | 130 | // either increment the qty for an existing ticket |
131 | - $line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty ); |
|
131 | + $line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty); |
|
132 | 132 | // or add a new one |
133 | - if ( ! $line_item instanceof EE_Line_Item ) { |
|
134 | - $line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty ); |
|
133 | + if ( ! $line_item instanceof EE_Line_Item) { |
|
134 | + $line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty); |
|
135 | 135 | } |
136 | 136 | $total_line_item->recalculate_total_including_taxes(); |
137 | 137 | return $line_item; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * @return \EE_Line_Item |
148 | 148 | * @throws \EE_Error |
149 | 149 | */ |
150 | - public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
150 | + public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
151 | 151 | $line_item = null; |
152 | - if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) { |
|
153 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item ); |
|
154 | - foreach ( (array)$ticket_line_items as $ticket_line_item ) { |
|
152 | + if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) { |
|
153 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
154 | + foreach ((array) $ticket_line_items as $ticket_line_item) { |
|
155 | 155 | if ( |
156 | 156 | $ticket_line_item instanceof EE_Line_Item |
157 | 157 | && (int) $ticket_line_item->OBJ_ID() === (int) $ticket->ID() |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | - if ( $line_item instanceof EE_Line_Item ) { |
|
165 | - EEH_Line_Item::increment_quantity( $line_item, $qty ); |
|
164 | + if ($line_item instanceof EE_Line_Item) { |
|
165 | + EEH_Line_Item::increment_quantity($line_item, $qty); |
|
166 | 166 | return $line_item; |
167 | 167 | } |
168 | 168 | return null; |
@@ -179,16 +179,16 @@ discard block |
||
179 | 179 | * @return void |
180 | 180 | * @throws \EE_Error |
181 | 181 | */ |
182 | - public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
183 | - if( ! $line_item->is_percent() ) { |
|
182 | + public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
183 | + if ( ! $line_item->is_percent()) { |
|
184 | 184 | $qty += $line_item->quantity(); |
185 | - $line_item->set_quantity( $qty ); |
|
186 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
185 | + $line_item->set_quantity($qty); |
|
186 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
187 | 187 | $line_item->save(); |
188 | 188 | } |
189 | - foreach( $line_item->children() as $child ) { |
|
190 | - if( $child->is_sub_line_item() ) { |
|
191 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
189 | + foreach ($line_item->children() as $child) { |
|
190 | + if ($child->is_sub_line_item()) { |
|
191 | + EEH_Line_Item::update_quantity($child, $qty); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -204,17 +204,17 @@ discard block |
||
204 | 204 | * @return void |
205 | 205 | * @throws \EE_Error |
206 | 206 | */ |
207 | - public static function decrement_quantity( EE_Line_Item $line_item, $qty = 1 ) { |
|
208 | - if( ! $line_item->is_percent() ) { |
|
207 | + public static function decrement_quantity(EE_Line_Item $line_item, $qty = 1) { |
|
208 | + if ( ! $line_item->is_percent()) { |
|
209 | 209 | $qty = $line_item->quantity() - $qty; |
210 | - $qty = max( $qty, 0 ); |
|
211 | - $line_item->set_quantity( $qty ); |
|
212 | - $line_item->set_total( $line_item->unit_price() * $qty ); |
|
210 | + $qty = max($qty, 0); |
|
211 | + $line_item->set_quantity($qty); |
|
212 | + $line_item->set_total($line_item->unit_price() * $qty); |
|
213 | 213 | $line_item->save(); |
214 | 214 | } |
215 | - foreach( $line_item->children() as $child ) { |
|
216 | - if( $child->is_sub_line_item() ) { |
|
217 | - EEH_Line_Item::update_quantity( $child, $qty ); |
|
215 | + foreach ($line_item->children() as $child) { |
|
216 | + if ($child->is_sub_line_item()) { |
|
217 | + EEH_Line_Item::update_quantity($child, $qty); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | * @param int $new_quantity |
230 | 230 | * @throws \EE_Error |
231 | 231 | */ |
232 | - public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) { |
|
233 | - if( ! $line_item->is_percent() ) { |
|
234 | - $line_item->set_quantity( $new_quantity ); |
|
235 | - $line_item->set_total( $line_item->unit_price() * $new_quantity ); |
|
232 | + public static function update_quantity(EE_Line_Item $line_item, $new_quantity) { |
|
233 | + if ( ! $line_item->is_percent()) { |
|
234 | + $line_item->set_quantity($new_quantity); |
|
235 | + $line_item->set_total($line_item->unit_price() * $new_quantity); |
|
236 | 236 | $line_item->save(); |
237 | 237 | } |
238 | - foreach( $line_item->children() as $child ) { |
|
239 | - if( $child->is_sub_line_item() ) { |
|
240 | - EEH_Line_Item::update_quantity( $child, $new_quantity ); |
|
238 | + foreach ($line_item->children() as $child) { |
|
239 | + if ($child->is_sub_line_item()) { |
|
240 | + EEH_Line_Item::update_quantity($child, $new_quantity); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | } |
@@ -252,43 +252,43 @@ discard block |
||
252 | 252 | * @return \EE_Line_Item |
253 | 253 | * @throws \EE_Error |
254 | 254 | */ |
255 | - public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) { |
|
255 | + public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) { |
|
256 | 256 | $datetimes = $ticket->datetimes(); |
257 | - $first_datetime = reset( $datetimes ); |
|
258 | - if( $first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event ) { |
|
257 | + $first_datetime = reset($datetimes); |
|
258 | + if ($first_datetime instanceof EE_Datetime && $first_datetime->event() instanceof EE_Event) { |
|
259 | 259 | $first_datetime_name = $first_datetime->event()->name(); |
260 | 260 | } else { |
261 | - $first_datetime_name = __( 'Event', 'event_espresso' ); |
|
261 | + $first_datetime_name = __('Event', 'event_espresso'); |
|
262 | 262 | } |
263 | - $event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name ); |
|
263 | + $event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name); |
|
264 | 264 | // get event subtotal line |
265 | - $events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket ); |
|
265 | + $events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket); |
|
266 | 266 | // add $ticket to cart |
267 | - $line_item = EE_Line_Item::new_instance( array( |
|
267 | + $line_item = EE_Line_Item::new_instance(array( |
|
268 | 268 | 'LIN_name' => $ticket->name(), |
269 | - 'LIN_desc' => $ticket->description() !== '' ? $ticket->description() . ' ' . $event : $event, |
|
269 | + 'LIN_desc' => $ticket->description() !== '' ? $ticket->description().' '.$event : $event, |
|
270 | 270 | 'LIN_unit_price' => $ticket->price(), |
271 | 271 | 'LIN_quantity' => $qty, |
272 | 272 | 'LIN_is_taxable' => $ticket->taxable(), |
273 | - 'LIN_order' => count( $events_sub_total->children() ), |
|
273 | + 'LIN_order' => count($events_sub_total->children()), |
|
274 | 274 | 'LIN_total' => $ticket->price() * $qty, |
275 | 275 | 'LIN_type' => EEM_Line_Item::type_line_item, |
276 | 276 | 'OBJ_ID' => $ticket->ID(), |
277 | 277 | 'OBJ_type' => 'Ticket' |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | $line_item = apply_filters( |
280 | 280 | 'FHEE__EEH_Line_Item__create_ticket_line_item__line_item', |
281 | 281 | $line_item |
282 | 282 | ); |
283 | - $events_sub_total->add_child_line_item( $line_item ); |
|
283 | + $events_sub_total->add_child_line_item($line_item); |
|
284 | 284 | //now add the sub-line items |
285 | 285 | $running_total_for_ticket = 0; |
286 | - foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) { |
|
286 | + foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) { |
|
287 | 287 | $sign = $price->is_discount() ? -1 : 1; |
288 | 288 | $price_total = $price->is_percent() |
289 | 289 | ? $running_total_for_ticket * $price->amount() / 100 |
290 | 290 | : $price->amount() * $qty; |
291 | - $sub_line_item = EE_Line_Item::new_instance( array( |
|
291 | + $sub_line_item = EE_Line_Item::new_instance(array( |
|
292 | 292 | 'LIN_name' => $price->name(), |
293 | 293 | 'LIN_desc' => $price->desc(), |
294 | 294 | 'LIN_quantity' => $price->is_percent() ? null : $qty, |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | 'LIN_type' => EEM_Line_Item::type_sub_line_item, |
299 | 299 | 'OBJ_ID' => $price->ID(), |
300 | 300 | 'OBJ_type' => 'Price' |
301 | - ) ); |
|
301 | + )); |
|
302 | 302 | $sub_line_item = apply_filters( |
303 | 303 | 'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item', |
304 | 304 | $sub_line_item |
305 | 305 | ); |
306 | - if ( $price->is_percent() ) { |
|
307 | - $sub_line_item->set_percent( $sign * $price->amount() ); |
|
306 | + if ($price->is_percent()) { |
|
307 | + $sub_line_item->set_percent($sign * $price->amount()); |
|
308 | 308 | } else { |
309 | - $sub_line_item->set_unit_price( $sign * $price->amount() ); |
|
309 | + $sub_line_item->set_unit_price($sign * $price->amount()); |
|
310 | 310 | } |
311 | 311 | $running_total_for_ticket += $price_total; |
312 | - $line_item->add_child_line_item( $sub_line_item ); |
|
312 | + $line_item->add_child_line_item($sub_line_item); |
|
313 | 313 | } |
314 | 314 | return $line_item; |
315 | 315 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @return boolean |
330 | 330 | * @throws \EE_Error |
331 | 331 | */ |
332 | - public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){ |
|
333 | - $pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item ); |
|
334 | - if ( $pre_tax_subtotal instanceof EE_Line_Item ){ |
|
332 | + public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) { |
|
333 | + $pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item); |
|
334 | + if ($pre_tax_subtotal instanceof EE_Line_Item) { |
|
335 | 335 | $success = $pre_tax_subtotal->add_child_line_item($item); |
336 | - }else{ |
|
336 | + } else { |
|
337 | 337 | return FALSE; |
338 | 338 | } |
339 | 339 | $total_line_item->recalculate_total_including_taxes(); |
@@ -352,34 +352,34 @@ discard block |
||
352 | 352 | * @return bool success |
353 | 353 | * @throws \EE_Error |
354 | 354 | */ |
355 | - public static function cancel_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
355 | + public static function cancel_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
356 | 356 | // validate incoming line_item |
357 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
357 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
358 | 358 | throw new EE_Error( |
359 | 359 | sprintf( |
360 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
360 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
361 | 361 | $ticket_line_item->type() |
362 | 362 | ) |
363 | 363 | ); |
364 | 364 | } |
365 | - if ( $ticket_line_item->quantity() < $qty ) { |
|
365 | + if ($ticket_line_item->quantity() < $qty) { |
|
366 | 366 | throw new EE_Error( |
367 | 367 | sprintf( |
368 | - __( 'Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso' ), |
|
368 | + __('Can not cancel %1$d ticket(s) because the supplied line item has a quantity of %2$d.', 'event_espresso'), |
|
369 | 369 | $qty, |
370 | 370 | $ticket_line_item->quantity() |
371 | 371 | ) |
372 | 372 | ); |
373 | 373 | } |
374 | 374 | // decrement ticket quantity; don't rely on auto-fixing when recalculating totals to do this |
375 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() - $qty ); |
|
376 | - foreach( $ticket_line_item->children() as $child_line_item ) { |
|
377 | - if( |
|
375 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() - $qty); |
|
376 | + foreach ($ticket_line_item->children() as $child_line_item) { |
|
377 | + if ( |
|
378 | 378 | $child_line_item->is_sub_line_item() |
379 | 379 | && ! $child_line_item->is_percent() |
380 | 380 | && ! $child_line_item->is_cancellation() |
381 | 381 | ) { |
382 | - $child_line_item->set_quantity( $child_line_item->quantity() - $qty ); |
|
382 | + $child_line_item->set_quantity($child_line_item->quantity() - $qty); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | // get cancellation sub line item |
@@ -387,31 +387,31 @@ discard block |
||
387 | 387 | $ticket_line_item, |
388 | 388 | EEM_Line_Item::type_cancellation |
389 | 389 | ); |
390 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
390 | + $cancellation_line_item = reset($cancellation_line_item); |
|
391 | 391 | // verify that this ticket was indeed previously cancelled |
392 | - if ( $cancellation_line_item instanceof EE_Line_Item ) { |
|
392 | + if ($cancellation_line_item instanceof EE_Line_Item) { |
|
393 | 393 | // increment cancelled quantity |
394 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() + $qty ); |
|
394 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() + $qty); |
|
395 | 395 | } else { |
396 | 396 | // create cancellation sub line item |
397 | - $cancellation_line_item = EE_Line_Item::new_instance( array( |
|
398 | - 'LIN_name' => __( 'Cancellation', 'event_espresso' ), |
|
397 | + $cancellation_line_item = EE_Line_Item::new_instance(array( |
|
398 | + 'LIN_name' => __('Cancellation', 'event_espresso'), |
|
399 | 399 | 'LIN_desc' => sprintf( |
400 | - _x( 'Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso' ), |
|
400 | + _x('Cancelled %1$s : %2$s', 'Cancelled Ticket Name : 2015-01-01 11:11', 'event_espresso'), |
|
401 | 401 | $ticket_line_item->name(), |
402 | - current_time( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ) |
|
402 | + current_time(get_option('date_format').' '.get_option('time_format')) |
|
403 | 403 | ), |
404 | 404 | 'LIN_unit_price' => 0, // $ticket_line_item->unit_price() |
405 | 405 | 'LIN_quantity' => $qty, |
406 | 406 | 'LIN_is_taxable' => $ticket_line_item->is_taxable(), |
407 | - 'LIN_order' => count( $ticket_line_item->children() ), |
|
407 | + 'LIN_order' => count($ticket_line_item->children()), |
|
408 | 408 | 'LIN_total' => 0, // $ticket_line_item->unit_price() |
409 | 409 | 'LIN_type' => EEM_Line_Item::type_cancellation, |
410 | - ) ); |
|
411 | - $ticket_line_item->add_child_line_item( $cancellation_line_item ); |
|
410 | + )); |
|
411 | + $ticket_line_item->add_child_line_item($cancellation_line_item); |
|
412 | 412 | } |
413 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
414 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
413 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
414 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
415 | 415 | return true; |
416 | 416 | } |
417 | 417 | return false; |
@@ -429,12 +429,12 @@ discard block |
||
429 | 429 | * @return bool success |
430 | 430 | * @throws \EE_Error |
431 | 431 | */ |
432 | - public static function reinstate_canceled_ticket_line_item( EE_Line_Item $ticket_line_item, $qty = 1 ) { |
|
432 | + public static function reinstate_canceled_ticket_line_item(EE_Line_Item $ticket_line_item, $qty = 1) { |
|
433 | 433 | // validate incoming line_item |
434 | - if ( $ticket_line_item->OBJ_type() !== 'Ticket' ) { |
|
434 | + if ($ticket_line_item->OBJ_type() !== 'Ticket') { |
|
435 | 435 | throw new EE_Error( |
436 | 436 | sprintf( |
437 | - __( 'The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso' ), |
|
437 | + __('The supplied line item must have an Object Type of "Ticket", not %1$s.', 'event_espresso'), |
|
438 | 438 | $ticket_line_item->type() |
439 | 439 | ) |
440 | 440 | ); |
@@ -444,37 +444,37 @@ discard block |
||
444 | 444 | $ticket_line_item, |
445 | 445 | EEM_Line_Item::type_cancellation |
446 | 446 | ); |
447 | - $cancellation_line_item = reset( $cancellation_line_item ); |
|
447 | + $cancellation_line_item = reset($cancellation_line_item); |
|
448 | 448 | // verify that this ticket was indeed previously cancelled |
449 | - if ( ! $cancellation_line_item instanceof EE_Line_Item ) { |
|
449 | + if ( ! $cancellation_line_item instanceof EE_Line_Item) { |
|
450 | 450 | return false; |
451 | 451 | } |
452 | - if ( $cancellation_line_item->quantity() > $qty ) { |
|
452 | + if ($cancellation_line_item->quantity() > $qty) { |
|
453 | 453 | // decrement cancelled quantity |
454 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
455 | - } else if ( $cancellation_line_item->quantity() == $qty ) { |
|
454 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
455 | + } else if ($cancellation_line_item->quantity() == $qty) { |
|
456 | 456 | // decrement cancelled quantity in case anyone still has the object kicking around |
457 | - $cancellation_line_item->set_quantity( $cancellation_line_item->quantity() - $qty ); |
|
457 | + $cancellation_line_item->set_quantity($cancellation_line_item->quantity() - $qty); |
|
458 | 458 | // delete because quantity will end up as 0 |
459 | 459 | $cancellation_line_item->delete(); |
460 | 460 | // and attempt to destroy the object, |
461 | 461 | // even though PHP won't actually destroy it until it needs the memory |
462 | - unset( $cancellation_line_item ); |
|
462 | + unset($cancellation_line_item); |
|
463 | 463 | } else { |
464 | 464 | // what ?!?! negative quantity ?!?! |
465 | 465 | throw new EE_Error( |
466 | 466 | sprintf( |
467 | - __( 'Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
468 | - 'event_espresso' ), |
|
467 | + __('Can not reinstate %1$d cancelled ticket(s) because the cancelled ticket quantity is only %2$d.', |
|
468 | + 'event_espresso'), |
|
469 | 469 | $qty, |
470 | 470 | $cancellation_line_item->quantity() |
471 | 471 | ) |
472 | 472 | ); |
473 | 473 | } |
474 | 474 | // increment ticket quantity |
475 | - $ticket_line_item->set_quantity( $ticket_line_item->quantity() + $qty ); |
|
476 | - if ( $ticket_line_item->save_this_and_descendants() > 0 ) { |
|
477 | - EEH_Line_Item::get_grand_total_and_recalculate_everything( $ticket_line_item ); |
|
475 | + $ticket_line_item->set_quantity($ticket_line_item->quantity() + $qty); |
|
476 | + if ($ticket_line_item->save_this_and_descendants() > 0) { |
|
477 | + EEH_Line_Item::get_grand_total_and_recalculate_everything($ticket_line_item); |
|
478 | 478 | return true; |
479 | 479 | } |
480 | 480 | return false; |
@@ -489,8 +489,8 @@ discard block |
||
489 | 489 | * @param EE_Line_Item $line_item |
490 | 490 | * @return \EE_Line_Item |
491 | 491 | */ |
492 | - public static function get_grand_total_and_recalculate_everything( EE_Line_Item $line_item ){ |
|
493 | - $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item ); |
|
492 | + public static function get_grand_total_and_recalculate_everything(EE_Line_Item $line_item) { |
|
493 | + $grand_total_line_item = EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item); |
|
494 | 494 | return $grand_total_line_item->recalculate_total_including_taxes(); |
495 | 495 | } |
496 | 496 | |
@@ -503,11 +503,11 @@ discard block |
||
503 | 503 | * @return \EE_Line_Item |
504 | 504 | * @throws \EE_Error |
505 | 505 | */ |
506 | - public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){ |
|
507 | - $pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' ); |
|
506 | + public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) { |
|
507 | + $pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal'); |
|
508 | 508 | return $pre_tax_subtotal instanceof EE_Line_Item |
509 | 509 | ? $pre_tax_subtotal |
510 | - : self::create_pre_tax_subtotal( $total_line_item ); |
|
510 | + : self::create_pre_tax_subtotal($total_line_item); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | |
@@ -519,9 +519,9 @@ discard block |
||
519 | 519 | * @return \EE_Line_Item |
520 | 520 | * @throws \EE_Error |
521 | 521 | */ |
522 | - public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){ |
|
523 | - $taxes = $total_line_item->get_child_line_item( 'taxes' ); |
|
524 | - return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item ); |
|
522 | + public static function get_taxes_subtotal(EE_Line_Item $total_line_item) { |
|
523 | + $taxes = $total_line_item->get_child_line_item('taxes'); |
|
524 | + return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | |
@@ -534,12 +534,12 @@ discard block |
||
534 | 534 | * @return void |
535 | 535 | * @throws \EE_Error |
536 | 536 | */ |
537 | - public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){ |
|
538 | - if( $transaction ){ |
|
537 | + public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) { |
|
538 | + if ($transaction) { |
|
539 | 539 | /** @type EEM_Transaction $EEM_Transaction */ |
540 | - $EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' ); |
|
541 | - $TXN_ID = $EEM_Transaction->ensure_is_ID( $transaction ); |
|
542 | - $line_item->set_TXN_ID( $TXN_ID ); |
|
540 | + $EEM_Transaction = EE_Registry::instance()->load_model('Transaction'); |
|
541 | + $TXN_ID = $EEM_Transaction->ensure_is_ID($transaction); |
|
542 | + $line_item->set_TXN_ID($TXN_ID); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * @return \EE_Line_Item of type total |
555 | 555 | * @throws \EE_Error |
556 | 556 | */ |
557 | - public static function create_total_line_item( $transaction = NULL ){ |
|
558 | - $total_line_item = EE_Line_Item::new_instance( array( |
|
557 | + public static function create_total_line_item($transaction = NULL) { |
|
558 | + $total_line_item = EE_Line_Item::new_instance(array( |
|
559 | 559 | 'LIN_code' => 'total', |
560 | 560 | 'LIN_name' => __('Grand Total', 'event_espresso'), |
561 | 561 | 'LIN_type' => EEM_Line_Item::type_total, |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | 'FHEE__EEH_Line_Item__create_total_line_item__total_line_item', |
566 | 566 | $total_line_item |
567 | 567 | ); |
568 | - self::set_TXN_ID( $total_line_item, $transaction ); |
|
569 | - self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
570 | - self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
568 | + self::set_TXN_ID($total_line_item, $transaction); |
|
569 | + self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
570 | + self::create_taxes_subtotal($total_line_item, $transaction); |
|
571 | 571 | return $total_line_item; |
572 | 572 | } |
573 | 573 | |
@@ -581,19 +581,19 @@ discard block |
||
581 | 581 | * @return EE_Line_Item |
582 | 582 | * @throws \EE_Error |
583 | 583 | */ |
584 | - protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
585 | - $pre_tax_line_item = EE_Line_Item::new_instance( array( |
|
584 | + protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
585 | + $pre_tax_line_item = EE_Line_Item::new_instance(array( |
|
586 | 586 | 'LIN_code' => 'pre-tax-subtotal', |
587 | - 'LIN_name' => __( 'Pre-Tax Subtotal', 'event_espresso' ), |
|
587 | + 'LIN_name' => __('Pre-Tax Subtotal', 'event_espresso'), |
|
588 | 588 | 'LIN_type' => EEM_Line_Item::type_sub_total |
589 | - ) ); |
|
589 | + )); |
|
590 | 590 | $pre_tax_line_item = apply_filters( |
591 | 591 | 'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item', |
592 | 592 | $pre_tax_line_item |
593 | 593 | ); |
594 | - self::set_TXN_ID( $pre_tax_line_item, $transaction ); |
|
595 | - $total_line_item->add_child_line_item( $pre_tax_line_item ); |
|
596 | - self::create_event_subtotal( $pre_tax_line_item, $transaction ); |
|
594 | + self::set_TXN_ID($pre_tax_line_item, $transaction); |
|
595 | + $total_line_item->add_child_line_item($pre_tax_line_item); |
|
596 | + self::create_event_subtotal($pre_tax_line_item, $transaction); |
|
597 | 597 | return $pre_tax_line_item; |
598 | 598 | } |
599 | 599 | |
@@ -608,21 +608,21 @@ discard block |
||
608 | 608 | * @return EE_Line_Item |
609 | 609 | * @throws \EE_Error |
610 | 610 | */ |
611 | - protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){ |
|
611 | + protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
612 | 612 | $tax_line_item = EE_Line_Item::new_instance(array( |
613 | 613 | 'LIN_code' => 'taxes', |
614 | 614 | 'LIN_name' => __('Taxes', 'event_espresso'), |
615 | 615 | 'LIN_type' => EEM_Line_Item::type_tax_sub_total, |
616 | - 'LIN_order' => 1000,//this should always come last |
|
616 | + 'LIN_order' => 1000, //this should always come last |
|
617 | 617 | )); |
618 | 618 | $tax_line_item = apply_filters( |
619 | 619 | 'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item', |
620 | 620 | $tax_line_item |
621 | 621 | ); |
622 | - self::set_TXN_ID( $tax_line_item, $transaction ); |
|
623 | - $total_line_item->add_child_line_item( $tax_line_item ); |
|
622 | + self::set_TXN_ID($tax_line_item, $transaction); |
|
623 | + $total_line_item->add_child_line_item($tax_line_item); |
|
624 | 624 | //and lastly, add the actual taxes |
625 | - self::apply_taxes( $total_line_item ); |
|
625 | + self::apply_taxes($total_line_item); |
|
626 | 626 | return $tax_line_item; |
627 | 627 | } |
628 | 628 | |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | * @return EE_Line_Item |
638 | 638 | * @throws \EE_Error |
639 | 639 | */ |
640 | - public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){ |
|
640 | + public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) { |
|
641 | 641 | $event_line_item = EE_Line_Item::new_instance(array( |
642 | - 'LIN_code' => self::get_event_code( $event ), |
|
643 | - 'LIN_name' => self::get_event_name( $event ), |
|
644 | - 'LIN_desc' => self::get_event_desc( $event ), |
|
642 | + 'LIN_code' => self::get_event_code($event), |
|
643 | + 'LIN_name' => self::get_event_name($event), |
|
644 | + 'LIN_desc' => self::get_event_desc($event), |
|
645 | 645 | 'LIN_type' => EEM_Line_Item::type_sub_total, |
646 | 646 | 'OBJ_type' => 'Event', |
647 | 647 | 'OBJ_ID' => $event instanceof EE_Event ? $event->ID() : 0 |
@@ -650,8 +650,8 @@ discard block |
||
650 | 650 | 'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item', |
651 | 651 | $event_line_item |
652 | 652 | ); |
653 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
654 | - $pre_tax_line_item->add_child_line_item( $event_line_item ); |
|
653 | + self::set_TXN_ID($event_line_item, $transaction); |
|
654 | + $pre_tax_line_item->add_child_line_item($event_line_item); |
|
655 | 655 | return $event_line_item; |
656 | 656 | } |
657 | 657 | |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | * @throws \EE_Error |
666 | 666 | */ |
667 | - public static function get_event_code( $event ) { |
|
668 | - return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' ); |
|
667 | + public static function get_event_code($event) { |
|
668 | + return 'event-'.($event instanceof EE_Event ? $event->ID() : '0'); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -673,8 +673,8 @@ discard block |
||
673 | 673 | * @param EE_Event $event |
674 | 674 | * @return string |
675 | 675 | */ |
676 | - public static function get_event_name( $event ) { |
|
677 | - return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' ); |
|
676 | + public static function get_event_name($event) { |
|
677 | + return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso'); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @param EE_Event $event |
683 | 683 | * @return string |
684 | 684 | */ |
685 | - public static function get_event_desc( $event ) { |
|
685 | + public static function get_event_desc($event) { |
|
686 | 686 | return $event instanceof EE_Event ? $event->short_description() : ''; |
687 | 687 | } |
688 | 688 | |
@@ -696,27 +696,27 @@ discard block |
||
696 | 696 | * @throws \EE_Error |
697 | 697 | * @return EE_Line_Item |
698 | 698 | */ |
699 | - public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) { |
|
699 | + public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) { |
|
700 | 700 | $first_datetime = $ticket->first_datetime(); |
701 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
701 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
702 | 702 | throw new EE_Error( |
703 | - sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) |
|
703 | + sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()) |
|
704 | 704 | ); |
705 | 705 | } |
706 | 706 | $event = $first_datetime->event(); |
707 | - if ( ! $event instanceof EE_Event ) { |
|
707 | + if ( ! $event instanceof EE_Event) { |
|
708 | 708 | throw new EE_Error( |
709 | 709 | sprintf( |
710 | - __( 'The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso' ), |
|
710 | + __('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), |
|
711 | 711 | $ticket->ID() |
712 | 712 | ) |
713 | 713 | ); |
714 | 714 | } |
715 | - $events_sub_total = EEH_Line_Item::get_event_line_item( $grand_total, $event ); |
|
716 | - if ( ! $events_sub_total instanceof EE_Line_Item ) { |
|
715 | + $events_sub_total = EEH_Line_Item::get_event_line_item($grand_total, $event); |
|
716 | + if ( ! $events_sub_total instanceof EE_Line_Item) { |
|
717 | 717 | throw new EE_Error( |
718 | 718 | sprintf( |
719 | - __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), |
|
719 | + __('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), |
|
720 | 720 | $ticket->ID(), |
721 | 721 | $grand_total->ID() |
722 | 722 | ) |
@@ -735,31 +735,31 @@ discard block |
||
735 | 735 | * @return EE_Line_Item for the event subtotal which is a child of $grand_total |
736 | 736 | * @throws \EE_Error |
737 | 737 | */ |
738 | - public static function get_event_line_item( EE_Line_Item $grand_total, $event ) { |
|
738 | + public static function get_event_line_item(EE_Line_Item $grand_total, $event) { |
|
739 | 739 | /** @type EE_Event $event */ |
740 | - $event = EEM_Event::instance()->ensure_is_obj( $event, true ); |
|
740 | + $event = EEM_Event::instance()->ensure_is_obj($event, true); |
|
741 | 741 | $event_line_item = NULL; |
742 | 742 | $found = false; |
743 | - foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) { |
|
743 | + foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) { |
|
744 | 744 | // default event subtotal, we should only ever find this the first time this method is called |
745 | - if ( ! $event_line_item->OBJ_ID() ) { |
|
745 | + if ( ! $event_line_item->OBJ_ID()) { |
|
746 | 746 | // let's use this! but first... set the event details |
747 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
747 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
748 | 748 | $found = true; |
749 | 749 | break; |
750 | - } else if ( $event_line_item->OBJ_ID() === $event->ID() ) { |
|
750 | + } else if ($event_line_item->OBJ_ID() === $event->ID()) { |
|
751 | 751 | // found existing line item for this event in the cart, so break out of loop and use this one |
752 | 752 | $found = true; |
753 | 753 | break; |
754 | 754 | } |
755 | 755 | } |
756 | - if ( ! $found ) { |
|
756 | + if ( ! $found) { |
|
757 | 757 | //there is no event sub-total yet, so add it |
758 | - $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total ); |
|
758 | + $pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total); |
|
759 | 759 | // create a new "event" subtotal below that |
760 | - $event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event ); |
|
760 | + $event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event); |
|
761 | 761 | // and set the event details |
762 | - EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event ); |
|
762 | + EEH_Line_Item::set_event_subtotal_details($event_line_item, $event); |
|
763 | 763 | } |
764 | 764 | return $event_line_item; |
765 | 765 | } |
@@ -780,13 +780,13 @@ discard block |
||
780 | 780 | EE_Event $event, |
781 | 781 | $transaction = null |
782 | 782 | ) { |
783 | - if ( $event instanceof EE_Event ) { |
|
784 | - $event_line_item->set_code( self::get_event_code( $event ) ); |
|
785 | - $event_line_item->set_name( self::get_event_name( $event ) ); |
|
786 | - $event_line_item->set_desc( self::get_event_desc( $event ) ); |
|
787 | - $event_line_item->set_OBJ_ID( $event->ID() ); |
|
783 | + if ($event instanceof EE_Event) { |
|
784 | + $event_line_item->set_code(self::get_event_code($event)); |
|
785 | + $event_line_item->set_name(self::get_event_name($event)); |
|
786 | + $event_line_item->set_desc(self::get_event_desc($event)); |
|
787 | + $event_line_item->set_OBJ_ID($event->ID()); |
|
788 | 788 | } |
789 | - self::set_TXN_ID( $event_line_item, $transaction ); |
|
789 | + self::set_TXN_ID($event_line_item, $transaction); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | |
@@ -799,19 +799,19 @@ discard block |
||
799 | 799 | * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total |
800 | 800 | * @throws \EE_Error |
801 | 801 | */ |
802 | - public static function apply_taxes( EE_Line_Item $total_line_item ){ |
|
802 | + public static function apply_taxes(EE_Line_Item $total_line_item) { |
|
803 | 803 | /** @type EEM_Price $EEM_Price */ |
804 | - $EEM_Price = EE_Registry::instance()->load_model( 'Price' ); |
|
804 | + $EEM_Price = EE_Registry::instance()->load_model('Price'); |
|
805 | 805 | // get array of taxes via Price Model |
806 | 806 | $ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes(); |
807 | - ksort( $ordered_taxes ); |
|
808 | - $taxes_line_item = self::get_taxes_subtotal( $total_line_item ); |
|
807 | + ksort($ordered_taxes); |
|
808 | + $taxes_line_item = self::get_taxes_subtotal($total_line_item); |
|
809 | 809 | //just to be safe, remove its old tax line items |
810 | 810 | $taxes_line_item->delete_children_line_items(); |
811 | 811 | //loop thru taxes |
812 | - foreach ( $ordered_taxes as $order => $taxes ) { |
|
813 | - foreach ( $taxes as $tax ) { |
|
814 | - if ( $tax instanceof EE_Price ) { |
|
812 | + foreach ($ordered_taxes as $order => $taxes) { |
|
813 | + foreach ($taxes as $tax) { |
|
814 | + if ($tax instanceof EE_Price) { |
|
815 | 815 | $tax_line_item = EE_Line_Item::new_instance( |
816 | 816 | array( |
817 | 817 | 'LIN_name' => $tax->name(), |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | 'FHEE__EEH_Line_Item__apply_taxes__tax_line_item', |
830 | 830 | $tax_line_item |
831 | 831 | ); |
832 | - $taxes_line_item->add_child_line_item( $tax_line_item ); |
|
832 | + $taxes_line_item->add_child_line_item($tax_line_item); |
|
833 | 833 | } |
834 | 834 | } |
835 | 835 | } |
@@ -846,10 +846,10 @@ discard block |
||
846 | 846 | * @return float |
847 | 847 | * @throws \EE_Error |
848 | 848 | */ |
849 | - public static function ensure_taxes_applied( $total_line_item ){ |
|
850 | - $taxes_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
851 | - if( ! $taxes_subtotal->children()){ |
|
852 | - self::apply_taxes( $total_line_item ); |
|
849 | + public static function ensure_taxes_applied($total_line_item) { |
|
850 | + $taxes_subtotal = self::get_taxes_subtotal($total_line_item); |
|
851 | + if ( ! $taxes_subtotal->children()) { |
|
852 | + self::apply_taxes($total_line_item); |
|
853 | 853 | } |
854 | 854 | return $taxes_subtotal->total(); |
855 | 855 | } |
@@ -863,16 +863,16 @@ discard block |
||
863 | 863 | * @return bool |
864 | 864 | * @throws \EE_Error |
865 | 865 | */ |
866 | - public static function delete_all_child_items( EE_Line_Item $parent_line_item ) { |
|
866 | + public static function delete_all_child_items(EE_Line_Item $parent_line_item) { |
|
867 | 867 | $deleted = 0; |
868 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
869 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
870 | - $deleted += EEH_Line_Item::delete_all_child_items( $child_line_item ); |
|
871 | - if ( $child_line_item->ID() ) { |
|
868 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
869 | + if ($child_line_item instanceof EE_Line_Item) { |
|
870 | + $deleted += EEH_Line_Item::delete_all_child_items($child_line_item); |
|
871 | + if ($child_line_item->ID()) { |
|
872 | 872 | $child_line_item->delete(); |
873 | - unset( $child_line_item ); |
|
873 | + unset($child_line_item); |
|
874 | 874 | } else { |
875 | - $parent_line_item->delete_child_line_item( $child_line_item->code() ); |
|
875 | + $parent_line_item->delete_child_line_item($child_line_item->code()); |
|
876 | 876 | } |
877 | 877 | $deleted++; |
878 | 878 | } |
@@ -894,9 +894,9 @@ discard block |
||
894 | 894 | * @param array|bool|string $line_item_codes |
895 | 895 | * @return int number of items successfully removed |
896 | 896 | */ |
897 | - public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) { |
|
897 | + public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) { |
|
898 | 898 | |
899 | - if( $total_line_item->type() !== EEM_Line_Item::type_total ){ |
|
899 | + if ($total_line_item->type() !== EEM_Line_Item::type_total) { |
|
900 | 900 | EE_Error::doing_it_wrong( |
901 | 901 | 'EEH_Line_Item::delete_items', |
902 | 902 | __( |
@@ -906,20 +906,20 @@ discard block |
||
906 | 906 | '4.6.18' |
907 | 907 | ); |
908 | 908 | } |
909 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
909 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | 910 | |
911 | 911 | // check if only a single line_item_id was passed |
912 | - if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) { |
|
912 | + if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) { |
|
913 | 913 | // place single line_item_id in an array to appear as multiple line_item_ids |
914 | - $line_item_codes = array ( $line_item_codes ); |
|
914 | + $line_item_codes = array($line_item_codes); |
|
915 | 915 | } |
916 | 916 | $removals = 0; |
917 | 917 | // cycle thru line_item_ids |
918 | - foreach ( $line_item_codes as $line_item_id ) { |
|
918 | + foreach ($line_item_codes as $line_item_id) { |
|
919 | 919 | $removals += $total_line_item->delete_child_line_item($line_item_id); |
920 | 920 | } |
921 | 921 | |
922 | - if ( $removals > 0 ) { |
|
922 | + if ($removals > 0) { |
|
923 | 923 | $total_line_item->recalculate_taxes_and_tax_total(); |
924 | 924 | return $removals; |
925 | 925 | } else { |
@@ -952,33 +952,33 @@ discard block |
||
952 | 952 | $code = null, |
953 | 953 | $add_to_existing_line_item = false |
954 | 954 | ) { |
955 | - $tax_subtotal = self::get_taxes_subtotal( $total_line_item ); |
|
955 | + $tax_subtotal = self::get_taxes_subtotal($total_line_item); |
|
956 | 956 | $taxable_total = $total_line_item->taxable_total(); |
957 | 957 | |
958 | - if( $add_to_existing_line_item ) { |
|
959 | - $new_tax = $tax_subtotal->get_child_line_item( $code ); |
|
958 | + if ($add_to_existing_line_item) { |
|
959 | + $new_tax = $tax_subtotal->get_child_line_item($code); |
|
960 | 960 | EEM_Line_Item::instance()->delete( |
961 | - array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) ) |
|
961 | + array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID())) |
|
962 | 962 | ); |
963 | 963 | } else { |
964 | 964 | $new_tax = null; |
965 | 965 | $tax_subtotal->delete_children_line_items(); |
966 | 966 | } |
967 | - if( $new_tax ) { |
|
968 | - $new_tax->set_total( $new_tax->total() + $amount ); |
|
969 | - $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 ); |
|
967 | + if ($new_tax) { |
|
968 | + $new_tax->set_total($new_tax->total() + $amount); |
|
969 | + $new_tax->set_percent($taxable_total ? $new_tax->total() / $taxable_total * 100 : 0); |
|
970 | 970 | } else { |
971 | 971 | //no existing tax item. Create it |
972 | - $new_tax = EE_Line_Item::new_instance( array( |
|
972 | + $new_tax = EE_Line_Item::new_instance(array( |
|
973 | 973 | 'TXN_ID' => $total_line_item->TXN_ID(), |
974 | - 'LIN_name' => $name ? $name : __( 'Tax', 'event_espresso' ), |
|
974 | + 'LIN_name' => $name ? $name : __('Tax', 'event_espresso'), |
|
975 | 975 | 'LIN_desc' => $description ? $description : '', |
976 | - 'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0, |
|
976 | + 'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0, |
|
977 | 977 | 'LIN_total' => $amount, |
978 | 978 | 'LIN_parent' => $tax_subtotal->ID(), |
979 | 979 | 'LIN_type' => EEM_Line_Item::type_tax, |
980 | 980 | 'LIN_code' => $code |
981 | - ) ); |
|
981 | + )); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | $new_tax = apply_filters( |
@@ -987,7 +987,7 @@ discard block |
||
987 | 987 | $total_line_item |
988 | 988 | ); |
989 | 989 | $new_tax->save(); |
990 | - $tax_subtotal->set_total( $new_tax->total() ); |
|
990 | + $tax_subtotal->set_total($new_tax->total()); |
|
991 | 991 | $tax_subtotal->save(); |
992 | 992 | $total_line_item->recalculate_total_including_taxes(); |
993 | 993 | return $new_tax; |
@@ -1009,14 +1009,14 @@ discard block |
||
1009 | 1009 | $code_substring_for_whitelist = null |
1010 | 1010 | ) { |
1011 | 1011 | $whitelisted = false; |
1012 | - if( $code_substring_for_whitelist !== null ) { |
|
1013 | - $whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false; |
|
1012 | + if ($code_substring_for_whitelist !== null) { |
|
1013 | + $whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false; |
|
1014 | 1014 | } |
1015 | - if( ! $whitelisted && $line_item->is_line_item() ) { |
|
1016 | - $line_item->set_is_taxable( $taxable ); |
|
1015 | + if ( ! $whitelisted && $line_item->is_line_item()) { |
|
1016 | + $line_item->set_is_taxable($taxable); |
|
1017 | 1017 | } |
1018 | - foreach( $line_item->children() as $child_line_item ) { |
|
1019 | - EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist ); |
|
1018 | + foreach ($line_item->children() as $child_line_item) { |
|
1019 | + EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist); |
|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | |
@@ -1029,8 +1029,8 @@ discard block |
||
1029 | 1029 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1030 | 1030 | * @return EE_Line_Item[] |
1031 | 1031 | */ |
1032 | - public static function get_event_subtotals( EE_Line_Item $parent_line_item ) { |
|
1033 | - return self::get_subtotals_of_object_type( $parent_line_item, 'Event' ); |
|
1032 | + public static function get_event_subtotals(EE_Line_Item $parent_line_item) { |
|
1033 | + return self::get_subtotals_of_object_type($parent_line_item, 'Event'); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | * @param string $obj_type |
1044 | 1044 | * @return EE_Line_Item[] |
1045 | 1045 | */ |
1046 | - public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1046 | + public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1047 | 1047 | return self::_get_descendants_by_type_and_object_type( |
1048 | 1048 | $parent_line_item, |
1049 | 1049 | EEM_Line_Item::type_sub_total, |
@@ -1060,8 +1060,8 @@ discard block |
||
1060 | 1060 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1061 | 1061 | * @return EE_Line_Item[] |
1062 | 1062 | */ |
1063 | - public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) { |
|
1064 | - return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' ); |
|
1063 | + public static function get_ticket_line_items(EE_Line_Item $parent_line_item) { |
|
1064 | + return self::get_line_items_of_object_type($parent_line_item, 'Ticket'); |
|
1065 | 1065 | } |
1066 | 1066 | |
1067 | 1067 | |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @param string $obj_type |
1075 | 1075 | * @return EE_Line_Item[] |
1076 | 1076 | */ |
1077 | - public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) { |
|
1078 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type ); |
|
1077 | + public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') { |
|
1078 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | |
@@ -1086,8 +1086,8 @@ discard block |
||
1086 | 1086 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1087 | 1087 | * @return EE_Line_Item[] |
1088 | 1088 | */ |
1089 | - public static function get_tax_descendants( EE_Line_Item $parent_line_item ) { |
|
1090 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax ); |
|
1089 | + public static function get_tax_descendants(EE_Line_Item $parent_line_item) { |
|
1090 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax); |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @param \EE_Line_Item $parent_line_item - the line item to find descendants of |
1099 | 1099 | * @return EE_Line_Item[] |
1100 | 1100 | */ |
1101 | - public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) { |
|
1102 | - return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item ); |
|
1101 | + public static function get_line_item_descendants(EE_Line_Item $parent_line_item) { |
|
1102 | + return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * @param string $line_item_type one of the EEM_Line_Item constants |
1113 | 1113 | * @return EE_Line_Item[] |
1114 | 1114 | */ |
1115 | - public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) { |
|
1116 | - return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL ); |
|
1115 | + public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) { |
|
1116 | + return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | |
@@ -1132,8 +1132,8 @@ discard block |
||
1132 | 1132 | $obj_type = null |
1133 | 1133 | ) { |
1134 | 1134 | $objects = array(); |
1135 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1136 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1135 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1136 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1137 | 1137 | if ( |
1138 | 1138 | $child_line_item->type() === $line_item_type |
1139 | 1139 | && ( |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | $OBJ_type = '', |
1174 | 1174 | $OBJ_IDs = array() |
1175 | 1175 | ) { |
1176 | - return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs ); |
|
1176 | + return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | |
@@ -1192,12 +1192,12 @@ discard block |
||
1192 | 1192 | $OBJ_IDs |
1193 | 1193 | ) { |
1194 | 1194 | $objects = array(); |
1195 | - foreach ( $parent_line_item->children() as $child_line_item ) { |
|
1196 | - if ( $child_line_item instanceof EE_Line_Item ) { |
|
1195 | + foreach ($parent_line_item->children() as $child_line_item) { |
|
1196 | + if ($child_line_item instanceof EE_Line_Item) { |
|
1197 | 1197 | if ( |
1198 | 1198 | $child_line_item->OBJ_type() === $OBJ_type |
1199 | - && is_array( $OBJ_IDs ) |
|
1200 | - && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs ) |
|
1199 | + && is_array($OBJ_IDs) |
|
1200 | + && in_array($child_line_item->OBJ_ID(), $OBJ_IDs) |
|
1201 | 1201 | ) { |
1202 | 1202 | $objects[] = $child_line_item; |
1203 | 1203 | } else { |
@@ -1227,8 +1227,8 @@ discard block |
||
1227 | 1227 | * @param string $type like one of the EEM_Line_Item::type_* |
1228 | 1228 | * @return EE_Line_Item |
1229 | 1229 | */ |
1230 | - public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) { |
|
1231 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type ); |
|
1230 | + public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) { |
|
1231 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1242,8 +1242,8 @@ discard block |
||
1242 | 1242 | * @param string $code any value used for LIN_code |
1243 | 1243 | * @return EE_Line_Item |
1244 | 1244 | */ |
1245 | - public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) { |
|
1246 | - return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code ); |
|
1245 | + public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) { |
|
1246 | + return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code); |
|
1247 | 1247 | } |
1248 | 1248 | |
1249 | 1249 | |
@@ -1257,15 +1257,15 @@ discard block |
||
1257 | 1257 | * @param string $value any value stored in $search_field |
1258 | 1258 | * @return EE_Line_Item |
1259 | 1259 | */ |
1260 | - protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) { |
|
1261 | - foreach( $parent_line_item->children() as $child ){ |
|
1262 | - if ( $child->get( $search_field ) == $value ){ |
|
1260 | + protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) { |
|
1261 | + foreach ($parent_line_item->children() as $child) { |
|
1262 | + if ($child->get($search_field) == $value) { |
|
1263 | 1263 | return $child; |
1264 | 1264 | } |
1265 | 1265 | } |
1266 | - foreach( $parent_line_item->children() as $child ){ |
|
1267 | - $descendant_found = self::_get_nearest_descendant( $child, $search_field, $value ); |
|
1268 | - if ( $descendant_found ){ |
|
1266 | + foreach ($parent_line_item->children() as $child) { |
|
1267 | + $descendant_found = self::_get_nearest_descendant($child, $search_field, $value); |
|
1268 | + if ($descendant_found) { |
|
1269 | 1269 | return $descendant_found; |
1270 | 1270 | } |
1271 | 1271 | } |
@@ -1282,24 +1282,24 @@ discard block |
||
1282 | 1282 | * @return \EE_Line_Item |
1283 | 1283 | * @throws \EE_Error |
1284 | 1284 | */ |
1285 | - public static function find_transaction_grand_total_for_line_item( EE_Line_Item $line_item ){ |
|
1286 | - if ( $line_item->TXN_ID() ) { |
|
1287 | - $total_line_item = $line_item->transaction()->total_line_item( false ); |
|
1288 | - if ( $total_line_item instanceof EE_Line_Item ) { |
|
1285 | + public static function find_transaction_grand_total_for_line_item(EE_Line_Item $line_item) { |
|
1286 | + if ($line_item->TXN_ID()) { |
|
1287 | + $total_line_item = $line_item->transaction()->total_line_item(false); |
|
1288 | + if ($total_line_item instanceof EE_Line_Item) { |
|
1289 | 1289 | return $total_line_item; |
1290 | 1290 | } |
1291 | 1291 | } else { |
1292 | 1292 | $line_item_parent = $line_item->parent(); |
1293 | - if ( $line_item_parent instanceof EE_Line_Item ) { |
|
1294 | - if ( $line_item_parent->is_total() ) { |
|
1293 | + if ($line_item_parent instanceof EE_Line_Item) { |
|
1294 | + if ($line_item_parent->is_total()) { |
|
1295 | 1295 | return $line_item_parent; |
1296 | 1296 | } |
1297 | - return EEH_Line_Item::find_transaction_grand_total_for_line_item( $line_item_parent ); |
|
1297 | + return EEH_Line_Item::find_transaction_grand_total_for_line_item($line_item_parent); |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | throw new EE_Error( |
1301 | 1301 | sprintf( |
1302 | - __( 'A valid grand total for line item %1$d was not found.', 'event_espresso' ), |
|
1302 | + __('A valid grand total for line item %1$d was not found.', 'event_espresso'), |
|
1303 | 1303 | $line_item->ID() |
1304 | 1304 | ) |
1305 | 1305 | ); |
@@ -1316,31 +1316,31 @@ discard block |
||
1316 | 1316 | * @return void |
1317 | 1317 | * @throws \EE_Error |
1318 | 1318 | */ |
1319 | - public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){ |
|
1319 | + public static function visualize(EE_Line_Item $line_item, $indentation = 0) { |
|
1320 | 1320 | echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
1321 | - if ( ! $indentation ) { |
|
1322 | - echo defined( 'EE_TESTS_DIR' ) ? "\n" : '<br />'; |
|
1321 | + if ( ! $indentation) { |
|
1322 | + echo defined('EE_TESTS_DIR') ? "\n" : '<br />'; |
|
1323 | 1323 | } |
1324 | - for( $i = 0; $i < $indentation; $i++ ){ |
|
1324 | + for ($i = 0; $i < $indentation; $i++) { |
|
1325 | 1325 | echo ". "; |
1326 | 1326 | } |
1327 | 1327 | $breakdown = ''; |
1328 | - if ( $line_item->is_line_item()){ |
|
1329 | - if ( $line_item->is_percent() ) { |
|
1328 | + if ($line_item->is_line_item()) { |
|
1329 | + if ($line_item->is_percent()) { |
|
1330 | 1330 | $breakdown = "{$line_item->percent()}%"; |
1331 | 1331 | } else { |
1332 | - $breakdown = '$' . "{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1332 | + $breakdown = '$'."{$line_item->unit_price()} x {$line_item->quantity()}"; |
|
1333 | 1333 | } |
1334 | 1334 | } |
1335 | - echo $line_item->name() . " ( ID:{$line_item->ID()} ) : {$line_item->type()} " . '$' . "{$line_item->total()}"; |
|
1336 | - if ( $breakdown ) { |
|
1335 | + echo $line_item->name()." ( ID:{$line_item->ID()} ) : {$line_item->type()} ".'$'."{$line_item->total()}"; |
|
1336 | + if ($breakdown) { |
|
1337 | 1337 | echo " ( {$breakdown} )"; |
1338 | 1338 | } |
1339 | - if( $line_item->is_taxable() ){ |
|
1339 | + if ($line_item->is_taxable()) { |
|
1340 | 1340 | echo " * taxable"; |
1341 | 1341 | } |
1342 | - if( $line_item->children() ){ |
|
1343 | - foreach($line_item->children() as $child){ |
|
1342 | + if ($line_item->children()) { |
|
1343 | + foreach ($line_item->children() as $child) { |
|
1344 | 1344 | self::visualize($child, $indentation + 1); |
1345 | 1345 | } |
1346 | 1346 | } |
@@ -1381,97 +1381,97 @@ discard block |
||
1381 | 1381 | * is theirs, which can be done with |
1382 | 1382 | * `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );` |
1383 | 1383 | */ |
1384 | - public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) { |
|
1384 | + public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) { |
|
1385 | 1385 | //init running grand total if not already |
1386 | - if ( ! isset( $running_totals[ 'total' ] ) ) { |
|
1387 | - $running_totals[ 'total' ] = 0; |
|
1386 | + if ( ! isset($running_totals['total'])) { |
|
1387 | + $running_totals['total'] = 0; |
|
1388 | 1388 | } |
1389 | - if( ! isset( $running_totals[ 'taxable' ] ) ) { |
|
1390 | - $running_totals[ 'taxable' ] = array( 'total' => 0 ); |
|
1389 | + if ( ! isset($running_totals['taxable'])) { |
|
1390 | + $running_totals['taxable'] = array('total' => 0); |
|
1391 | 1391 | } |
1392 | - foreach ( $line_item->children() as $child_line_item ) { |
|
1393 | - switch ( $child_line_item->type() ) { |
|
1392 | + foreach ($line_item->children() as $child_line_item) { |
|
1393 | + switch ($child_line_item->type()) { |
|
1394 | 1394 | |
1395 | 1395 | case EEM_Line_Item::type_sub_total : |
1396 | - $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities ); |
|
1396 | + $running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities); |
|
1397 | 1397 | //combine arrays but preserve numeric keys |
1398 | - $running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals ); |
|
1399 | - $running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ]; |
|
1400 | - $running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ]; |
|
1398 | + $running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals); |
|
1399 | + $running_totals['total'] += $running_totals_from_subtotal['total']; |
|
1400 | + $running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total']; |
|
1401 | 1401 | break; |
1402 | 1402 | |
1403 | 1403 | case EEM_Line_Item::type_tax_sub_total : |
1404 | 1404 | |
1405 | 1405 | //find how much the taxes percentage is |
1406 | - if ( $child_line_item->percent() !== 0 ) { |
|
1406 | + if ($child_line_item->percent() !== 0) { |
|
1407 | 1407 | $tax_percent_decimal = $child_line_item->percent() / 100; |
1408 | 1408 | } else { |
1409 | 1409 | $tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100; |
1410 | 1410 | } |
1411 | 1411 | //and apply to all the taxable totals, and add to the pretax totals |
1412 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1412 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1413 | 1413 | //"total" and "taxable" array key is an exception |
1414 | - if ( $line_item_id === 'taxable' ) { |
|
1414 | + if ($line_item_id === 'taxable') { |
|
1415 | 1415 | continue; |
1416 | 1416 | } |
1417 | - $taxable_total = $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1418 | - $running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal ); |
|
1417 | + $taxable_total = $running_totals['taxable'][$line_item_id]; |
|
1418 | + $running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal); |
|
1419 | 1419 | } |
1420 | 1420 | break; |
1421 | 1421 | |
1422 | 1422 | case EEM_Line_Item::type_line_item : |
1423 | 1423 | |
1424 | 1424 | // ticket line items or ???? |
1425 | - if ( $child_line_item->OBJ_type() === 'Ticket' ) { |
|
1425 | + if ($child_line_item->OBJ_type() === 'Ticket') { |
|
1426 | 1426 | // kk it's a ticket |
1427 | - if ( isset( $running_totals[ $child_line_item->ID() ] ) ) { |
|
1427 | + if (isset($running_totals[$child_line_item->ID()])) { |
|
1428 | 1428 | //huh? that shouldn't happen. |
1429 | - $running_totals[ 'total' ] += $child_line_item->total(); |
|
1429 | + $running_totals['total'] += $child_line_item->total(); |
|
1430 | 1430 | } else { |
1431 | 1431 | //its not in our running totals yet. great. |
1432 | - if ( $child_line_item->is_taxable() ) { |
|
1432 | + if ($child_line_item->is_taxable()) { |
|
1433 | 1433 | $taxable_amount = $child_line_item->unit_price(); |
1434 | 1434 | } else { |
1435 | 1435 | $taxable_amount = 0; |
1436 | 1436 | } |
1437 | 1437 | // are we only calculating totals for some tickets? |
1438 | - if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) { |
|
1439 | - $quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ]; |
|
1440 | - $running_totals[ $child_line_item->ID() ] = $quantity |
|
1438 | + if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) { |
|
1439 | + $quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()]; |
|
1440 | + $running_totals[$child_line_item->ID()] = $quantity |
|
1441 | 1441 | ? $child_line_item->unit_price() |
1442 | 1442 | : 0; |
1443 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity |
|
1443 | + $running_totals['taxable'][$child_line_item->ID()] = $quantity |
|
1444 | 1444 | ? $taxable_amount |
1445 | 1445 | : 0; |
1446 | 1446 | } else { |
1447 | 1447 | $quantity = $child_line_item->quantity(); |
1448 | - $running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price(); |
|
1449 | - $running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount; |
|
1448 | + $running_totals[$child_line_item->ID()] = $child_line_item->unit_price(); |
|
1449 | + $running_totals['taxable'][$child_line_item->ID()] = $taxable_amount; |
|
1450 | 1450 | } |
1451 | - $running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity; |
|
1452 | - $running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity; |
|
1451 | + $running_totals['taxable']['total'] += $taxable_amount * $quantity; |
|
1452 | + $running_totals['total'] += $child_line_item->unit_price() * $quantity; |
|
1453 | 1453 | } |
1454 | 1454 | } else { |
1455 | 1455 | // it's some other type of item added to the cart |
1456 | 1456 | // it should affect the running totals |
1457 | 1457 | // basically we want to convert it into a PERCENT modifier. Because |
1458 | 1458 | // more clearly affect all registration's final price equally |
1459 | - $line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 |
|
1460 | - ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 |
|
1459 | + $line_items_percent_of_running_total = $running_totals['total'] > 0 |
|
1460 | + ? ($child_line_item->total() / $running_totals['total']) + 1 |
|
1461 | 1461 | : 1; |
1462 | - foreach ( $running_totals as $line_item_id => $this_running_total ) { |
|
1462 | + foreach ($running_totals as $line_item_id => $this_running_total) { |
|
1463 | 1463 | //the "taxable" array key is an exception |
1464 | - if ( $line_item_id === 'taxable' ) { |
|
1464 | + if ($line_item_id === 'taxable') { |
|
1465 | 1465 | continue; |
1466 | 1466 | } |
1467 | 1467 | // update the running totals |
1468 | 1468 | // yes this actually even works for the running grand total! |
1469 | - $running_totals[ $line_item_id ] = |
|
1469 | + $running_totals[$line_item_id] = |
|
1470 | 1470 | $line_items_percent_of_running_total * $this_running_total; |
1471 | 1471 | |
1472 | - if ( $child_line_item->is_taxable() ) { |
|
1473 | - $running_totals[ 'taxable' ][ $line_item_id ] = |
|
1474 | - $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ]; |
|
1472 | + if ($child_line_item->is_taxable()) { |
|
1473 | + $running_totals['taxable'][$line_item_id] = |
|
1474 | + $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id]; |
|
1475 | 1475 | } |
1476 | 1476 | } |
1477 | 1477 | } |
@@ -1489,16 +1489,16 @@ discard block |
||
1489 | 1489 | * @return float | null |
1490 | 1490 | * @throws \OutOfRangeException |
1491 | 1491 | */ |
1492 | - public static function calculate_final_price_for_ticket_line_item( \EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item ) { |
|
1492 | + public static function calculate_final_price_for_ticket_line_item(\EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item) { |
|
1493 | 1493 | static $final_prices_per_ticket_line_item = array(); |
1494 | - if ( empty( $final_prices_per_ticket_line_item ) ) { |
|
1494 | + if (empty($final_prices_per_ticket_line_item)) { |
|
1495 | 1495 | $final_prices_per_ticket_line_item = \EEH_Line_Item::calculate_reg_final_prices_per_line_item( |
1496 | 1496 | $total_line_item |
1497 | 1497 | ); |
1498 | 1498 | } |
1499 | 1499 | //ok now find this new registration's final price |
1500 | - if ( isset( $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ] ) ) { |
|
1501 | - return $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ]; |
|
1500 | + if (isset($final_prices_per_ticket_line_item[$ticket_line_item->ID()])) { |
|
1501 | + return $final_prices_per_ticket_line_item[$ticket_line_item->ID()]; |
|
1502 | 1502 | } |
1503 | 1503 | $message = sprintf( |
1504 | 1504 | __( |
@@ -1507,10 +1507,10 @@ discard block |
||
1507 | 1507 | ), |
1508 | 1508 | $ticket_line_item->ID() |
1509 | 1509 | ); |
1510 | - if ( WP_DEBUG ) { |
|
1511 | - throw new \OutOfRangeException( $message ); |
|
1510 | + if (WP_DEBUG) { |
|
1511 | + throw new \OutOfRangeException($message); |
|
1512 | 1512 | } else { |
1513 | - EE_Log::instance()->log( __CLASS__, __FUNCTION__, $message ); |
|
1513 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
1514 | 1514 | } |
1515 | 1515 | return null; |
1516 | 1516 | } |
@@ -1526,15 +1526,15 @@ discard block |
||
1526 | 1526 | * @return \EE_Line_Item |
1527 | 1527 | * @throws \EE_Error |
1528 | 1528 | */ |
1529 | - public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) { |
|
1530 | - $copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations ); |
|
1531 | - foreach ( $line_item->children() as $child_li ) { |
|
1532 | - $copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) ); |
|
1529 | + public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) { |
|
1530 | + $copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations); |
|
1531 | + foreach ($line_item->children() as $child_li) { |
|
1532 | + $copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations)); |
|
1533 | 1533 | } |
1534 | 1534 | //if this is the grand total line item, make sure the totals all add up |
1535 | 1535 | //(we could have duplicated this logic AS we copied the line items, but |
1536 | 1536 | //it seems DRYer this way) |
1537 | - if ( $copy_li->type() === EEM_Line_Item::type_total ) { |
|
1537 | + if ($copy_li->type() === EEM_Line_Item::type_total) { |
|
1538 | 1538 | $copy_li->recalculate_total_including_taxes(); |
1539 | 1539 | } |
1540 | 1540 | return $copy_li; |
@@ -1551,24 +1551,24 @@ discard block |
||
1551 | 1551 | * @throws \EE_Error |
1552 | 1552 | * @param EE_Registration[] $registrations |
1553 | 1553 | */ |
1554 | - public static function billable_line_item( EE_Line_Item $line_item, $registrations ) { |
|
1554 | + public static function billable_line_item(EE_Line_Item $line_item, $registrations) { |
|
1555 | 1555 | $new_li_fields = $line_item->model_field_array(); |
1556 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1556 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1557 | 1557 | $line_item->OBJ_type() === 'Ticket' |
1558 | 1558 | ) { |
1559 | 1559 | $count = 0; |
1560 | - foreach ( $registrations as $registration ) { |
|
1561 | - if ( $line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1562 | - in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() ) |
|
1560 | + foreach ($registrations as $registration) { |
|
1561 | + if ($line_item->OBJ_ID() === $registration->ticket_ID() && |
|
1562 | + in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment()) |
|
1563 | 1563 | ) { |
1564 | 1564 | $count++; |
1565 | 1565 | } |
1566 | 1566 | } |
1567 | - $new_li_fields[ 'LIN_quantity' ] = $count; |
|
1567 | + $new_li_fields['LIN_quantity'] = $count; |
|
1568 | 1568 | } |
1569 | 1569 | //don't set the total. We'll leave that up to the code that calculates it |
1570 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ], $new_li_fields[ 'LIN_total' ] ); |
|
1571 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1570 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent'], $new_li_fields['LIN_total']); |
|
1571 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1572 | 1572 | } |
1573 | 1573 | |
1574 | 1574 | |
@@ -1581,19 +1581,19 @@ discard block |
||
1581 | 1581 | * @return \EE_Line_Item|null |
1582 | 1582 | * @throws \EE_Error |
1583 | 1583 | */ |
1584 | - public static function non_empty_line_items( EE_Line_Item $line_item ) { |
|
1585 | - $copied_li = EEH_Line_Item::non_empty_line_item( $line_item ); |
|
1586 | - if ( $copied_li === null ) { |
|
1584 | + public static function non_empty_line_items(EE_Line_Item $line_item) { |
|
1585 | + $copied_li = EEH_Line_Item::non_empty_line_item($line_item); |
|
1586 | + if ($copied_li === null) { |
|
1587 | 1587 | return null; |
1588 | 1588 | } |
1589 | 1589 | //if this is an event subtotal, we want to only include it if it |
1590 | 1590 | //has a non-zero total and at least one ticket line item child |
1591 | 1591 | $ticket_children = 0; |
1592 | - foreach ( $line_item->children() as $child_li ) { |
|
1593 | - $child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li ); |
|
1594 | - if ( $child_li_copy !== null ) { |
|
1595 | - $copied_li->add_child_line_item( $child_li_copy ); |
|
1596 | - if ( $child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1592 | + foreach ($line_item->children() as $child_li) { |
|
1593 | + $child_li_copy = EEH_Line_Item::non_empty_line_items($child_li); |
|
1594 | + if ($child_li_copy !== null) { |
|
1595 | + $copied_li->add_child_line_item($child_li_copy); |
|
1596 | + if ($child_li_copy->type() === EEM_Line_Item::type_line_item && |
|
1597 | 1597 | $child_li_copy->OBJ_type() === 'Ticket' |
1598 | 1598 | ) { |
1599 | 1599 | $ticket_children++; |
@@ -1623,8 +1623,8 @@ discard block |
||
1623 | 1623 | * @return EE_Line_Item |
1624 | 1624 | * @throws \EE_Error |
1625 | 1625 | */ |
1626 | - public static function non_empty_line_item( EE_Line_Item $line_item ) { |
|
1627 | - if ( $line_item->type() === EEM_Line_Item::type_line_item && |
|
1626 | + public static function non_empty_line_item(EE_Line_Item $line_item) { |
|
1627 | + if ($line_item->type() === EEM_Line_Item::type_line_item && |
|
1628 | 1628 | $line_item->OBJ_type() === 'Ticket' && |
1629 | 1629 | $line_item->quantity() === 0 |
1630 | 1630 | ) { |
@@ -1632,8 +1632,8 @@ discard block |
||
1632 | 1632 | } |
1633 | 1633 | $new_li_fields = $line_item->model_field_array(); |
1634 | 1634 | //don't set the total. We'll leave that up to the code that calculates it |
1635 | - unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ] ); |
|
1636 | - return EE_Line_Item::new_instance( $new_li_fields ); |
|
1635 | + unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent']); |
|
1636 | + return EE_Line_Item::new_instance($new_li_fields); |
|
1637 | 1637 | } |
1638 | 1638 | |
1639 | 1639 | |
@@ -1645,9 +1645,9 @@ discard block |
||
1645 | 1645 | * @return \EE_Line_Item |
1646 | 1646 | * @throws \EE_Error |
1647 | 1647 | */ |
1648 | - public static function get_items_subtotal( EE_Line_Item $total_line_item ){ |
|
1649 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1650 | - return self::get_pre_tax_subtotal( $total_line_item ); |
|
1648 | + public static function get_items_subtotal(EE_Line_Item $total_line_item) { |
|
1649 | + EE_Error::doing_it_wrong('EEH_Line_Item::get_items_subtotal()', __('Method replaced with EEH_Line_Item::get_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1650 | + return self::get_pre_tax_subtotal($total_line_item); |
|
1651 | 1651 | } |
1652 | 1652 | |
1653 | 1653 | |
@@ -1658,9 +1658,9 @@ discard block |
||
1658 | 1658 | * @return \EE_Line_Item |
1659 | 1659 | * @throws \EE_Error |
1660 | 1660 | */ |
1661 | - public static function create_default_total_line_item( $transaction = NULL) { |
|
1662 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0' ); |
|
1663 | - return self::create_total_line_item( $transaction ); |
|
1661 | + public static function create_default_total_line_item($transaction = NULL) { |
|
1662 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_total_line_item()', __('Method replaced with EEH_Line_Item::create_total_line_item()', 'event_espresso'), '4.6.0'); |
|
1663 | + return self::create_total_line_item($transaction); |
|
1664 | 1664 | } |
1665 | 1665 | |
1666 | 1666 | |
@@ -1672,9 +1672,9 @@ discard block |
||
1672 | 1672 | * @return \EE_Line_Item |
1673 | 1673 | * @throws \EE_Error |
1674 | 1674 | */ |
1675 | - public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1676 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1677 | - return self::create_pre_tax_subtotal( $total_line_item, $transaction ); |
|
1675 | + public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1676 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_tickets_subtotal()', __('Method replaced with EEH_Line_Item::create_pre_tax_subtotal()', 'event_espresso'), '4.6.0'); |
|
1677 | + return self::create_pre_tax_subtotal($total_line_item, $transaction); |
|
1678 | 1678 | } |
1679 | 1679 | |
1680 | 1680 | |
@@ -1686,9 +1686,9 @@ discard block |
||
1686 | 1686 | * @return \EE_Line_Item |
1687 | 1687 | * @throws \EE_Error |
1688 | 1688 | */ |
1689 | - public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1690 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1691 | - return self::create_taxes_subtotal( $total_line_item, $transaction ); |
|
1689 | + public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1690 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_taxes_subtotal()', __('Method replaced with EEH_Line_Item::create_taxes_subtotal()', 'event_espresso'), '4.6.0'); |
|
1691 | + return self::create_taxes_subtotal($total_line_item, $transaction); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | |
@@ -1700,9 +1700,9 @@ discard block |
||
1700 | 1700 | * @return \EE_Line_Item |
1701 | 1701 | * @throws \EE_Error |
1702 | 1702 | */ |
1703 | - public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1704 | - EE_Error::doing_it_wrong( 'EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0' ); |
|
1705 | - return self::create_event_subtotal( $total_line_item, $transaction ); |
|
1703 | + public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) { |
|
1704 | + EE_Error::doing_it_wrong('EEH_Line_Item::create_default_event_subtotal()', __('Method replaced with EEH_Line_Item::create_event_subtotal()', 'event_espresso'), '4.6.0'); |
|
1705 | + return self::create_event_subtotal($total_line_item, $transaction); |
|
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 |
@@ -884,12 +884,12 @@ discard block |
||
884 | 884 | if ( $registration instanceof EE_Registration ) { |
885 | 885 | // we display all attendee info for the primary registrant |
886 | 886 | if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
887 | - && $registration->is_primary_registrant() |
|
887 | + && $registration->is_primary_registrant() |
|
888 | 888 | ) { |
889 | 889 | $this->checkout->primary_revisit = true; |
890 | 890 | break; |
891 | 891 | } else if ( $this->checkout->revisit |
892 | - && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
892 | + && $this->checkout->reg_url_link !== $registration->reg_url_link() |
|
893 | 893 | ) { |
894 | 894 | // but hide info if it doesn't belong to you |
895 | 895 | $transaction->clear_cache( 'Registration', $registration->ID() ); |
@@ -921,23 +921,23 @@ discard block |
||
921 | 921 | //do the following for each ticket of this type they selected |
922 | 922 | for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
923 | 923 | $att_nmbr++; |
924 | - /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
925 | - $CreateRegistrationCommand = EE_Registry::instance() |
|
926 | - ->create( |
|
927 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
928 | - array( |
|
929 | - $transaction, |
|
930 | - $line_item, |
|
931 | - $att_nmbr, |
|
932 | - $this->checkout->total_ticket_count |
|
933 | - ) |
|
934 | - ); |
|
935 | - // override capabilities for frontend registrations |
|
936 | - if ( ! is_admin()) { |
|
937 | - $CreateRegistrationCommand->setCapCheck( |
|
938 | - new PublicCapabilities( '', 'create_new_registration' ) |
|
939 | - ); |
|
940 | - } |
|
924 | + /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
|
925 | + $CreateRegistrationCommand = EE_Registry::instance() |
|
926 | + ->create( |
|
927 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
928 | + array( |
|
929 | + $transaction, |
|
930 | + $line_item, |
|
931 | + $att_nmbr, |
|
932 | + $this->checkout->total_ticket_count |
|
933 | + ) |
|
934 | + ); |
|
935 | + // override capabilities for frontend registrations |
|
936 | + if ( ! is_admin()) { |
|
937 | + $CreateRegistrationCommand->setCapCheck( |
|
938 | + new PublicCapabilities( '', 'create_new_registration' ) |
|
939 | + ); |
|
940 | + } |
|
941 | 941 | $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
942 | 942 | if ( ! $registration instanceof EE_Registration ) { |
943 | 943 | throw new InvalidEntityException( $registration, 'EE_Registration' ); |
@@ -1344,8 +1344,8 @@ discard block |
||
1344 | 1344 | 'revisit' => $this->checkout->revisit, |
1345 | 1345 | 'reg_steps' => $this->checkout->reg_steps, |
1346 | 1346 | 'next_step' => $this->checkout->next_step instanceof EE_SPCO_Reg_Step |
1347 | - ? $this->checkout->next_step->slug() |
|
1348 | - : '', |
|
1347 | + ? $this->checkout->next_step->slug() |
|
1348 | + : '', |
|
1349 | 1349 | 'cancel_page_url' => $this->checkout->cancel_page_url, |
1350 | 1350 | 'empty_msg' => apply_filters( |
1351 | 1351 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\domain\services\capabilities\PublicCapabilities; |
2 | 2 | use EventEspresso\core\exceptions\InvalidEntityException; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
5 | 5 | /** |
6 | 6 | * Single Page Checkout (SPCO) |
7 | 7 | * |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | * @return EED_Single_Page_Checkout |
51 | 51 | */ |
52 | 52 | public static function instance() { |
53 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
54 | - return parent::get_instance( __CLASS__ ); |
|
53 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
54 | + return parent::get_instance(__CLASS__); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -96,22 +96,22 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public static function set_hooks_admin() { |
98 | 98 | EED_Single_Page_Checkout::set_definitions(); |
99 | - if ( defined( 'DOING_AJAX' )) { |
|
99 | + if (defined('DOING_AJAX')) { |
|
100 | 100 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
101 | 101 | ob_start(); |
102 | 102 | EED_Single_Page_Checkout::load_request_handler(); |
103 | 103 | EED_Single_Page_Checkout::load_reg_steps(); |
104 | 104 | } else { |
105 | 105 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
106 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
106 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
107 | 107 | } |
108 | 108 | // set ajax hooks |
109 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
110 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
111 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
112 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
113 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
114 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
109 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
110 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
111 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
112 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
113 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
114 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param string $ajax_action |
123 | 123 | * @throws \EE_Error |
124 | 124 | */ |
125 | - public static function process_ajax_request( $ajax_action ) { |
|
126 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
125 | + public static function process_ajax_request($ajax_action) { |
|
126 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
127 | 127 | EED_Single_Page_Checkout::instance()->_initialize(); |
128 | 128 | } |
129 | 129 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @throws \EE_Error |
136 | 136 | */ |
137 | 137 | public static function display_reg_step() { |
138 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
138 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @throws \EE_Error |
147 | 147 | */ |
148 | 148 | public static function process_reg_step() { |
149 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
149 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @throws \EE_Error |
158 | 158 | */ |
159 | 159 | public static function update_reg_step() { |
160 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
160 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @throws \EE_Error |
171 | 171 | */ |
172 | 172 | public static function update_checkout() { |
173 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
173 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public static function load_request_handler() { |
185 | 185 | // load core Request_Handler class |
186 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
187 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
186 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
187 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
@@ -198,21 +198,21 @@ discard block |
||
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | 200 | public static function set_definitions() { |
201 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
202 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
203 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
204 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
205 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
206 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
207 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
208 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
209 | - EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ] = sprintf( |
|
210 | - __( '%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
201 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
202 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
203 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
204 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
205 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
206 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
207 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
208 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
209 | + EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
|
210 | + __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
211 | 211 | '<h4 class="important-notice">', |
212 | 212 | '</h4>', |
213 | 213 | '<br />', |
214 | 214 | '<p>', |
215 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
215 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
216 | 216 | '">', |
217 | 217 | '</a>', |
218 | 218 | '</p>' |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public static function load_reg_steps() { |
233 | 233 | static $reg_steps_loaded = FALSE; |
234 | - if ( $reg_steps_loaded ) { |
|
234 | + if ($reg_steps_loaded) { |
|
235 | 235 | return; |
236 | 236 | } |
237 | 237 | // filter list of reg_steps |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | EED_Single_Page_Checkout::get_reg_steps() |
241 | 241 | ); |
242 | 242 | // sort by key (order) |
243 | - ksort( $reg_steps_to_load ); |
|
243 | + ksort($reg_steps_to_load); |
|
244 | 244 | // loop through folders |
245 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
245 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
246 | 246 | // we need a |
247 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
247 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
248 | 248 | // copy over to the reg_steps_array |
249 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
249 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
250 | 250 | // register custom key route for each reg step |
251 | 251 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
252 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
252 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
253 | 253 | // add AJAX or other hooks |
254 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
254 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
255 | 255 | // setup autoloaders if necessary |
256 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
257 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
256 | + if ( ! class_exists($reg_step['class_name'])) { |
|
257 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
258 | 258 | } |
259 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
260 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
259 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
260 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
261 | 261 | } |
262 | 262 | } |
263 | 263 | } |
@@ -276,28 +276,28 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public static function get_reg_steps() { |
278 | 278 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
279 | - if ( empty( $reg_steps )) { |
|
279 | + if (empty($reg_steps)) { |
|
280 | 280 | $reg_steps = array( |
281 | 281 | 10 => array( |
282 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
282 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
283 | 283 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
284 | 284 | 'slug' => 'attendee_information', |
285 | 285 | 'has_hooks' => FALSE |
286 | 286 | ), |
287 | 287 | 20 => array( |
288 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
288 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
289 | 289 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
290 | 290 | 'slug' => 'registration_confirmation', |
291 | 291 | 'has_hooks' => FALSE |
292 | 292 | ), |
293 | 293 | 30 => array( |
294 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
294 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
295 | 295 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
296 | 296 | 'slug' => 'payment_options', |
297 | 297 | 'has_hooks' => TRUE |
298 | 298 | ), |
299 | 299 | 999 => array( |
300 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
300 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
301 | 301 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
302 | 302 | 'slug' => 'finalize_registration', |
303 | 303 | 'has_hooks' => FALSE |
@@ -318,9 +318,9 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public static function registration_checkout_for_admin() { |
320 | 320 | EED_Single_Page_Checkout::load_reg_steps(); |
321 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
322 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
323 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
321 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
322 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
323 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
324 | 324 | EED_Single_Page_Checkout::instance()->_initialize(); |
325 | 325 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
326 | 326 | return EE_Registry::instance()->REQ->get_output(); |
@@ -337,15 +337,15 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public static function process_registration_from_admin() { |
339 | 339 | EED_Single_Page_Checkout::load_reg_steps(); |
340 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
341 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
342 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
340 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
341 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
342 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
343 | 343 | EED_Single_Page_Checkout::instance()->_initialize(); |
344 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
345 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
346 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
347 | - EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated( $final_reg_step ); |
|
348 | - if ( $final_reg_step->process_reg_step() ) { |
|
344 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
345 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
346 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
347 | + EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step); |
|
348 | + if ($final_reg_step->process_reg_step()) { |
|
349 | 349 | $final_reg_step->set_completed(); |
350 | 350 | EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array(); |
351 | 351 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | * @return void |
366 | 366 | * @throws \EE_Error |
367 | 367 | */ |
368 | - public function run( $WP_Query ) { |
|
368 | + public function run($WP_Query) { |
|
369 | 369 | if ( |
370 | 370 | $WP_Query instanceof WP_Query |
371 | 371 | && $WP_Query->is_main_query() |
372 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
372 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
373 | 373 | ) { |
374 | 374 | $this->_initialize(); |
375 | 375 | } |
@@ -385,8 +385,8 @@ discard block |
||
385 | 385 | * @return void |
386 | 386 | * @throws \EE_Error |
387 | 387 | */ |
388 | - public static function init( $WP_Query ) { |
|
389 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
388 | + public static function init($WP_Query) { |
|
389 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | private function _initialize() { |
402 | 402 | // ensure SPCO doesn't run twice |
403 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
403 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
404 | 404 | return; |
405 | 405 | } |
406 | 406 | try { |
@@ -408,22 +408,22 @@ discard block |
||
408 | 408 | // setup the EE_Checkout object |
409 | 409 | $this->checkout = $this->_initialize_checkout(); |
410 | 410 | // filter checkout |
411 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
411 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
412 | 412 | // get the $_GET |
413 | 413 | $this->_get_request_vars(); |
414 | 414 | // filter continue_reg |
415 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
415 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
416 | 416 | // load the reg steps array |
417 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
417 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
418 | 418 | EED_Single_Page_Checkout::$_initialized = true; |
419 | 419 | return; |
420 | 420 | } |
421 | 421 | // set the current step |
422 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
422 | + $this->checkout->set_current_step($this->checkout->step); |
|
423 | 423 | // and the next step |
424 | 424 | $this->checkout->set_next_step(); |
425 | 425 | // verify that everything has been setup correctly |
426 | - if ( ! ( $this->_verify_transaction_and_get_registrations() && $this->_final_verifications() ) ) { |
|
426 | + if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) { |
|
427 | 427 | EED_Single_Page_Checkout::$_initialized = true; |
428 | 428 | return; |
429 | 429 | } |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | // set no cache headers and constants |
449 | 449 | EE_System::do_not_cache(); |
450 | 450 | // add anchor |
451 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
451 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
452 | 452 | // remove transaction lock |
453 | - add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
|
454 | - } catch ( Exception $e ) { |
|
455 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ ); |
|
453 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
454 | + } catch (Exception $e) { |
|
455 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | |
@@ -466,16 +466,16 @@ discard block |
||
466 | 466 | * @throws EE_Error |
467 | 467 | */ |
468 | 468 | private function _verify_session() { |
469 | - if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) { |
|
470 | - throw new EE_Error( __( 'The EE_Session class could not be loaded.', 'event_espresso' ) ); |
|
469 | + if ( ! EE_Registry::instance()->SSN instanceof EE_Session) { |
|
470 | + throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso')); |
|
471 | 471 | } |
472 | 472 | // is session still valid ? |
473 | - if ( EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) === '' ) { |
|
473 | + if (EE_Registry::instance()->SSN->expired() && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === '') { |
|
474 | 474 | $this->checkout = new EE_Checkout(); |
475 | 475 | EE_Registry::instance()->SSN->reset_cart(); |
476 | 476 | EE_Registry::instance()->SSN->reset_checkout(); |
477 | 477 | EE_Registry::instance()->SSN->reset_transaction(); |
478 | - EE_Error::add_attention( EE_Registry::$i18n_js_strings[ 'registration_expiration_notice' ], __FILE__, __FUNCTION__, __LINE__ ); |
|
478 | + EE_Error::add_attention(EE_Registry::$i18n_js_strings['registration_expiration_notice'], __FILE__, __FUNCTION__, __LINE__); |
|
479 | 479 | EE_Registry::instance()->SSN->reset_expired(); |
480 | 480 | } |
481 | 481 | } |
@@ -495,20 +495,20 @@ discard block |
||
495 | 495 | /** @type EE_Checkout $checkout */ |
496 | 496 | $checkout = EE_Registry::instance()->SSN->checkout(); |
497 | 497 | // verify |
498 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
498 | + if ( ! $checkout instanceof EE_Checkout) { |
|
499 | 499 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
500 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
500 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
501 | 501 | } else { |
502 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
502 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
503 | 503 | $this->unlock_transaction(); |
504 | - wp_safe_redirect( $checkout->redirect_url ); |
|
504 | + wp_safe_redirect($checkout->redirect_url); |
|
505 | 505 | exit(); |
506 | 506 | } |
507 | 507 | } |
508 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
508 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
509 | 509 | // verify again |
510 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
511 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
510 | + if ( ! $checkout instanceof EE_Checkout) { |
|
511 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
512 | 512 | } |
513 | 513 | // reset anything that needs a clean slate for each request |
514 | 514 | $checkout->reset_for_current_request(); |
@@ -528,24 +528,24 @@ discard block |
||
528 | 528 | // load classes |
529 | 529 | EED_Single_Page_Checkout::load_request_handler(); |
530 | 530 | //make sure this request is marked as belonging to EE |
531 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
531 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
532 | 532 | // which step is being requested ? |
533 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
533 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
534 | 534 | // which step is being edited ? |
535 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
535 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
536 | 536 | // and what we're doing on the current step |
537 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
537 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
538 | 538 | // returning to edit ? |
539 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
539 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
540 | 540 | // or some other kind of revisit ? |
541 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
541 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
542 | 542 | // and whether or not to generate a reg form for this request |
543 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
543 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
544 | 544 | // and whether or not to process a reg form submission for this request |
545 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
545 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
546 | 546 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
547 | 547 | ? $this->checkout->process_form_submission |
548 | - : FALSE; // TRUE FALSE |
|
548 | + : FALSE; // TRUE FALSE |
|
549 | 549 | // $this->_display_request_vars(); |
550 | 550 | } |
551 | 551 | |
@@ -558,17 +558,17 @@ discard block |
||
558 | 558 | * @return void |
559 | 559 | */ |
560 | 560 | protected function _display_request_vars() { |
561 | - if ( ! WP_DEBUG ) { |
|
561 | + if ( ! WP_DEBUG) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
565 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
566 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
567 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
568 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
569 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
570 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
571 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
564 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
565 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
566 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
567 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
568 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
569 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
570 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
571 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | * @return array |
583 | 583 | */ |
584 | 584 | private function _get_first_step() { |
585 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
586 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
585 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
586 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -599,27 +599,27 @@ discard block |
||
599 | 599 | private function _load_and_instantiate_reg_steps() { |
600 | 600 | // have reg_steps already been instantiated ? |
601 | 601 | if ( |
602 | - empty( $this->checkout->reg_steps ) || |
|
603 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
602 | + empty($this->checkout->reg_steps) || |
|
603 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
604 | 604 | ) { |
605 | 605 | // if not, then loop through raw reg steps array |
606 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
607 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
606 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
607 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
608 | 608 | return false; |
609 | 609 | } |
610 | 610 | } |
611 | 611 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
612 | 612 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
613 | 613 | // skip the registration_confirmation page ? |
614 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
614 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
615 | 615 | // just remove it from the reg steps array |
616 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
616 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
617 | 617 | } else if ( |
618 | - isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
618 | + isset($this->checkout->reg_steps['registration_confirmation']) |
|
619 | 619 | && EE_Registry::instance()->CFG->registration->reg_confirmation_last |
620 | 620 | ) { |
621 | 621 | // set the order to something big like 100 |
622 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
622 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
623 | 623 | } |
624 | 624 | // filter the array for good luck |
625 | 625 | $this->checkout->reg_steps = apply_filters( |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | // finally re-sort based on the reg step class order properties |
630 | 630 | $this->checkout->sort_reg_steps(); |
631 | 631 | } else { |
632 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
632 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
633 | 633 | // set all current step stati to FALSE |
634 | - $reg_step->set_is_current_step( FALSE ); |
|
634 | + $reg_step->set_is_current_step(FALSE); |
|
635 | 635 | } |
636 | 636 | } |
637 | - if ( empty( $this->checkout->reg_steps )) { |
|
638 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
637 | + if (empty($this->checkout->reg_steps)) { |
|
638 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
639 | 639 | return false; |
640 | 640 | } |
641 | 641 | // make reg step details available to JS |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | * @param int $order |
654 | 654 | * @return bool |
655 | 655 | */ |
656 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
656 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
657 | 657 | |
658 | 658 | // we need a file_path, class_name, and slug to add a reg step |
659 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
659 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
660 | 660 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
661 | 661 | if ( |
662 | 662 | $this->checkout->reg_url_link |
@@ -674,26 +674,26 @@ discard block |
||
674 | 674 | FALSE |
675 | 675 | ); |
676 | 676 | // did we gets the goods ? |
677 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
677 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
678 | 678 | // set reg step order based on config |
679 | - $reg_step_obj->set_order( $order ); |
|
679 | + $reg_step_obj->set_order($order); |
|
680 | 680 | // add instantiated reg step object to the master reg steps array |
681 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
681 | + $this->checkout->add_reg_step($reg_step_obj); |
|
682 | 682 | } else { |
683 | 683 | EE_Error::add_error( |
684 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
684 | + __('The current step could not be set.', 'event_espresso'), |
|
685 | 685 | __FILE__, __FUNCTION__, __LINE__ |
686 | 686 | ); |
687 | 687 | return false; |
688 | 688 | } |
689 | 689 | } else { |
690 | - if ( WP_DEBUG ) { |
|
690 | + if (WP_DEBUG) { |
|
691 | 691 | EE_Error::add_error( |
692 | 692 | sprintf( |
693 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
694 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
695 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
696 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
693 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
694 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
695 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
696 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
697 | 697 | '<ul>', |
698 | 698 | '<li>', |
699 | 699 | '</li>', |
@@ -717,15 +717,15 @@ discard block |
||
717 | 717 | */ |
718 | 718 | private function _verify_transaction_and_get_registrations() { |
719 | 719 | // was there already a valid transaction in the checkout from the session ? |
720 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
720 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
721 | 721 | // get transaction from db or session |
722 | 722 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
723 | 723 | ? $this->_get_transaction_and_cart_for_previous_visit() |
724 | 724 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
725 | 725 | |
726 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
726 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
727 | 727 | EE_Error::add_error( |
728 | - __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
|
728 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
729 | 729 | __FILE__, __FUNCTION__, __LINE__ |
730 | 730 | ); |
731 | 731 | $this->checkout->transaction = EE_Transaction::new_instance(); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | return false; |
736 | 736 | } |
737 | 737 | // and the registrations for the transaction |
738 | - $this->_get_registrations( $this->checkout->transaction ); |
|
738 | + $this->_get_registrations($this->checkout->transaction); |
|
739 | 739 | } |
740 | 740 | return true; |
741 | 741 | } |
@@ -750,16 +750,16 @@ discard block |
||
750 | 750 | */ |
751 | 751 | private function _get_transaction_and_cart_for_previous_visit() { |
752 | 752 | /** @var $TXN_model EEM_Transaction */ |
753 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
753 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
754 | 754 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
755 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
755 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
756 | 756 | // verify transaction |
757 | - if ( $transaction instanceof EE_Transaction ) { |
|
757 | + if ($transaction instanceof EE_Transaction) { |
|
758 | 758 | // and get the cart that was used for that transaction |
759 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
759 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
760 | 760 | return $transaction; |
761 | 761 | } else { |
762 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
762 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
763 | 763 | return NULL; |
764 | 764 | } |
765 | 765 | } |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | * @param EE_Transaction $transaction |
774 | 774 | * @return EE_Cart |
775 | 775 | */ |
776 | - private function _get_cart_for_transaction( $transaction ) { |
|
777 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
776 | + private function _get_cart_for_transaction($transaction) { |
|
777 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -786,8 +786,8 @@ discard block |
||
786 | 786 | * @param EE_Transaction $transaction |
787 | 787 | * @return EE_Cart |
788 | 788 | */ |
789 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
790 | - return $this->checkout->get_cart_for_transaction( $transaction ); |
|
789 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
790 | + return $this->checkout->get_cart_for_transaction($transaction); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -803,15 +803,15 @@ discard block |
||
803 | 803 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
804 | 804 | // if there's no transaction, then this is the FIRST visit to SPCO |
805 | 805 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
806 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
806 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
807 | 807 | // and then create a new transaction |
808 | 808 | $transaction = $this->_initialize_transaction(); |
809 | 809 | // verify transaction |
810 | - if ( $transaction instanceof EE_Transaction ) { |
|
810 | + if ($transaction instanceof EE_Transaction) { |
|
811 | 811 | // and save TXN data to the cart |
812 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
812 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
813 | 813 | } else { |
814 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
814 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
815 | 815 | } |
816 | 816 | return $transaction; |
817 | 817 | } |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | $transaction->ID() |
848 | 848 | ); |
849 | 849 | return $transaction; |
850 | - } catch( Exception $e ) { |
|
851 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
850 | + } catch (Exception $e) { |
|
851 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
852 | 852 | } |
853 | 853 | return NULL; |
854 | 854 | } |
@@ -863,38 +863,38 @@ discard block |
||
863 | 863 | * @return EE_Cart |
864 | 864 | * @throws \EE_Error |
865 | 865 | */ |
866 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
866 | + private function _get_registrations(EE_Transaction $transaction) { |
|
867 | 867 | // first step: grab the registrants { : o |
868 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
868 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
869 | 869 | // verify registrations have been set |
870 | - if ( empty( $registrations )) { |
|
870 | + if (empty($registrations)) { |
|
871 | 871 | // if no cached registrations, then check the db |
872 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
872 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
873 | 873 | // still nothing ? well as long as this isn't a revisit |
874 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
874 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
875 | 875 | // generate new registrations from scratch |
876 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
876 | + $registrations = $this->_initialize_registrations($transaction); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | // sort by their original registration order |
880 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
880 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
881 | 881 | // then loop thru the array |
882 | - foreach ( $registrations as $registration ) { |
|
882 | + foreach ($registrations as $registration) { |
|
883 | 883 | // verify each registration |
884 | - if ( $registration instanceof EE_Registration ) { |
|
884 | + if ($registration instanceof EE_Registration) { |
|
885 | 885 | // we display all attendee info for the primary registrant |
886 | - if ( $this->checkout->reg_url_link === $registration->reg_url_link() |
|
886 | + if ($this->checkout->reg_url_link === $registration->reg_url_link() |
|
887 | 887 | && $registration->is_primary_registrant() |
888 | 888 | ) { |
889 | 889 | $this->checkout->primary_revisit = true; |
890 | 890 | break; |
891 | - } else if ( $this->checkout->revisit |
|
891 | + } else if ($this->checkout->revisit |
|
892 | 892 | && $this->checkout->reg_url_link !== $registration->reg_url_link() |
893 | 893 | ) { |
894 | 894 | // but hide info if it doesn't belong to you |
895 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
895 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
896 | 896 | } |
897 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
897 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
898 | 898 | } |
899 | 899 | } |
900 | 900 | } |
@@ -909,17 +909,17 @@ discard block |
||
909 | 909 | * @return array |
910 | 910 | * @throws \EE_Error |
911 | 911 | */ |
912 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
912 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
913 | 913 | $att_nmbr = 0; |
914 | 914 | $registrations = array(); |
915 | - if ( $transaction instanceof EE_Transaction ) { |
|
915 | + if ($transaction instanceof EE_Transaction) { |
|
916 | 916 | /** @type EE_Registration_Processor $registration_processor */ |
917 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
917 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
918 | 918 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
919 | 919 | // now let's add the cart items to the $transaction |
920 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
920 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
921 | 921 | //do the following for each ticket of this type they selected |
922 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
922 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
923 | 923 | $att_nmbr++; |
924 | 924 | /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */ |
925 | 925 | $CreateRegistrationCommand = EE_Registry::instance() |
@@ -935,17 +935,17 @@ discard block |
||
935 | 935 | // override capabilities for frontend registrations |
936 | 936 | if ( ! is_admin()) { |
937 | 937 | $CreateRegistrationCommand->setCapCheck( |
938 | - new PublicCapabilities( '', 'create_new_registration' ) |
|
938 | + new PublicCapabilities('', 'create_new_registration') |
|
939 | 939 | ); |
940 | 940 | } |
941 | - $registration = EE_Registry::instance()->BUS->execute( $CreateRegistrationCommand ); |
|
942 | - if ( ! $registration instanceof EE_Registration ) { |
|
943 | - throw new InvalidEntityException( $registration, 'EE_Registration' ); |
|
941 | + $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand); |
|
942 | + if ( ! $registration instanceof EE_Registration) { |
|
943 | + throw new InvalidEntityException($registration, 'EE_Registration'); |
|
944 | 944 | } |
945 | - $registrations[ $registration->ID() ] = $registration; |
|
945 | + $registrations[$registration->ID()] = $registration; |
|
946 | 946 | } |
947 | 947 | } |
948 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
948 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
949 | 949 | } |
950 | 950 | return $registrations; |
951 | 951 | } |
@@ -960,12 +960,12 @@ discard block |
||
960 | 960 | * @param EE_Registration $reg_B |
961 | 961 | * @return int |
962 | 962 | */ |
963 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
963 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
964 | 964 | // this shouldn't ever happen within the same TXN, but oh well |
965 | - if ( $reg_A->count() === $reg_B->count() ) { |
|
965 | + if ($reg_A->count() === $reg_B->count()) { |
|
966 | 966 | return 0; |
967 | 967 | } |
968 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
968 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | |
@@ -980,21 +980,21 @@ discard block |
||
980 | 980 | */ |
981 | 981 | private function _final_verifications() { |
982 | 982 | // filter checkout |
983 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
983 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
984 | 984 | //verify that current step is still set correctly |
985 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
986 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
985 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
986 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
987 | 987 | return false; |
988 | 988 | } |
989 | 989 | // if returning to SPCO, then verify that primary registrant is set |
990 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
990 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
991 | 991 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
992 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
993 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
992 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
993 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
994 | 994 | return false; |
995 | 995 | } |
996 | 996 | $valid_registrant = null; |
997 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
997 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
998 | 998 | if ( |
999 | 999 | $registration instanceof EE_Registration |
1000 | 1000 | && $registration->reg_url_link() === $this->checkout->reg_url_link |
@@ -1002,9 +1002,9 @@ discard block |
||
1002 | 1002 | $valid_registrant = $registration; |
1003 | 1003 | } |
1004 | 1004 | } |
1005 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
1005 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
1006 | 1006 | // hmmm... maybe we have the wrong session because the user is opening multiple tabs ? |
1007 | - if ( EED_Single_Page_Checkout::$_checkout_verified ) { |
|
1007 | + if (EED_Single_Page_Checkout::$_checkout_verified) { |
|
1008 | 1008 | // clear the session, mark the checkout as unverified, and try again |
1009 | 1009 | EE_Registry::instance()->SSN->clear_session(); |
1010 | 1010 | EED_Single_Page_Checkout::$_initialized = false; |
@@ -1013,13 +1013,13 @@ discard block |
||
1013 | 1013 | EE_Error::reset_notices(); |
1014 | 1014 | return false; |
1015 | 1015 | } |
1016 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1016 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | // now that things have been kinda sufficiently verified, |
1021 | 1021 | // let's add the checkout to the session so that's available other systems |
1022 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
1022 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
1023 | 1023 | return true; |
1024 | 1024 | } |
1025 | 1025 | |
@@ -1034,15 +1034,15 @@ discard block |
||
1034 | 1034 | * @param bool $reinitializing |
1035 | 1035 | * @throws \EE_Error |
1036 | 1036 | */ |
1037 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
1038 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
1037 | + private function _initialize_reg_steps($reinitializing = false) { |
|
1038 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
1039 | 1039 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
1040 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
1041 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
1040 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
1041 | + if ( ! $reg_step->initialize_reg_step()) { |
|
1042 | 1042 | // if not initialized then maybe this step is being removed... |
1043 | - if ( ! $reinitializing && $reg_step->is_current_step() ) { |
|
1043 | + if ( ! $reinitializing && $reg_step->is_current_step()) { |
|
1044 | 1044 | // if it was the current step, then we need to start over here |
1045 | - $this->_initialize_reg_steps( true ); |
|
1045 | + $this->_initialize_reg_steps(true); |
|
1046 | 1046 | return; |
1047 | 1047 | } |
1048 | 1048 | continue; |
@@ -1051,13 +1051,13 @@ discard block |
||
1051 | 1051 | $reg_step->enqueue_styles_and_scripts(); |
1052 | 1052 | // i18n |
1053 | 1053 | $reg_step->translate_js_strings(); |
1054 | - if ( $reg_step->is_current_step() ) { |
|
1054 | + if ($reg_step->is_current_step()) { |
|
1055 | 1055 | // the text that appears on the reg step form submit button |
1056 | 1056 | $reg_step->set_submit_button_text(); |
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
1060 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
1060 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | |
@@ -1070,43 +1070,43 @@ discard block |
||
1070 | 1070 | */ |
1071 | 1071 | private function _check_form_submission() { |
1072 | 1072 | //does this request require the reg form to be generated ? |
1073 | - if ( $this->checkout->generate_reg_form ) { |
|
1073 | + if ($this->checkout->generate_reg_form) { |
|
1074 | 1074 | // ever heard that song by Blue Rodeo ? |
1075 | 1075 | try { |
1076 | 1076 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
1077 | 1077 | // if not displaying a form, then check for form submission |
1078 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
1078 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
1079 | 1079 | // clear out any old data in case this step is being run again |
1080 | - $this->checkout->current_step->set_valid_data( array() ); |
|
1080 | + $this->checkout->current_step->set_valid_data(array()); |
|
1081 | 1081 | // capture submitted form data |
1082 | 1082 | $this->checkout->current_step->reg_form->receive_form_submission( |
1083 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
1083 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
1084 | 1084 | ); |
1085 | 1085 | // validate submitted form data |
1086 | - if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid() ) { |
|
1086 | + if ( ! $this->checkout->continue_reg && ! $this->checkout->current_step->reg_form->is_valid()) { |
|
1087 | 1087 | // thou shall not pass !!! |
1088 | 1088 | $this->checkout->continue_reg = FALSE; |
1089 | 1089 | // any form validation errors? |
1090 | - if ( $this->checkout->current_step->reg_form->submission_error_message() !== '' ) { |
|
1090 | + if ($this->checkout->current_step->reg_form->submission_error_message() !== '') { |
|
1091 | 1091 | $submission_error_messages = array(); |
1092 | 1092 | // bad, bad, bad registrant |
1093 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
1094 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
1093 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
1094 | + if ($validation_error instanceof EE_Validation_Error) { |
|
1095 | 1095 | $submission_error_messages[] = sprintf( |
1096 | - __( '%s : %s', 'event_espresso' ), |
|
1096 | + __('%s : %s', 'event_espresso'), |
|
1097 | 1097 | $validation_error->get_form_section()->html_label_text(), |
1098 | 1098 | $validation_error->getMessage() |
1099 | 1099 | ); |
1100 | 1100 | } |
1101 | 1101 | } |
1102 | - EE_Error::add_error( implode( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1102 | + EE_Error::add_error(implode('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
1103 | 1103 | } |
1104 | 1104 | // well not really... what will happen is we'll just get redirected back to redo the current step |
1105 | 1105 | $this->go_to_next_step(); |
1106 | 1106 | return; |
1107 | 1107 | } |
1108 | 1108 | } |
1109 | - } catch( EE_Error $e ) { |
|
1109 | + } catch (EE_Error $e) { |
|
1110 | 1110 | $e->get_error(); |
1111 | 1111 | } |
1112 | 1112 | } |
@@ -1123,22 +1123,22 @@ discard block |
||
1123 | 1123 | */ |
1124 | 1124 | private function _process_form_action() { |
1125 | 1125 | // what cha wanna do? |
1126 | - switch( $this->checkout->action ) { |
|
1126 | + switch ($this->checkout->action) { |
|
1127 | 1127 | // AJAX next step reg form |
1128 | 1128 | case 'display_spco_reg_step' : |
1129 | 1129 | $this->checkout->redirect = FALSE; |
1130 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1131 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1130 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1131 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1132 | 1132 | } |
1133 | 1133 | break; |
1134 | 1134 | |
1135 | 1135 | default : |
1136 | 1136 | // meh... do one of those other steps first |
1137 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1137 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1138 | 1138 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1139 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1139 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1140 | 1140 | // call action on current step |
1141 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1141 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1142 | 1142 | // good registrant, you get to proceed |
1143 | 1143 | if ( |
1144 | 1144 | $this->checkout->current_step->success_message() !== '' |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | ) { |
1150 | 1150 | EE_Error::add_success( |
1151 | 1151 | $this->checkout->current_step->success_message() |
1152 | - . '<br />' . $this->checkout->next_step->_instructions() |
|
1152 | + . '<br />'.$this->checkout->next_step->_instructions() |
|
1153 | 1153 | ); |
1154 | 1154 | |
1155 | 1155 | } |
@@ -1157,12 +1157,12 @@ discard block |
||
1157 | 1157 | $this->_setup_redirect(); |
1158 | 1158 | } |
1159 | 1159 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1160 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1160 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1161 | 1161 | |
1162 | 1162 | } else { |
1163 | 1163 | EE_Error::add_error( |
1164 | 1164 | sprintf( |
1165 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1165 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1166 | 1166 | $this->checkout->action, |
1167 | 1167 | $this->checkout->current_step->name() |
1168 | 1168 | ), |
@@ -1188,10 +1188,10 @@ discard block |
||
1188 | 1188 | public function add_styles_and_scripts() { |
1189 | 1189 | // i18n |
1190 | 1190 | $this->translate_js_strings(); |
1191 | - if ( $this->checkout->admin_request ) { |
|
1192 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1191 | + if ($this->checkout->admin_request) { |
|
1192 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1193 | 1193 | } else { |
1194 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1194 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1207,50 +1207,50 @@ discard block |
||
1207 | 1207 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1208 | 1208 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1209 | 1209 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1210 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1211 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1212 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1210 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1211 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1212 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1213 | 1213 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1214 | 1214 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1215 | 1215 | EE_Registry::$i18n_js_strings['process_registration'] = sprintf( |
1216 | - __( 'Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso' ), |
|
1216 | + __('Please wait while we process your registration.%1$sDo not refresh the page or navigate away while this is happening.%1$sThank you for your patience.', 'event_espresso'), |
|
1217 | 1217 | '<br/>' |
1218 | 1218 | ); |
1219 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1219 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1220 | 1220 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1221 | 1221 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1222 | 1222 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1223 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1224 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1225 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1226 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1227 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1228 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1229 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1230 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1231 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1232 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1233 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1234 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1235 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1236 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1223 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1224 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1225 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1226 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1227 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1228 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1229 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1230 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1231 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1232 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1233 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1234 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1235 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1236 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1237 | 1237 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1238 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1238 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1239 | 1239 | '<h4 class="important-notice">', |
1240 | 1240 | '</h4>', |
1241 | 1241 | '<br />', |
1242 | 1242 | '<p>', |
1243 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1243 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1244 | 1244 | '">', |
1245 | 1245 | '</a>', |
1246 | 1246 | '</p>' |
1247 | 1247 | ); |
1248 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1249 | - EE_Registry::$i18n_js_strings[ 'session_extension' ] = absint( |
|
1250 | - apply_filters( 'FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS ) |
|
1248 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1249 | + EE_Registry::$i18n_js_strings['session_extension'] = absint( |
|
1250 | + apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS) |
|
1251 | 1251 | ); |
1252 | - EE_Registry::$i18n_js_strings[ 'session_expiration' ] = gmdate( |
|
1253 | - 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) |
|
1252 | + EE_Registry::$i18n_js_strings['session_expiration'] = gmdate( |
|
1253 | + 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
1254 | 1254 | ); |
1255 | 1255 | |
1256 | 1256 | |
@@ -1266,31 +1266,31 @@ discard block |
||
1266 | 1266 | */ |
1267 | 1267 | public function enqueue_styles_and_scripts() { |
1268 | 1268 | // load css |
1269 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1270 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1269 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1270 | + wp_enqueue_style('single_page_checkout'); |
|
1271 | 1271 | // load JS |
1272 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1273 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1272 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1273 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1274 | 1274 | wp_register_script( |
1275 | 1275 | 'single_page_checkout', |
1276 | - SPCO_JS_URL . 'single_page_checkout.js', |
|
1277 | - array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), |
|
1276 | + SPCO_JS_URL.'single_page_checkout.js', |
|
1277 | + array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), |
|
1278 | 1278 | EVENT_ESPRESSO_VERSION, |
1279 | 1279 | TRUE |
1280 | 1280 | ); |
1281 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1281 | + wp_enqueue_script('single_page_checkout'); |
|
1282 | 1282 | |
1283 | 1283 | /** |
1284 | 1284 | * global action hook for enqueueing styles and scripts with |
1285 | 1285 | * spco calls. |
1286 | 1286 | */ |
1287 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1287 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1288 | 1288 | |
1289 | 1289 | /** |
1290 | 1290 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1291 | 1291 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1292 | 1292 | */ |
1293 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1293 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1294 | 1294 | |
1295 | 1295 | } |
1296 | 1296 | |
@@ -1305,20 +1305,20 @@ discard block |
||
1305 | 1305 | */ |
1306 | 1306 | private function _display_spco_reg_form() { |
1307 | 1307 | // if registering via the admin, just display the reg form for the current step |
1308 | - if ( $this->checkout->admin_request ) { |
|
1309 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1308 | + if ($this->checkout->admin_request) { |
|
1309 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1310 | 1310 | } else { |
1311 | 1311 | // add powered by EE msg |
1312 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1312 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1313 | 1313 | |
1314 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1315 | - EE_Registry::$i18n_js_strings[ 'empty_cart' ] = $empty_cart; |
|
1314 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1315 | + EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart; |
|
1316 | 1316 | $cookies_not_set_msg = ''; |
1317 | - if ( $empty_cart && ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1317 | + if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) { |
|
1318 | 1318 | $cookies_not_set_msg = apply_filters( |
1319 | 1319 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1320 | 1320 | sprintf( |
1321 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1321 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1322 | 1322 | '<div class="ee-attention">', |
1323 | 1323 | '</div>', |
1324 | 1324 | '<h6 class="important-notice">', |
@@ -1338,7 +1338,7 @@ discard block |
||
1338 | 1338 | 'layout_strategy' => |
1339 | 1339 | new EE_Template_Layout( |
1340 | 1340 | array( |
1341 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1341 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1342 | 1342 | 'template_args' => array( |
1343 | 1343 | 'empty_cart' => $empty_cart, |
1344 | 1344 | 'revisit' => $this->checkout->revisit, |
@@ -1350,8 +1350,8 @@ discard block |
||
1350 | 1350 | 'empty_msg' => apply_filters( |
1351 | 1351 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1352 | 1352 | sprintf( |
1353 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1354 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1353 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1354 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1355 | 1355 | '">', |
1356 | 1356 | '</a>' |
1357 | 1357 | ) |
@@ -1369,7 +1369,7 @@ discard block |
||
1369 | 1369 | ) |
1370 | 1370 | ); |
1371 | 1371 | // load template and add to output sent that gets filtered into the_content() |
1372 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1372 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1373 | 1373 | } |
1374 | 1374 | } |
1375 | 1375 | |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | * @internal param string $label |
1384 | 1384 | * @return string |
1385 | 1385 | */ |
1386 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1387 | - if ( $next_step === 'finalize_registration' ) { |
|
1386 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1387 | + if ($next_step === 'finalize_registration') { |
|
1388 | 1388 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1389 | 1389 | } |
1390 | 1390 | } |
@@ -1398,18 +1398,18 @@ discard block |
||
1398 | 1398 | * @return string |
1399 | 1399 | */ |
1400 | 1400 | public static function display_registration_footer() { |
1401 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1402 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1403 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1404 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1401 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1402 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1403 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1404 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1405 | 1405 | echo apply_filters( |
1406 | 1406 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1407 | 1407 | sprintf( |
1408 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1409 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1408 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1409 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1410 | 1410 | '" target="_blank">', |
1411 | 1411 | '</a>', |
1412 | - '<a href="' . $url . '" title="', |
|
1412 | + '<a href="'.$url.'" title="', |
|
1413 | 1413 | '" target="_blank">', |
1414 | 1414 | '</a></div>' |
1415 | 1415 | ) |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | * @throws \EE_Error |
1428 | 1428 | */ |
1429 | 1429 | public function unlock_transaction() { |
1430 | - if ( $this->checkout->transaction instanceof EE_Transaction ) { |
|
1430 | + if ($this->checkout->transaction instanceof EE_Transaction) { |
|
1431 | 1431 | $this->checkout->transaction->unlock(); |
1432 | 1432 | } |
1433 | 1433 | } |
@@ -1442,12 +1442,12 @@ discard block |
||
1442 | 1442 | * @return array |
1443 | 1443 | */ |
1444 | 1444 | private function _setup_redirect() { |
1445 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1445 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1446 | 1446 | $this->checkout->redirect = TRUE; |
1447 | - if ( empty( $this->checkout->redirect_url )) { |
|
1447 | + if (empty($this->checkout->redirect_url)) { |
|
1448 | 1448 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1449 | 1449 | } |
1450 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1450 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1451 | 1451 | } |
1452 | 1452 | } |
1453 | 1453 | |
@@ -1461,9 +1461,9 @@ discard block |
||
1461 | 1461 | * @throws \EE_Error |
1462 | 1462 | */ |
1463 | 1463 | public function go_to_next_step() { |
1464 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1464 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1465 | 1465 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1466 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1466 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1467 | 1467 | } |
1468 | 1468 | $this->unlock_transaction(); |
1469 | 1469 | // just return for these conditions |
@@ -1492,7 +1492,7 @@ discard block |
||
1492 | 1492 | */ |
1493 | 1493 | protected function _handle_json_response() { |
1494 | 1494 | // if this is an ajax request |
1495 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1495 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1496 | 1496 | // DEBUG LOG |
1497 | 1497 | //$this->checkout->log( |
1498 | 1498 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1505,7 +1505,7 @@ discard block |
||
1505 | 1505 | $this->checkout->json_response->set_registration_time_limit( |
1506 | 1506 | $this->checkout->get_registration_time_limit() |
1507 | 1507 | ); |
1508 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1508 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1509 | 1509 | // just send the ajax ( |
1510 | 1510 | $json_response = apply_filters( |
1511 | 1511 | 'FHEE__EE_Single_Page_Checkout__JSON_response', |
@@ -1526,9 +1526,9 @@ discard block |
||
1526 | 1526 | */ |
1527 | 1527 | protected function _handle_html_redirects() { |
1528 | 1528 | // going somewhere ? |
1529 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1529 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1530 | 1530 | // store notices in a transient |
1531 | - EE_Error::get_notices( false, true, true ); |
|
1531 | + EE_Error::get_notices(false, true, true); |
|
1532 | 1532 | // DEBUG LOG |
1533 | 1533 | //$this->checkout->log( |
1534 | 1534 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | // 'headers_list' => headers_list(), |
1539 | 1539 | // ) |
1540 | 1540 | //); |
1541 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1541 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1542 | 1542 | exit(); |
1543 | 1543 | } |
1544 | 1544 | } |