Completed
Branch FET-8394-move-rules-into-core (5a0f96)
by
unknown
62:42 queued 53:38
created
core/helpers/EEH_Line_Item.helper.php 4 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -280,7 +280,7 @@
 block discarded – undo
280 280
 		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
281 281
 		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
282 282
 			$success = $pre_tax_subtotal->add_child_line_item($item);
283
-		}else{
283
+		} else{
284 284
 			return FALSE;
285 285
 		}
286 286
 		$total_line_item->recalculate_total_including_taxes();
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
35 35
 	 * @return boolean success
36 36
 	 */
37
-	public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
38
-		$items_subtotal = self::get_pre_tax_subtotal( $parent_line_item );
37
+	public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
38
+		$items_subtotal = self::get_pre_tax_subtotal($parent_line_item);
39 39
 		$line_item = EE_Line_Item::new_instance(array(
40 40
 			'LIN_name' => $name,
41 41
 			'LIN_desc' => $description,
42 42
 			'LIN_unit_price' => $unit_price,
43 43
 			'LIN_quantity' => $quantity,
44 44
 			'LIN_is_taxable' => $taxable,
45
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
46
-			'LIN_total' => floatval( $unit_price ) * intval( $quantity ),
45
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
46
+			'LIN_total' => floatval($unit_price) * intval($quantity),
47 47
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
48 48
 			'LIN_code' => $code,
49 49
 		));
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			'FHEE__EEH_Line_Item__add_unrelated_item__line_item',
52 52
 			$line_item
53 53
 		);
54
-		return self::add_item( $parent_line_item, $line_item );
54
+		return self::add_item($parent_line_item, $line_item);
55 55
 	}
56 56
 
57 57
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param boolean      $taxable
68 68
 	 * @return boolean success
69 69
 	 */
70
-	public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){
70
+	public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) {
71 71
 		$line_item = EE_Line_Item::new_instance(array(
72 72
 			'LIN_name' => $name,
73 73
 			'LIN_desc' => $description,
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			'LIN_percent' => $percentage_amount,
76 76
 			'LIN_quantity' => NULL,
77 77
 			'LIN_is_taxable' => $taxable,
78
-			'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )),
78
+			'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)),
79 79
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
80 80
 			'LIN_parent' => $parent_line_item->ID()
81 81
 		));
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			'FHEE__EEH_Line_Item__add_percentage_based_item__line_item',
84 84
 			$line_item
85 85
 		);
86
-		return self::add_item( $parent_line_item, $line_item );
86
+		return self::add_item($parent_line_item, $line_item);
87 87
 	}
88 88
 
89 89
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 	 * @return \EE_Line_Item
99 99
 	 * @throws \EE_Error
100 100
 	 */
101
-	public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
102
-		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) {
103
-			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() ) );
101
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
102
+		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) {
103
+			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()));
104 104
 		}
105 105
 		// either increment the qty for an existing ticket
106
-		$line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty );
106
+		$line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty);
107 107
 		// or add a new one
108
-		if ( ! $line_item instanceof EE_Line_Item ) {
109
-			$line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty );
108
+		if ( ! $line_item instanceof EE_Line_Item) {
109
+			$line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty);
110 110
 		}
111 111
 		$total_line_item->recalculate_total_including_taxes();
112 112
 		return $line_item;
@@ -122,21 +122,21 @@  discard block
 block discarded – undo
122 122
 	 * @return \EE_Line_Item
123 123
 	 * @throws \EE_Error
124 124
 	 */
125
-	public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
125
+	public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
126 126
 		$line_item = null;
127
-		if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) {
128
-			$ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item );
129
-			foreach ( (array)$ticket_line_items as $ticket_line_item ) {
130
-				if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) {
127
+		if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) {
128
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
129
+			foreach ((array) $ticket_line_items as $ticket_line_item) {
130
+				if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) {
131 131
 					$line_item = $ticket_line_item;
132 132
 					break;
133 133
 				}
134 134
 			}
135 135
 		}
136
-		if ( $line_item instanceof EE_Line_Item ) {
136
+		if ($line_item instanceof EE_Line_Item) {
137 137
 			$qty += $line_item->quantity();
138
-			$line_item->set_quantity( $qty );
139
-			$line_item->set_total( $line_item->unit_price() * $qty );
138
+			$line_item->set_quantity($qty);
139
+			$line_item->set_total($line_item->unit_price() * $qty);
140 140
 			return $line_item;
141 141
 		}
142 142
 		return null;
@@ -152,43 +152,43 @@  discard block
 block discarded – undo
152 152
 	 * @return \EE_Line_Item
153 153
 	 * @throws \EE_Error
154 154
 	 */
155
-	public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
155
+	public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
156 156
 		$datetimes = $ticket->datetimes();
157 157
 		$event_names = array();
158
-		foreach ( $datetimes as $datetime ) {
158
+		foreach ($datetimes as $datetime) {
159 159
 			$event = $datetime->event();
160
-			$event_names[ $event->ID() ] = $event->name();
160
+			$event_names[$event->ID()] = $event->name();
161 161
 		}
162
-		$description_addition = sprintf( __( ' (For %1$s)', 'event_espresso' ), implode(", ",$event_names) );
163
-		$full_description = $ticket->description() . $description_addition;
162
+		$description_addition = sprintf(__(' (For %1$s)', 'event_espresso'), implode(", ", $event_names));
163
+		$full_description = $ticket->description().$description_addition;
164 164
 		// get event subtotal line
165
-		$events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket );
166
-		if ( ! $events_sub_total instanceof EE_Line_Item ) {
167
-			throw new EE_Error( sprintf( __( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ), $ticket->ID(), $total_line_item->ID() ) );
165
+		$events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket);
166
+		if ( ! $events_sub_total instanceof EE_Line_Item) {
167
+			throw new EE_Error(sprintf(__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'), $ticket->ID(), $total_line_item->ID()));
168 168
 		}
169 169
 		// add $ticket to cart
170
-		$line_item = EE_Line_Item::new_instance( array(
170
+		$line_item = EE_Line_Item::new_instance(array(
171 171
 			'LIN_name'       	=> $ticket->name(),
172 172
 			'LIN_desc'       		=> $full_description,
173 173
 			'LIN_unit_price' 	=> $ticket->price(),
174 174
 			'LIN_quantity'   	=> $qty,
175 175
 			'LIN_is_taxable' 	=> $ticket->taxable(),
176
-			'LIN_order'      	=> count( $events_sub_total->children() ),
176
+			'LIN_order'      	=> count($events_sub_total->children()),
177 177
 			'LIN_total'      		=> $ticket->price() * $qty,
178 178
 			'LIN_type'       		=> EEM_Line_Item::type_line_item,
179 179
 			'OBJ_ID'         		=> $ticket->ID(),
180 180
 			'OBJ_type'       	=> 'Ticket'
181
-		) );
181
+		));
182 182
 		$line_item = apply_filters(
183 183
 			'FHEE__EEH_Line_Item__create_ticket_line_item__line_item',
184 184
 			$line_item
185 185
 		);
186 186
 		//now add the sub-line items
187 187
 		$running_total_for_ticket = 0;
188
-		foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) {
188
+		foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) {
189 189
 			$sign = $price->is_discount() ? -1 : 1;
190 190
 			$price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty;
191
-			$sub_line_item = EE_Line_Item::new_instance( array(
191
+			$sub_line_item = EE_Line_Item::new_instance(array(
192 192
 				'LIN_name'       	=> $price->name(),
193 193
 				'LIN_desc'       		=> $price->desc(),
194 194
 				'LIN_quantity'   	=> $price->is_percent() ? null : $qty,
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
 				'LIN_type'       		=> EEM_Line_Item::type_sub_line_item,
199 199
 				'OBJ_ID'         		=> $price->ID(),
200 200
 				'OBJ_type'       	=> 'Price'
201
-			) );
201
+			));
202 202
 			$sub_line_item = apply_filters(
203 203
 				'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item',
204 204
 				$sub_line_item
205 205
 			);
206
-			if ( $price->is_percent() ) {
207
-				$sub_line_item->set_percent( $sign * $price->amount() );
206
+			if ($price->is_percent()) {
207
+				$sub_line_item->set_percent($sign * $price->amount());
208 208
 			} else {
209
-				$sub_line_item->set_unit_price( $sign * $price->amount() );
209
+				$sub_line_item->set_unit_price($sign * $price->amount());
210 210
 			}
211 211
 			$running_total_for_ticket += $price_total;
212
-			$line_item->add_child_line_item( $sub_line_item );
212
+			$line_item->add_child_line_item($sub_line_item);
213 213
 		}
214
-		$events_sub_total->add_child_line_item( $line_item );
214
+		$events_sub_total->add_child_line_item($line_item);
215 215
 		return $line_item;
216 216
 	}
217 217
 
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 	 * @param EE_Line_Item $item to be added
224 224
 	 * @return boolean
225 225
 	 */
226
-	public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){
227
-		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
228
-		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
226
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
227
+		$pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item);
228
+		if ($pre_tax_subtotal instanceof EE_Line_Item) {
229 229
 			$success = $pre_tax_subtotal->add_child_line_item($item);
230
-		}else{
230
+		} else {
231 231
 			return FALSE;
232 232
 		}
233 233
 		$total_line_item->recalculate_total_including_taxes();
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
242 242
 	 *	@return \EE_Line_Item
243 243
 	 */
244
-	public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){
245
-		$pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' );
246
-		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item );
244
+	public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) {
245
+		$pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal');
246
+		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item);
247 247
 	}
248 248
 
249 249
 
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
254 254
 	 * @return \EE_Line_Item
255 255
 	 */
256
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
257
-		$taxes = $total_line_item->get_child_line_item( 'taxes' );
258
-		return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item );
256
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
257
+		$taxes = $total_line_item->get_child_line_item('taxes');
258
+		return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item);
259 259
 	}
260 260
 
261 261
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 	 * @param EE_Transaction $transaction
267 267
 	 * @return void
268 268
 	 */
269
-	public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){
270
-		if( $transaction ){
269
+	public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) {
270
+		if ($transaction) {
271 271
 			/** @type EEM_Transaction $EEM_Transaction */
272
-			$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' );
273
-			$transaction = $EEM_Transaction->ensure_is_ID( $transaction );
274
-			$line_item->set_TXN_ID( $transaction );
272
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
273
+			$transaction = $EEM_Transaction->ensure_is_ID($transaction);
274
+			$line_item->set_TXN_ID($transaction);
275 275
 		}
276 276
 	}
277 277
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param EE_Transaction $transaction
285 285
 	 * @return \EE_Line_Item of type total
286 286
 	 */
287
-	public static function create_total_line_item( $transaction = NULL ){
288
-		$total_line_item = EE_Line_Item::new_instance( array(
287
+	public static function create_total_line_item($transaction = NULL) {
288
+		$total_line_item = EE_Line_Item::new_instance(array(
289 289
 			'LIN_code'	=> 'total',
290 290
 			'LIN_name'	=> __('Grand Total', 'event_espresso'),
291 291
 			'LIN_type'	=> EEM_Line_Item::type_total,
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 			'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
296 296
 			$total_line_item
297 297
 		);
298
-		self::set_TXN_ID( $total_line_item, $transaction );
299
-		self::create_pre_tax_subtotal( $total_line_item, $transaction );
300
-		self::create_taxes_subtotal( $total_line_item, $transaction );
298
+		self::set_TXN_ID($total_line_item, $transaction);
299
+		self::create_pre_tax_subtotal($total_line_item, $transaction);
300
+		self::create_taxes_subtotal($total_line_item, $transaction);
301 301
 		return $total_line_item;
302 302
 	}
303 303
 
@@ -309,19 +309,19 @@  discard block
 block discarded – undo
309 309
 	 * @param EE_Transaction $transaction
310 310
 	 * @return EE_Line_Item
311 311
 	 */
312
-	protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
313
-		$pre_tax_line_item = EE_Line_Item::new_instance( array(
312
+	protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
313
+		$pre_tax_line_item = EE_Line_Item::new_instance(array(
314 314
 			'LIN_code' 	=> 'pre-tax-subtotal',
315
-			'LIN_name' 	=> __( 'Pre-Tax Subtotal', 'event_espresso' ),
315
+			'LIN_name' 	=> __('Pre-Tax Subtotal', 'event_espresso'),
316 316
 			'LIN_type' 	=> EEM_Line_Item::type_sub_total
317
-		) );
317
+		));
318 318
 		$pre_tax_line_item = apply_filters(
319 319
 			'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
320 320
 			$pre_tax_line_item
321 321
 		);
322
-		self::set_TXN_ID( $pre_tax_line_item, $transaction );
323
-		$total_line_item->add_child_line_item( $pre_tax_line_item );
324
-		self::create_event_subtotal( $pre_tax_line_item, $transaction );
322
+		self::set_TXN_ID($pre_tax_line_item, $transaction);
323
+		$total_line_item->add_child_line_item($pre_tax_line_item);
324
+		self::create_event_subtotal($pre_tax_line_item, $transaction);
325 325
 		return $pre_tax_line_item;
326 326
 	}
327 327
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @param EE_Transaction $transaction
335 335
 	 * @return EE_Line_Item
336 336
 	 */
337
-	protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
337
+	protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
338 338
 		$tax_line_item = EE_Line_Item::new_instance(array(
339 339
 			'LIN_code'	=> 'taxes',
340 340
 			'LIN_name' 	=> __('Taxes', 'event_espresso'),
@@ -344,10 +344,10 @@  discard block
 block discarded – undo
344 344
 			'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
345 345
 			$tax_line_item
346 346
 		);
347
-		self::set_TXN_ID( $tax_line_item, $transaction );
348
-		$total_line_item->add_child_line_item( $tax_line_item );
347
+		self::set_TXN_ID($tax_line_item, $transaction);
348
+		$total_line_item->add_child_line_item($tax_line_item);
349 349
 		//and lastly, add the actual taxes
350
-		self::apply_taxes( $total_line_item );
350
+		self::apply_taxes($total_line_item);
351 351
 		return $tax_line_item;
352 352
 	}
353 353
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @param EE_Event $event
361 361
 	 * @return EE_Line_Item
362 362
 	 */
363
-	public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){
363
+	public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) {
364 364
 		$event_line_item = EE_Line_Item::new_instance(array(
365
-			'LIN_code'	=> self::get_event_code( $event ),
365
+			'LIN_code'	=> self::get_event_code($event),
366 366
 			'LIN_name' 	=> __('Event', 'event_espresso'),
367 367
 			'LIN_type'	=> EEM_Line_Item::type_sub_total,
368 368
 			'OBJ_type' 	=> 'Event',
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 			'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item',
373 373
 			$event_line_item
374 374
 		);
375
-		self::set_TXN_ID( $event_line_item, $transaction );
376
-		$pre_tax_line_item->add_child_line_item( $event_line_item );
375
+		self::set_TXN_ID($event_line_item, $transaction);
376
+		$pre_tax_line_item->add_child_line_item($event_line_item);
377 377
 		return $event_line_item;
378 378
 	}
379 379
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param EE_Event $event
383 383
 	 * @return string
384 384
 	 */
385
-	public static function get_event_code( $event ) {
386
-		return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' );
385
+	public static function get_event_code($event) {
386
+		return 'event-'.($event instanceof EE_Event ? $event->ID() : '0');
387 387
 	}
388 388
 
389 389
 	/**
@@ -396,37 +396,37 @@  discard block
 block discarded – undo
396 396
 	  * @throws \EE_Error
397 397
 	  * @return EE_Line_Item
398 398
 	  */
399
-	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
399
+	public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) {
400 400
 		$first_datetime = $ticket->first_datetime();
401
-		if( ! $first_datetime instanceof EE_Datetime ){
402
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) );
401
+		if ( ! $first_datetime instanceof EE_Datetime) {
402
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()));
403 403
 		}
404 404
 		$event = $first_datetime->event();
405
-		if ( ! $event instanceof EE_Event ) {
406
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) );
405
+		if ( ! $event instanceof EE_Event) {
406
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID()));
407 407
 		}
408 408
 		$event_line_item = NULL;
409 409
 		$found = false;
410
-		foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) {
410
+		foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) {
411 411
 			// default event subtotal, we should only ever find this the first time this method is called
412
-			if ( ! $event_line_item->OBJ_ID() ) {
412
+			if ( ! $event_line_item->OBJ_ID()) {
413 413
 				// let's use this! but first... set the event details
414
-				EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
414
+				EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
415 415
 				$found = true;
416 416
 				break;
417
-			} else if ( $event_line_item->OBJ_ID() === $event->ID() ) {
417
+			} else if ($event_line_item->OBJ_ID() === $event->ID()) {
418 418
 				// found existing line item for this event in the cart, so break out of loop and use this one
419 419
 				$found = true;
420 420
 				break;
421 421
 			}
422 422
 		}
423
-		if ( ! $found ) {
423
+		if ( ! $found) {
424 424
 			//there is no event sub-total yet, so add it
425
-			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total );
425
+			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total);
426 426
 			// create a new "event" subtotal below that
427
-			$event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event );
427
+			$event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event);
428 428
 			// and set the event details
429
-			EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
429
+			EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
430 430
 		}
431 431
 		return $event_line_item;
432 432
 	}
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
 	 * @param EE_Transaction $transaction
441 441
 	 * @return EE_Line_Item
442 442
 	 */
443
-	public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){
444
-		if ( $event instanceof EE_Event ) {
445
-			$event_line_item->set_code( self::get_event_code( $event ) );
446
-			$event_line_item->set_desc( $event->name() );
447
-			$event_line_item->set_OBJ_ID( $event->ID() );
443
+	public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) {
444
+		if ($event instanceof EE_Event) {
445
+			$event_line_item->set_code(self::get_event_code($event));
446
+			$event_line_item->set_desc($event->name());
447
+			$event_line_item->set_OBJ_ID($event->ID());
448 448
 		}
449
-		self::set_TXN_ID( $event_line_item, $transaction );
449
+		self::set_TXN_ID($event_line_item, $transaction);
450 450
 	}
451 451
 
452 452
 
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 	 * any old taxes are removed
458 458
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
459 459
 	 */
460
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
460
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
461 461
 		/** @type EEM_Price $EEM_Price */
462
-		$EEM_Price = EE_Registry::instance()->load_model( 'Price' );
462
+		$EEM_Price = EE_Registry::instance()->load_model('Price');
463 463
 		// get array of taxes via Price Model
464 464
 		$ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes();
465
-		ksort( $ordered_taxes );
466
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
465
+		ksort($ordered_taxes);
466
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
467 467
 		//just to be safe, remove its old tax line items
468 468
 		$taxes_line_item->delete_children_line_items();
469 469
 		//loop thru taxes
470
-		foreach ( $ordered_taxes as $order => $taxes ) {
471
-			foreach ( $taxes as $tax ) {
472
-				if ( $tax instanceof EE_Price ) {
470
+		foreach ($ordered_taxes as $order => $taxes) {
471
+			foreach ($taxes as $tax) {
472
+				if ($tax instanceof EE_Price) {
473 473
 					$tax_line_item = EE_Line_Item::new_instance(
474 474
 						array(
475 475
 							'LIN_name'       => $tax->name(),
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 						'FHEE__EEH_Line_Item__apply_taxes__tax_line_item',
488 488
 						$tax_line_item
489 489
 					);
490
-					$taxes_line_item->add_child_line_item( $tax_line_item );
490
+					$taxes_line_item->add_child_line_item($tax_line_item);
491 491
 				}
492 492
 			}
493 493
 		}
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
503 503
 	 * @return float
504 504
 	 */
505
-	public static function ensure_taxes_applied( $total_line_item ){
506
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
507
-		if( ! $taxes_subtotal->children()){
508
-			self::apply_taxes( $total_line_item );
505
+	public static function ensure_taxes_applied($total_line_item) {
506
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
507
+		if ( ! $taxes_subtotal->children()) {
508
+			self::apply_taxes($total_line_item);
509 509
 		}
510 510
 		return $taxes_subtotal->total();
511 511
 	}
@@ -518,15 +518,15 @@  discard block
 block discarded – undo
518 518
 	 * @param EE_Line_Item $parent_line_item
519 519
 	 * @return bool
520 520
 	 */
521
-	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
521
+	public static function delete_all_child_items(EE_Line_Item $parent_line_item) {
522 522
 		$deleted = 0;
523
-		foreach ( $parent_line_item->children() as $child_line_item ) {
524
-			if ( $child_line_item instanceof EE_Line_Item ) {
525
-				$deleted += EEH_Line_Item::delete_all_child_items( $child_line_item );
526
-				if ( $child_line_item->ID() ) {
523
+		foreach ($parent_line_item->children() as $child_line_item) {
524
+			if ($child_line_item instanceof EE_Line_Item) {
525
+				$deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
526
+				if ($child_line_item->ID()) {
527 527
 					$child_line_item->delete();
528 528
 				} else {
529
-					$parent_line_item->delete_child_line_item( $child_line_item->code() );
529
+					$parent_line_item->delete_child_line_item($child_line_item->code());
530 530
 				}
531 531
 				$deleted++;
532 532
 			}
@@ -543,25 +543,25 @@  discard block
 block discarded – undo
543 543
 	 * @param array|bool|string $line_item_codes
544 544
 	 * @return int number of items successfully removed
545 545
 	 */
546
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
546
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
547 547
 
548
-		if( $total_line_item->type() != EEM_Line_Item::type_total ){
549
-			EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __( 'This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso' ), '4.6.18' );
548
+		if ($total_line_item->type() != EEM_Line_Item::type_total) {
549
+			EE_Error::doing_it_wrong('EEH_Line_Item::delete_items', __('This static method should only be called with a TOTAL line item, otherwise we won\'t recalculate the totals correctly', 'event_espresso'), '4.6.18');
550 550
 		}
551
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
551
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
552 552
 
553 553
 		// check if only a single line_item_id was passed
554
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
554
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
555 555
 			// place single line_item_id in an array to appear as multiple line_item_ids
556
-			$line_item_codes = array ( $line_item_codes );
556
+			$line_item_codes = array($line_item_codes);
557 557
 		}
558 558
 		$removals = 0;
559 559
 		// cycle thru line_item_ids
560
-		foreach ( $line_item_codes as $line_item_id ) {
560
+		foreach ($line_item_codes as $line_item_id) {
561 561
 			$removals += $total_line_item->delete_child_line_item($line_item_id);
562 562
 		}
563 563
 
564
-		if ( $removals > 0 ) {
564
+		if ($removals > 0) {
565 565
 			$total_line_item->recalculate_taxes_and_tax_total();
566 566
 			return $removals;
567 567
 		} else {
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
 	 * @param string $description
579 579
 	 * @return EE_Line_Item the new tax line item created
580 580
 	 */
581
-	public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL ){
581
+	public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL) {
582 582
 		//first: remove all tax descendants
583 583
 		//add this as a new tax descendant
584
-		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
584
+		$tax_subtotal = self::get_taxes_subtotal($total_line_item);
585 585
 		$tax_subtotal->delete_children_line_items();
586 586
 		$taxable_total = $total_line_item->taxable_total();
587 587
 		$new_tax_subtotal = EE_Line_Item::new_instance(array(
588 588
 			'TXN_ID' => $total_line_item->TXN_ID(),
589 589
 			'LIN_name' => $name ? $name : __('Tax', 'event_espresso'),
590 590
 			'LIN_desc' => $description ? $description : '',
591
-			'LIN_percent' => $taxable_total ? ( $amount / $total_line_item->taxable_total()  * 100 ) : 0,
591
+			'LIN_percent' => $taxable_total ? ($amount / $total_line_item->taxable_total() * 100) : 0,
592 592
 			'LIN_total' => $amount,
593 593
 			'LIN_parent' => $tax_subtotal->ID(),
594 594
 			'LIN_type' => EEM_Line_Item::type_tax
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 			$new_tax_subtotal
599 599
 		);
600 600
 		$new_tax_subtotal->save();
601
-		$tax_subtotal->set_total( $amount );
601
+		$tax_subtotal->set_total($amount);
602 602
 		$tax_subtotal->save();
603 603
 		$total_line_item->recalculate_total_including_taxes();
604 604
 		return $new_tax_subtotal;
@@ -613,8 +613,8 @@  discard block
 block discarded – undo
613 613
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
614 614
 	 * @return EE_Line_Item[]
615 615
 	 */
616
-	public static function get_event_subtotals( EE_Line_Item $parent_line_item ) {
617
-		return self::get_subtotals_of_object_type( $parent_line_item, 'Event' );
616
+	public static function get_event_subtotals(EE_Line_Item $parent_line_item) {
617
+		return self::get_subtotals_of_object_type($parent_line_item, 'Event');
618 618
 	}
619 619
 
620 620
 
@@ -627,8 +627,8 @@  discard block
 block discarded – undo
627 627
 	 * @param string $obj_type
628 628
 	 * @return EE_Line_Item[]
629 629
 	 */
630
-	public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
631
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type );
630
+	public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
631
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type);
632 632
 	}
633 633
 
634 634
 
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
641 641
 	 * @return EE_Line_Item[]
642 642
 	 */
643
-	public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) {
644
-		return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' );
643
+	public static function get_ticket_line_items(EE_Line_Item $parent_line_item) {
644
+		return self::get_line_items_of_object_type($parent_line_item, 'Ticket');
645 645
 	}
646 646
 
647 647
 
@@ -654,8 +654,8 @@  discard block
 block discarded – undo
654 654
 	 * @param string $obj_type
655 655
 	 * @return EE_Line_Item[]
656 656
 	 */
657
-	public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
658
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type );
657
+	public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
658
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type);
659 659
 	}
660 660
 
661 661
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
667 667
 	 * @return EE_Line_Item[]
668 668
 	 */
669
-	public static function get_tax_descendants( EE_Line_Item $parent_line_item ) {
670
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax );
669
+	public static function get_tax_descendants(EE_Line_Item $parent_line_item) {
670
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax);
671 671
 	}
672 672
 
673 673
 
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
679 679
 	 * @return EE_Line_Item[]
680 680
 	 */
681
-	public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) {
682
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item );
681
+	public static function get_line_item_descendants(EE_Line_Item $parent_line_item) {
682
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item);
683 683
 	}
684 684
 
685 685
 
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @param string $line_item_type one of the EEM_Line_Item constants
693 693
 	 * @return EE_Line_Item[]
694 694
 	 */
695
-	public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) {
696
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL );
695
+	public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) {
696
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL);
697 697
 	}
698 698
 
699 699
 
@@ -706,15 +706,15 @@  discard block
 block discarded – undo
706 706
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
707 707
 	 * @return EE_Line_Item[]
708 708
 	 */
709
-	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
709
+	protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) {
710 710
 		$objects = array();
711
-		foreach ( $parent_line_item->children() as $child_line_item ) {
712
-			if ( $child_line_item instanceof EE_Line_Item ) {
713
-				if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) {
711
+		foreach ($parent_line_item->children() as $child_line_item) {
712
+			if ($child_line_item instanceof EE_Line_Item) {
713
+				if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) {
714 714
 					$objects[] = $child_line_item;
715 715
 				} else {
716 716
 					//go-through-all-its children looking for more matches
717
-					$objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type ));
717
+					$objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type));
718 718
 				}
719 719
 			}
720 720
 		}
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 	 * @param array $OBJ_IDs array of OBJ_IDs
733 733
 	 * @return EE_Line_Item[]
734 734
 	 */
735
-	public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) {
736
-		return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs );
735
+	public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) {
736
+		return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs);
737 737
 	}
738 738
 
739 739
 
@@ -746,15 +746,15 @@  discard block
 block discarded – undo
746 746
 	 * @param array $OBJ_IDs array of OBJ_IDs
747 747
 	 * @return EE_Line_Item[]
748 748
 	 */
749
-	protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) {
749
+	protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) {
750 750
 		$objects = array();
751
-		foreach ( $parent_line_item->children() as $child_line_item ) {
752
-			if ( $child_line_item instanceof EE_Line_Item ) {
753
-				if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) {
751
+		foreach ($parent_line_item->children() as $child_line_item) {
752
+			if ($child_line_item instanceof EE_Line_Item) {
753
+				if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) {
754 754
 					$objects[] = $child_line_item;
755 755
 				} else {
756 756
 					//go-through-all-its children looking for more matches
757
-					$objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs ));
757
+					$objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs));
758 758
 				}
759 759
 			}
760 760
 		}
@@ -772,8 +772,8 @@  discard block
 block discarded – undo
772 772
 	 * @param string $type like one of the EEM_Line_Item::type_*
773 773
 	 * @return EE_Line_Item
774 774
 	 */
775
-	public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) {
776
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type );
775
+	public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) {
776
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type);
777 777
 	}
778 778
 
779 779
 
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @param string $code any value used for LIN_code
787 787
 	 * @return EE_Line_Item
788 788
 	 */
789
-	public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) {
790
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code );
789
+	public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) {
790
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code);
791 791
 	}
792 792
 
793 793
 
@@ -800,15 +800,15 @@  discard block
 block discarded – undo
800 800
 	 * @param string $value any value stored in $search_field
801 801
 	 * @return EE_Line_Item
802 802
 	 */
803
-	protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) {
804
-		foreach( $parent_line_item->children() as $child ){
805
-			if ( $child->get( $search_field ) == $value ){
803
+	protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) {
804
+		foreach ($parent_line_item->children() as $child) {
805
+			if ($child->get($search_field) == $value) {
806 806
 				return $child;
807 807
 			}
808 808
 		}
809
-		foreach( $parent_line_item->children() as $child ){
810
-			$descendant_found = self::_get_nearest_descendant( $child, $search_field, $value );
811
-			if ( $descendant_found ){
809
+		foreach ($parent_line_item->children() as $child) {
810
+			$descendant_found = self::_get_nearest_descendant($child, $search_field, $value);
811
+			if ($descendant_found) {
812 812
 				return $descendant_found;
813 813
 			}
814 814
 		}
@@ -824,17 +824,17 @@  discard block
 block discarded – undo
824 824
 	 * @param int $indentation
825 825
 	 * @return void
826 826
 	 */
827
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
827
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
828 828
 		echo "\r\n";
829
-		for( $i = 0; $i < $indentation; $i++ ){
829
+		for ($i = 0; $i < $indentation; $i++) {
830 830
 			echo "-";
831 831
 		}
832
-		echo $line_item->name() . ": " . $line_item->type() . " $" . $line_item->total();
833
-		if( $line_item->is_taxable() ){
832
+		echo $line_item->name().": ".$line_item->type()." $".$line_item->total();
833
+		if ($line_item->is_taxable()) {
834 834
 			echo " taxable";
835 835
 		}
836
-		if( $line_item->children() ){
837
-			foreach($line_item->children() as $child){
836
+		if ($line_item->children()) {
837
+			foreach ($line_item->children() as $child) {
838 838
 				self::visualize($child, $indentation + 1);
839 839
 			}
840 840
 		}
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @param EE_Line_Item $total_line_item
853 853
 	 *	@return \EE_Line_Item
854 854
 	 */
855
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
856
-		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' );
857
-		return self::get_pre_tax_subtotal( $total_line_item );
855
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
856
+		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');
857
+		return self::get_pre_tax_subtotal($total_line_item);
858 858
 	}
859 859
 
860 860
 
@@ -864,9 +864,9 @@  discard block
 block discarded – undo
864 864
 	 * @param EE_Transaction $transaction
865 865
 	 *	@return \EE_Line_Item
866 866
 	 */
867
-	public static function create_default_total_line_item( $transaction = NULL) {
868
-		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' );
869
-		return self::create_total_line_item( $transaction );
867
+	public static function create_default_total_line_item($transaction = NULL) {
868
+		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');
869
+		return self::create_total_line_item($transaction);
870 870
 	}
871 871
 
872 872
 
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
 	 * @param EE_Transaction $transaction
878 878
 	 *	@return \EE_Line_Item
879 879
 	 */
880
-	public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
881
-		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' );
882
-		return self::create_pre_tax_subtotal( $total_line_item, $transaction );
880
+	public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
881
+		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');
882
+		return self::create_pre_tax_subtotal($total_line_item, $transaction);
883 883
 	}
884 884
 
885 885
 
@@ -890,9 +890,9 @@  discard block
 block discarded – undo
890 890
 	 * @param EE_Transaction $transaction
891 891
 	 *	@return \EE_Line_Item
892 892
 	 */
893
-	public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
894
-		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' );
895
-		return self::create_taxes_subtotal( $total_line_item, $transaction );
893
+	public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
894
+		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');
895
+		return self::create_taxes_subtotal($total_line_item, $transaction);
896 896
 	}
897 897
 
898 898
 
@@ -903,9 +903,9 @@  discard block
 block discarded – undo
903 903
 	 * @param EE_Transaction $transaction
904 904
 	 *	@return \EE_Line_Item
905 905
 	 */
906
-	public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
907
-		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' );
908
-		return self::create_event_subtotal( $total_line_item, $transaction );
906
+	public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
907
+		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');
908
+		return self::create_event_subtotal($total_line_item, $transaction);
909 909
 	}
910 910
 
911 911
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -467,15 +467,15 @@
 block discarded – undo
467 467
 	}
468 468
 
469 469
 	/**
470
-	  * Given the grand total line item and a ticket, finds the event sub-total
471
-	  * line item the ticket's purchase should be added onto
472
-	  *
473
-	  * @access public
474
-	  * @param EE_Line_Item $grand_total the grand total line item
475
-	  * @param EE_Ticket $ticket
476
-	  * @throws \EE_Error
477
-	  * @return EE_Line_Item
478
-	  */
470
+	 * Given the grand total line item and a ticket, finds the event sub-total
471
+	 * line item the ticket's purchase should be added onto
472
+	 *
473
+	 * @access public
474
+	 * @param EE_Line_Item $grand_total the grand total line item
475
+	 * @param EE_Ticket $ticket
476
+	 * @throws \EE_Error
477
+	 * @return EE_Line_Item
478
+	 */
479 479
 	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
480 480
 		$first_datetime = $ticket->first_datetime();
481 481
 		if( ! $first_datetime instanceof EE_Datetime ){
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 * Ensures that taxes have been applied to the order, if not applies them.
501 501
 	 * Returns the total amount of tax
502 502
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
503
-	 * @return float
503
+	 * @return boolean
504 504
 	 */
505 505
 	public static function ensure_taxes_applied( $total_line_item ){
506 506
 		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	 * Deletes ALL children of the passed line item
517 517
 	 *
518 518
 	 * @param EE_Line_Item $parent_line_item
519
-	 * @return bool
519
+	 * @return integer
520 520
 	 */
521 521
 	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
522 522
 		$deleted = 0;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	 * Deletes the line items as indicated by the line item code(s) provided,
541 541
 	 * regardless of where they're found in the line item tree
542 542
 	 * @param EE_Line_Item      $total_line_item of type EEM_Line_Item::type_total
543
-	 * @param array|bool|string $line_item_codes
543
+	 * @param boolean $line_item_codes
544 544
 	 * @return int number of items successfully removed
545 545
 	 */
546 546
 	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
@@ -704,6 +704,7 @@  discard block
 block discarded – undo
704 704
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
705 705
 	 * @param string $line_item_type one of the EEM_Line_Item constants
706 706
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
707
+	 * @param string $obj_type
707 708
 	 * @return EE_Line_Item[]
708 709
 	 */
709 710
 	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
@@ -729,7 +730,7 @@  discard block
 block discarded – undo
729 730
 	 * @uses  EEH_Line_Item::_get_descendants_by_type_and_object_type()
730 731
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
731 732
 	 * @param string $OBJ_type object type (like Event)
732
-	 * @param array $OBJ_IDs array of OBJ_IDs
733
+	 * @param boolean[] $OBJ_IDs array of OBJ_IDs
733 734
 	 * @return EE_Line_Item[]
734 735
 	 */
735 736
 	public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) {
Please login to merge, or discard this patch.
core/helpers/EEH_MSG_Template.helper.php 2 patches
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	 * @throws \EE_Error
47 47
 	 * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems.
48 48
 	 */
49
-	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0,  $global = FALSE) {
49
+	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) {
50 50
 
51 51
 		//make sure message_type is an array.
52 52
 		$message_types = (array) $message_types;
53 53
 		$templates = array();
54 54
 		$success = TRUE;
55 55
 
56
-		if ( empty($messenger) ) {
57
-			throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') );
56
+		if (empty($messenger)) {
57
+			throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso'));
58 58
 		}
59 59
 
60 60
 		//if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files.
61
-		if ( empty($message_types) ) {
62
-			throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') );
61
+		if (empty($message_types)) {
62
+			throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso'));
63 63
 		}
64 64
 
65 65
 		self::_set_autoloader();
@@ -67,25 +67,25 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$MSG = new EE_messages();
69 69
 
70
-		foreach ( $message_types as $message_type ) {
70
+		foreach ($message_types as $message_type) {
71 71
 			//if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty.
72
-			if ( $global && empty( $GRP_ID ) ) {
73
-				$GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) );
72
+			if ($global && empty($GRP_ID)) {
73
+				$GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE)));
74 74
 				$GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0;
75 75
 			}
76 76
 			//if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination.  If we do then NO generation!!
77
-			if ( $global && self::already_generated($messenger, $message_type, $GRP_ID  ) ) {
77
+			if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) {
78 78
 				$templates = TRUE;
79 79
 				continue; //get out we've already got generated templates for this.
80 80
 			}
81 81
 
82 82
 			$new_message_template_group = $MSG->create_new_templates($messenger, $message_type, $GRP_ID, $global);
83 83
 
84
-			if ( !$new_message_template_group ) {
84
+			if ( ! $new_message_template_group) {
85 85
 				$success = FALSE;
86 86
 				continue;
87 87
 			}
88
-			if ( $templates === TRUE ) $templates = array();
88
+			if ($templates === TRUE) $templates = array();
89 89
 			$templates[] = $new_message_template_group;
90 90
 		}
91 91
 
@@ -101,18 +101,18 @@  discard block
 block discarded – undo
101 101
 	 * @param  bool  $update_to_active if true then we also toggle the template to active.
102 102
 	 * @return bool                true = generated, false = hasn't been generated.
103 103
 	 */
104
-	public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) {
104
+	public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) {
105 105
 		self::_set_autoloader();
106 106
 		$MTP = EEM_Message_Template::instance();
107 107
 
108 108
 		//what method we use depends on whether we have an GRP_ID or not
109
-		$count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) :  $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) );
109
+		$count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID)));
110 110
 
111
-		if ( $update_to_active ) {
112
-			self::update_to_active( $messenger, $message_type );
111
+		if ($update_to_active) {
112
+			self::update_to_active($messenger, $message_type);
113 113
 		}
114 114
 
115
-		return ( $count > 0 ) ? TRUE : FALSE;
115
+		return ($count > 0) ? TRUE : FALSE;
116 116
 	}
117 117
 
118 118
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @static
127 127
 	 * @return  int 						count of updated records.
128 128
 	 */
129
-	public static function update_to_active( $messenger, $message_type ) {
130
-		return EEM_Message_Template_Group::instance()->update( array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type )) );
129
+	public static function update_to_active($messenger, $message_type) {
130
+		return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => 1), array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type)));
131 131
 	}
132 132
 
133 133
 
@@ -140,18 +140,18 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @return int  count of updated records.
142 142
 	 */
143
-	public static function update_to_inactive( $messenger = '', $message_type = '' ) {
143
+	public static function update_to_inactive($messenger = '', $message_type = '') {
144 144
 		$query_args = array();
145
-		if ( empty( $messenger ) && empty( $message_type ) )
145
+		if (empty($messenger) && empty($message_type))
146 146
 			return 0;
147
-		if ( ! empty( $messenger ) ) {
147
+		if ( ! empty($messenger)) {
148 148
 			$query_args[0]['MTP_messenger'] = $messenger;
149 149
 		}
150 150
 
151
-		if ( ! empty( $message_type ) ) {
151
+		if ( ! empty($message_type)) {
152 152
 			$query_args[0]['MTP_message_type'] = $message_type;
153 153
 		}
154
-		return EEM_Message_Template_Group::instance()->update( array( 'MTP_is_active' => FALSE ), $query_args );
154
+		return EEM_Message_Template_Group::instance()->update(array('MTP_is_active' => FALSE), $query_args);
155 155
 	}
156 156
 
157 157
 
@@ -189,39 +189,39 @@  discard block
 block discarded – undo
189 189
 	 *												OR
190 190
 	 * 												FALSE if no shortcodes found.
191 191
 	 */
192
-	public static function get_shortcodes( $message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE ) {
192
+	public static function get_shortcodes($message_type, $messenger, $fields = array(), $context = 'admin', $merged = FALSE) {
193 193
 
194
-		$messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) );
195
-		$mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) );
194
+		$messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger)));
195
+		$mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type)));
196 196
 
197 197
 		//convert slug to object
198
-		$messenger = self::messenger_obj( $messenger );
198
+		$messenger = self::messenger_obj($messenger);
199 199
 
200 200
 		//validate class for getting our list of shortcodes
201
-		$classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator';
202
-		if ( !class_exists( $classname ) ) {
203
-			$msg[] = __( 'The Validator class was unable to load', 'event_espresso');
204
-			$msg[] = sprintf( __('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname );
205
-			throw new EE_Error( implode( '||', $msg ) );
201
+		$classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator';
202
+		if ( ! class_exists($classname)) {
203
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
204
+			$msg[] = sprintf(__('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'), $classname);
205
+			throw new EE_Error(implode('||', $msg));
206 206
 		}
207 207
 
208
-		$a = new ReflectionClass( $classname );
209
-		$_VLD = $a->newInstance( array(), $context );
208
+		$a = new ReflectionClass($classname);
209
+		$_VLD = $a->newInstance(array(), $context);
210 210
 		$valid_shortcodes = $_VLD->get_validators();
211 211
 
212 212
 		//let's make sure we're only getting the shortcode part of the validators
213 213
 		$shortcodes = array();
214
-		foreach( $valid_shortcodes as $field => $validators ) {
214
+		foreach ($valid_shortcodes as $field => $validators) {
215 215
 			$shortcodes[$field] = $validators['shortcodes'];
216 216
 			$fields[] = $field;
217 217
 		}
218 218
 		$valid_shortcodes = $shortcodes;
219 219
 
220 220
 		//if not all fields let's make sure we ONLY include the shortcodes for the specified fields.
221
-		if ( ! empty( $fields ) ) {
221
+		if ( ! empty($fields)) {
222 222
 			$specified_shortcodes = array();
223
-			foreach ( $fields as $field ) {
224
-				if ( isset( $valid_shortcodes[$field] ) )
223
+			foreach ($fields as $field) {
224
+				if (isset($valid_shortcodes[$field]))
225 225
 					$specified_shortcodes[$field] = $valid_shortcodes[$field];
226 226
 			}
227 227
 			$valid_shortcodes = $specified_shortcodes;
@@ -229,16 +229,16 @@  discard block
 block discarded – undo
229 229
 
230 230
 
231 231
 		//if not merged then let's replace the fields with the localized fields
232
-		if ( ! $merged ) {
232
+		if ( ! $merged) {
233 233
 			//let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array.
234 234
 			$field_settings = $messenger->get_template_fields();
235 235
 			$localized = array();
236
-			foreach ( $valid_shortcodes as $field => $shortcodes ) {
236
+			foreach ($valid_shortcodes as $field => $shortcodes) {
237 237
 				//get localized field label
238
-				if ( isset( $field_settings[$field] ) ) {
238
+				if (isset($field_settings[$field])) {
239 239
 					//possible that this is used as a main field.
240
-					if ( empty( $field_settings[$field] ) ) {
241
-						if ( isset( $field_settings['extra'][$field] ) ) {
240
+					if (empty($field_settings[$field])) {
241
+						if (isset($field_settings['extra'][$field])) {
242 242
 							$_field = $field_settings['extra'][$field]['main']['label'];
243 243
 						} else {
244 244
 							$_field = $field;
@@ -246,10 +246,10 @@  discard block
 block discarded – undo
246 246
 					} else {
247 247
 						$_field = $field_settings[$field]['label'];
248 248
 					}
249
-				} else if ( isset( $field_settings['extra'] ) ) {
249
+				} else if (isset($field_settings['extra'])) {
250 250
 					//loop through extra "main fields" and see if any of their children have our field
251
-					foreach ( $field_settings['extra'] as $main_field => $fields ) {
252
-						if ( isset( $fields[$field] ) )
251
+					foreach ($field_settings['extra'] as $main_field => $fields) {
252
+						if (isset($fields[$field]))
253 253
 							$_field = $fields[$field]['label'];
254 254
 						else
255 255
 							$_field = $field;
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 				} else {
258 258
 					$_field = $field;
259 259
 				}
260
-				if ( isset( $_field )) {
261
-					$localized[ $_field ] = $shortcodes;
260
+				if (isset($_field)) {
261
+					$localized[$_field] = $shortcodes;
262 262
 				}
263 263
 			}
264 264
 			$valid_shortcodes = $localized;
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 
267 267
 
268 268
 		//if $merged then let's merge all the shortcodes into one list NOT indexed by field.
269
-		if ( $merged ) {
269
+		if ($merged) {
270 270
 			$merged_codes = array();
271
-			foreach ( $valid_shortcodes as $field => $shortcode ) {
272
-				foreach ( $shortcode as $code => $label ) {
273
-					if ( isset( $merged_codes[$code] ) )
271
+			foreach ($valid_shortcodes as $field => $shortcode) {
272
+				foreach ($shortcode as $code => $label) {
273
+					if (isset($merged_codes[$code]))
274 274
 						continue;
275 275
 					else
276 276
 						$merged_codes[$code] = $label;
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 	 * @throws \EE_Error
293 293
 	 * @return EE_messenger
294 294
 	 */
295
-	public static function messenger_obj( $messenger ) {
296
-		$ref = ucwords( str_replace( '_', ' ', $messenger ) );
297
-		$ref = str_replace( ' ', '_', $ref );
298
-		$classname = 'EE_' . $ref . '_messenger';
295
+	public static function messenger_obj($messenger) {
296
+		$ref = ucwords(str_replace('_', ' ', $messenger));
297
+		$ref = str_replace(' ', '_', $ref);
298
+		$classname = 'EE_'.$ref.'_messenger';
299 299
 
300
-		if ( !class_exists($classname) ) {
300
+		if ( ! class_exists($classname)) {
301 301
 			$msg[] = __('Messenger class loading fail.', 'event_espresso');
302
-			$msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname );
303
-			throw new EE_Error( implode( '||', $msg ) );
302
+			$msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate messenger file name (minus the extension) in the "/core/messages/messenger/" directory', 'event_espresso'), $classname);
303
+			throw new EE_Error(implode('||', $msg));
304 304
 		}
305 305
 
306 306
 		//made it here so let's instantiate the object and return it.
@@ -318,15 +318,15 @@  discard block
 block discarded – undo
318 318
 	 * @throws \EE_Error
319 319
 	 * @return EE_message_type
320 320
 	 */
321
-	public static function message_type_obj( $message_type ) {
322
-		$ref = ucwords( str_replace( '_', ' ', $message_type ) );
323
-		$ref = str_replace( ' ', '_', $ref );
324
-		$classname = 'EE_' . $ref . '_message_type';
321
+	public static function message_type_obj($message_type) {
322
+		$ref = ucwords(str_replace('_', ' ', $message_type));
323
+		$ref = str_replace(' ', '_', $ref);
324
+		$classname = 'EE_'.$ref.'_message_type';
325 325
 
326
-		if ( !class_exists($classname) ) {
326
+		if ( ! class_exists($classname)) {
327 327
 			$msg[] = __('Message Type class loading fail.', 'event_espresso');
328
-			$msg[] = sprintf( __('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname );
329
-			throw new EE_Error( implode( '||', $msg ) );
328
+			$msg[] = sprintf(__('The class name checked was "%s". Please check the spelling and case of this reference and make sure it matches the appropriate message type file name (minus the extension) in the "/core/messages/message_type/" directory', 'event_espresso'), $classname);
329
+			throw new EE_Error(implode('||', $msg));
330 330
 		}
331 331
 
332 332
 		//made it here so let's instantiate the object and return it.
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
 	 * @param  string   $message_type message type to check for.
346 346
 	 * @return boolean
347 347
 	 */
348
-	public static function is_mt_active( $message_type ) {
348
+	public static function is_mt_active($message_type) {
349 349
 		self::_set_autoloader();
350
-		$active_mts = EE_Registry::instance()->load_lib( 'messages' )->get_active_message_types();
351
-		return in_array( $message_type, $active_mts );
350
+		$active_mts = EE_Registry::instance()->load_lib('messages')->get_active_message_types();
351
+		return in_array($message_type, $active_mts);
352 352
 	}
353 353
 
354 354
 
@@ -361,10 +361,10 @@  discard block
 block discarded – undo
361 361
 	 * @param  string  $messenger slug for messenger to check.
362 362
 	 * @return boolean
363 363
 	 */
364
-	public static function is_messenger_active( $messenger ) {
364
+	public static function is_messenger_active($messenger) {
365 365
 		self::_set_autoloader();
366 366
 		$active_messengers = EE_Registry::instance()->load_lib('messages')->get_active_messengers();
367
-		return isset( $active_messengers[ $messenger ] );
367
+		return isset($active_messengers[$messenger]);
368 368
 	}
369 369
 
370 370
 
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 * @return array
379 379
 	 */
380 380
 	public static function get_active_messengers_in_db() {
381
-		return apply_filters( 'FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option( 'ee_active_messengers', array() ) );
381
+		return apply_filters('FHEE__EEH_MSG_Template__get_active_messengers_in_db', get_option('ee_active_messengers', array()));
382 382
 	}
383 383
 
384 384
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 *
394 394
 	 * @return bool FALSE if not updated, TRUE if updated.
395 395
 	 */
396
-	public static function update_active_messengers_in_db( $data_to_save ) {
397
-		return update_option( 'ee_active_messengers', $data_to_save );
396
+	public static function update_active_messengers_in_db($data_to_save) {
397
+		return update_option('ee_active_messengers', $data_to_save);
398 398
 	}
399 399
 
400 400
 
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return string          The generated url.
415 415
 	 */
416
-	public static function generate_url_trigger( $sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id ) {
416
+	public static function generate_url_trigger($sending_messenger, $generating_messenger, $context, $message_type, EE_Registration $registration, $message_template_group, $data_id) {
417 417
 		$query_args = array(
418 418
 			'ee' => 'msg_url_trigger',
419 419
 			'snd_msgr' => $sending_messenger,
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 			'GRP_ID' => $message_template_group,
425 425
 			'id' => $data_id
426 426
 			);
427
-		$url = add_query_arg( $query_args, get_site_url() );
427
+		$url = add_query_arg($query_args, get_site_url());
428 428
 
429 429
 		//made it here so now we can just get the url and filter it.  Filtered globally and by message type.
430
-		$url = apply_filters( 'FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id );
430
+		$url = apply_filters('FHEE__EEH_MSG_Template__generate_url_trigger', $url, $sending_messenger, $generating_messenger, $context, $message_type, $registration, $message_template_group, $data_id);
431 431
 
432 432
 		return $url;
433 433
 	}
Please login to merge, or discard this patch.
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
4 4
 	exit('NO direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -85,7 +86,9 @@  discard block
 block discarded – undo
85 86
 				$success = FALSE;
86 87
 				continue;
87 88
 			}
88
-			if ( $templates === TRUE ) $templates = array();
89
+			if ( $templates === TRUE ) {
90
+				$templates = array();
91
+			}
89 92
 			$templates[] = $new_message_template_group;
90 93
 		}
91 94
 
@@ -142,8 +145,9 @@  discard block
 block discarded – undo
142 145
 	 */
143 146
 	public static function update_to_inactive( $messenger = '', $message_type = '' ) {
144 147
 		$query_args = array();
145
-		if ( empty( $messenger ) && empty( $message_type ) )
146
-			return 0;
148
+		if ( empty( $messenger ) && empty( $message_type ) ) {
149
+					return 0;
150
+		}
147 151
 		if ( ! empty( $messenger ) ) {
148 152
 			$query_args[0]['MTP_messenger'] = $messenger;
149 153
 		}
@@ -221,8 +225,9 @@  discard block
 block discarded – undo
221 225
 		if ( ! empty( $fields ) ) {
222 226
 			$specified_shortcodes = array();
223 227
 			foreach ( $fields as $field ) {
224
-				if ( isset( $valid_shortcodes[$field] ) )
225
-					$specified_shortcodes[$field] = $valid_shortcodes[$field];
228
+				if ( isset( $valid_shortcodes[$field] ) ) {
229
+									$specified_shortcodes[$field] = $valid_shortcodes[$field];
230
+				}
226 231
 			}
227 232
 			$valid_shortcodes = $specified_shortcodes;
228 233
 		}
@@ -249,10 +254,11 @@  discard block
 block discarded – undo
249 254
 				} else if ( isset( $field_settings['extra'] ) ) {
250 255
 					//loop through extra "main fields" and see if any of their children have our field
251 256
 					foreach ( $field_settings['extra'] as $main_field => $fields ) {
252
-						if ( isset( $fields[$field] ) )
253
-							$_field = $fields[$field]['label'];
254
-						else
255
-							$_field = $field;
257
+						if ( isset( $fields[$field] ) ) {
258
+													$_field = $fields[$field]['label'];
259
+						} else {
260
+													$_field = $field;
261
+						}
256 262
 					}
257 263
 				} else {
258 264
 					$_field = $field;
@@ -270,10 +276,11 @@  discard block
 block discarded – undo
270 276
 			$merged_codes = array();
271 277
 			foreach ( $valid_shortcodes as $field => $shortcode ) {
272 278
 				foreach ( $shortcode as $code => $label ) {
273
-					if ( isset( $merged_codes[$code] ) )
274
-						continue;
275
-					else
276
-						$merged_codes[$code] = $label;
279
+					if ( isset( $merged_codes[$code] ) ) {
280
+											continue;
281
+					} else {
282
+											$merged_codes[$code] = $label;
283
+					}
277 284
 				}
278 285
 			}
279 286
 			$valid_shortcodes = $merged_codes;
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
10 10
  /**
11
- *
12
- * Money helper class.
13
- * This class has helper methods that help with money related conversions and calculations.
14
- *
15
- * @since %VER%
16
- *
17
- * @package		Event Espresso
18
- * @subpackage	helpers
19
- * @author		Darren Ethier
20
- *
21
- * ------------------------------------------------------------------------
22
- */
11
+  *
12
+  * Money helper class.
13
+  * This class has helper methods that help with money related conversions and calculations.
14
+  *
15
+  * @since %VER%
16
+  *
17
+  * @package		Event Espresso
18
+  * @subpackage	helpers
19
+  * @author		Darren Ethier
20
+  *
21
+  * ------------------------------------------------------------------------
22
+  */
23 23
 class EEH_Money extends EEH_Base  {
24 24
 
25 25
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * ------------------------------------------------------------------------
22 22
  */
23
-class EEH_Money extends EEH_Base  {
23
+class EEH_Money extends EEH_Base {
24 24
 
25 25
 
26 26
 	/**
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 * @param int|string $incoming_value
30 30
 	 * @return float
31 31
 	 */
32
-	public static function convert_to_float_from_localized_money( $incoming_value ) {
32
+	public static function convert_to_float_from_localized_money($incoming_value) {
33 33
 		//remove thousands separator
34
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value );
34
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value);
35 35
 
36 36
 		//replace decimal place with standard decimal.
37
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value );
37
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value);
38 38
 
39 39
 		//float it! and round to three decimal places
40
-		$money_value = round ( (float) $money_value, 3 );
40
+		$money_value = round((float) $money_value, 3);
41 41
 		return $money_value;
42 42
 	}
43 43
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 * @throws \EE_Error
58 58
 	 */
59 59
 
60
-	public static function compare_floats( $float1, $float2, $operator='=' ) {
60
+	public static function compare_floats($float1, $float2, $operator = '=') {
61 61
 		// Check numbers to 5 digits of precision
62 62
 		$epsilon = 0.00001;
63 63
 
64
-		$float1 = (float)$float1;
65
-		$float2 = (float)$float2;
64
+		$float1 = (float) $float1;
65
+		$float2 = (float) $float2;
66 66
 
67 67
 		switch ($operator) {
68 68
 			// equal
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				}
117 117
 				break;
118 118
 			default:
119
-				throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) );
119
+				throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso'));
120 120
 		}
121 121
 
122 122
 		return false;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@
 block discarded – undo
6 6
  * @package  Event Espresso
7 7
  * @subpackage helper
8 8
  */
9
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11
+}
10 12
  /**
11 13
  *
12 14
  * Money helper class.
Please login to merge, or discard this patch.
core/helpers/EEH_Parse_Shortcodes.helper.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param INT 					 $GRP_ID 	       The message template grp_id for the specific template being parsed.
84 84
 	 * @return string                   The parsed template string
85 85
 	 */
86
-	public function parse_message_template( $template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID ) {
86
+	public function parse_message_template($template, EE_Messages_Addressee $data, $valid_shortcodes, EE_message_type $message_type, EE_messenger $messenger, $context, $GRP_ID) {
87 87
 		$extra_data = array(
88 88
 			'messenger' => $messenger,
89 89
 			'message_type' => $message_type,
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'GRP_ID' => $GRP_ID
92 92
 			);
93 93
 
94
-		$this->_init_data( $template, $data, $valid_shortcodes, $extra_data );
94
+		$this->_init_data($template, $data, $valid_shortcodes, $extra_data);
95 95
 
96 96
 
97 97
 		$this->_template = is_array($template) ? $template['main'] : $template;
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 
105
-	public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) {
105
+	public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) {
106 106
 
107
-		$this->_init_data( $template, $registration, $valid_shortcodes, $extra_data );
107
+		$this->_init_data($template, $registration, $valid_shortcodes, $extra_data);
108 108
 
109 109
 		$this->_template = is_array($template) ? $template['attendee_list'] : $template;
110 110
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 		return $parsed;
113 113
 	}
114 114
 
115
-	public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) {
116
-		$this->_init_data( $template, $event, $valid_shortcodes, $extra_data );
115
+	public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) {
116
+		$this->_init_data($template, $event, $valid_shortcodes, $extra_data);
117 117
 
118 118
 		$this->_template = is_array($template) ? $template['event_list'] : $template;
119 119
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	}
123 123
 
124 124
 
125
-	public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) {
126
-		$this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data );
125
+	public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) {
126
+		$this->_init_data($template, $ticket, $valid_shortcodes, $extra_data);
127 127
 
128 128
 		$this->_template = is_array($template) ? $template['ticket_list'] : $template;
129 129
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 
134 134
 
135 135
 
136
-	public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) {
137
-		$this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data );
138
-		$this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template;
136
+	public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) {
137
+		$this->_init_data($template, $line_item, $valid_shortcodes, $extra_data);
138
+		$this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template;
139 139
 
140 140
 		$parsed = $this->_parse_message_template();
141 141
 		return $parsed;
142 142
 	}
143 143
 
144 144
 
145
-	public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) {
146
-		$this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data );
147
-		$this->_template = is_array( $template ) ? $template['payment_list'] : $template;
145
+	public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) {
146
+		$this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data);
147
+		$this->_template = is_array($template) ? $template['payment_list'] : $template;
148 148
 
149 149
 		$parsed = $this->_parse_message_template();
150 150
 		return $parsed;
151 151
 	}
152 152
 
153 153
 
154
-	public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) {
155
-		$this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data );
154
+	public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) {
155
+		$this->_init_data($template, $datetime, $valid_shortcodes, $extra_data);
156 156
 
157 157
 		$this->_template = is_array($template) ? $template['datetime_list'] : $template;
158 158
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	}
162 162
 
163 163
 
164
-	public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) {
165
-		$this->_init_data( $template, $answer, $valid_shortcodes, $extra_data );
164
+	public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) {
165
+		$this->_init_data($template, $answer, $valid_shortcodes, $extra_data);
166 166
 
167 167
 		$this->_template = is_array($template) ? $template['question_list'] : $template;
168 168
 
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 	}
172 172
 
173 173
 
174
-	private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) {
174
+	private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) {
175 175
 		$this->_reset_props();
176 176
 		$this->_data['template'] = $template;
177 177
 		$this->_data['data'] = $data;
178 178
 		$this->_data['extra_data'] = $extra_data;
179 179
 
180
-		$this->_set_shortcodes( $valid_shortcodes );
180
+		$this->_set_shortcodes($valid_shortcodes);
181 181
 	}
182 182
 
183 183
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 
198 198
 		//now let's get a list of shortcodes that are found in the given template
199
-		$possible_shortcodes = preg_match_all( '/(\[.+?\])/', $this->_template, $matches );
199
+		$possible_shortcodes = preg_match_all('/(\[.+?\])/', $this->_template, $matches);
200 200
 		$shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string.
201 201
 
202 202
 		$matched_code = array();
@@ -221,31 +221,31 @@  discard block
 block discarded – undo
221 221
 			'[PAYMENT_LIST_*]'
222 222
 			);
223 223
 
224
-		$list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes );
224
+		$list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes);
225 225
 
226 226
 		//now lets go ahead and loop through our parsers for each shortcode and setup the values
227
-		foreach ( $shortcodes as $shortcode ) {
227
+		foreach ($shortcodes as $shortcode) {
228 228
 
229
-			foreach ( $this->_shortcode_objs as $sc_obj ) {
229
+			foreach ($this->_shortcode_objs as $sc_obj) {
230 230
 				$data_send = '';
231 231
 
232 232
 				//we need to setup any dynamic shortcodes so that they work with the array_key_exists
233
-				$sc = preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches );
234
-				$sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode;
233
+				$sc = preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
234
+				$sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode;
235 235
 
236
-				if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) {
236
+				if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) {
237 237
 					continue; //the given shortcode isn't in this object
238 238
 				}
239 239
 
240 240
 				//if this isn't  a "list" type shortcode then we'll send along the data vanilla instead of in an array.
241
-				if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) {
242
-					$data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
241
+				if ( ! in_array($sc_to_verify, $list_type_shortcodes)) {
242
+					$data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
243 243
 				} else {
244 244
 					$data_send = $this->_data;
245 245
 				}
246 246
 
247 247
 
248
-				$parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] );
248
+				$parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']);
249 249
 
250 250
 				$matched_code[] = $shortcode;
251 251
 				$sc_values[] = $parsed;
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 	 * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects
268 268
 	 * @return void
269 269
 	 */
270
-	private function _set_shortcodes( $valid_shortcodes ) {
271
-		foreach ( $valid_shortcodes as $shortcode_ref ) {
272
-			$ref = ucwords( str_replace('_', ' ', $shortcode_ref ) );
273
-			$ref = str_replace( ' ', '_', $ref );
274
-			$classname = 'EE_' . $ref . '_Shortcodes';
275
-			if ( class_exists( $classname ) ) {
276
-				$a = new ReflectionClass( $classname );
270
+	private function _set_shortcodes($valid_shortcodes) {
271
+		foreach ($valid_shortcodes as $shortcode_ref) {
272
+			$ref = ucwords(str_replace('_', ' ', $shortcode_ref));
273
+			$ref = str_replace(' ', '_', $ref);
274
+			$classname = 'EE_'.$ref.'_Shortcodes';
275
+			if (class_exists($classname)) {
276
+				$a = new ReflectionClass($classname);
277 277
 				$this->_shortcode_objs[] = $a->newInstance();
278 278
 			}
279 279
 		}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
Please login to merge, or discard this patch.
core/helpers/EEH_Sideloader.helper.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
 
31
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
31
+require_once(EE_HELPERS.'EEH_Base.helper.php');
32 32
 class EEH_Sideloader extends EEH_Base {
33 33
 
34 34
 	private $_upload_to;
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @access public
44 44
 	 * @param array $init array fo initializing the sideloader if keys match the properties.
45 45
 	 */
46
-	public function __construct( $init = array() ) {
47
-		$this->_init( $init );
46
+	public function __construct($init = array()) {
47
+		$this->_init($init);
48 48
 	}
49 49
 
50 50
 
@@ -55,24 +55,24 @@  discard block
 block discarded – undo
55 55
 	 * @param  array  $init array on init (keys match properties others ignored)
56 56
 	 * @return void
57 57
 	 */
58
-	private function _init( $init ) {
58
+	private function _init($init) {
59 59
 		$defaults = array(
60 60
 			'_upload_to' => $this->_get_wp_uploads_dir(),
61 61
 			'_upload_from' => '',
62 62
 			'_permissions' => 0644,
63
-			'_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default'
63
+			'_new_file_name' => 'EE_Sideloader_'.uniqid().'.default'
64 64
 			);
65 65
 
66
-		$props = array_merge( $defaults, $init );
66
+		$props = array_merge($defaults, $init);
67 67
 
68
-		foreach ( $props as $key => $val ) {
69
-			if ( EEH_Class_Tools::has_property( $this, $key ) ) {
68
+		foreach ($props as $key => $val) {
69
+			if (EEH_Class_Tools::has_property($this, $key)) {
70 70
 				$this->$key = $val;
71 71
 			}
72 72
 		}
73 73
 
74 74
 		//make sure we include the required wp file for needed functions
75
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
75
+		require_once(ABSPATH.'wp-admin/includes/file.php');
76 76
 	}
77 77
 
78 78
 
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	private function _get_wp_uploads_dir() {}
81 81
 
82 82
 	//setters
83
-	public function set_upload_to( $upload_to_folder ) {
83
+	public function set_upload_to($upload_to_folder) {
84 84
 		$this->_upload_to = $upload_to_folder;
85 85
 	}
86
-	public function set_upload_from( $upload_from_folder ) {
86
+	public function set_upload_from($upload_from_folder) {
87 87
 		$this->_upload_from_folder = $upload_from_folder;
88 88
 	}
89
-	public function set_permissions( $permissions ) {
89
+	public function set_permissions($permissions) {
90 90
 		$this->_permissions = $permissions;
91 91
 	}
92
-	public function set_new_file_name( $new_file_name ) {
92
+	public function set_new_file_name($new_file_name) {
93 93
 		$this->_new_file_name = $new_file_name;
94 94
 	}
95 95
 
@@ -111,34 +111,34 @@  discard block
 block discarded – undo
111 111
 	//upload methods
112 112
 	public function sideload() {
113 113
 		//setup temp dir
114
-		$temp_file = wp_tempnam( $this->_upload_from );
114
+		$temp_file = wp_tempnam($this->_upload_from);
115 115
 
116
-		if ( !$temp_file ) {
117
-			EE_Error::add_error( __('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
116
+		if ( ! $temp_file) {
117
+			EE_Error::add_error(__('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
118 118
 			return false;
119 119
 		}
120 120
 
121
-		do_action( 'AHEE__EEH_Sideloader__sideload__before', $this, $temp_file );
121
+		do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file);
122 122
 
123
-		$wp_remote_args = apply_filters( 'FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file );
123
+		$wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file);
124 124
 
125
-		$response = wp_safe_remote_get( $this->_upload_from, $wp_remote_args );
125
+		$response = wp_safe_remote_get($this->_upload_from, $wp_remote_args);
126 126
 
127
-		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
128
-			unlink( $temp_file );
129
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
130
-				EE_Error::add_error( sprintf( __('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export( $response, true ), $this->_upload_from ), __FILE__, __FUNCTION__, __LINE__ );
127
+		if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
128
+			unlink($temp_file);
129
+			if (defined('WP_DEBUG') && WP_DEBUG) {
130
+				EE_Error::add_error(sprintf(__('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export($response, true), $this->_upload_from), __FILE__, __FUNCTION__, __LINE__);
131 131
 			}
132 132
 			return false;
133 133
 		}
134 134
 
135 135
 		//possible md5 check
136
-		$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
137
-		if ( $content_md5 ) {
138
-			$md5_check = verify_file_md5( $temp_file, $content_md5 );
139
-			if ( is_wp_error( $md5_check ) ) {
140
-				unlink( $temp_file );
141
-				EE_Error::add_error( $md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
136
+		$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
137
+		if ($content_md5) {
138
+			$md5_check = verify_file_md5($temp_file, $content_md5);
139
+			if (is_wp_error($md5_check)) {
140
+				unlink($temp_file);
141
+				EE_Error::add_error($md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
142 142
 				return false;
143 143
 			}
144 144
 		}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 		$file = $temp_file;
147 147
 
148 148
 		//now we have the file, let's get it in the right directory with the right name.
149
-		$path = apply_filters( 'FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this );
149
+		$path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this);
150 150
 
151 151
 		//move file in
152
-		if ( false === @ rename( $file, $path ) ) {
153
-			unlink( $temp_file );
154
-			EE_Error::add_error(  sprintf( __('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso' ), $path ), __FILE__, __FUNCTION__, __LINE__ );
152
+		if (false === @ rename($file, $path)) {
153
+			unlink($temp_file);
154
+			EE_Error::add_error(sprintf(__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), $path), __FILE__, __FUNCTION__, __LINE__);
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		//set permissions
159
-		$permissions = apply_filters( 'FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this );
160
-		chmod( $path, $permissions );
159
+		$permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this);
160
+		chmod($path, $permissions);
161 161
 
162 162
 		//that's it.  let's allow for actions after file uploaded.
163
-		do_action( 'AHEE__EE_Sideloader__sideload_after', $this, $path );
163
+		do_action('AHEE__EE_Sideloader__sideload_after', $this, $path);
164 164
 
165 165
 		//unlink tempfile
166
-		@unlink( $temp_file );
166
+		@unlink($temp_file);
167 167
 		return true;
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
core/helpers/EEH_URL.helper.php 2 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * EEH_URL helper
4 6
  * Helper class for URL-related PHP functions
@@ -62,7 +64,7 @@  discard block
 block discarded – undo
62 64
 				isset($results['response']['code']) &&
63 65
 				$results['response']['code'] == '200'){
64 66
 			return true;
65
-		}else{
67
+		} else{
66 68
 			return false;
67 69
 		}
68 70
 	}
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  *
10 10
  * ------------------------------------------------------------------------
11 11
  */
12
-class EEH_URL{
12
+class EEH_URL {
13 13
 
14 14
 	/**
15 15
 	 * _add_query_arg
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
 	 * @param string $url
21 21
 	 * @return string
22 22
 	 */
23
-	public static function add_query_args_and_nonce( $args = array(), $url = '' ) {
24
-		if ( empty( $url )) {
25
-			$user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' );
26
-			$dev_msg = $user_msg . "\n" . sprintf(
27
-					__('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso' ),
23
+	public static function add_query_args_and_nonce($args = array(), $url = '') {
24
+		if (empty($url)) {
25
+			$user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso');
26
+			$dev_msg = $user_msg."\n".sprintf(
27
+					__('In order to dynamically generate nonces for your actions, you need to supply a valid URL as a second parameter for the %s::add_query_args_and_nonce method.', 'event_espresso'),
28 28
 					__CLASS__
29 29
 				);
30
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
30
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
31 31
 		}
32 32
 		// check that an action exists
33
-		if ( isset( $args['action'] ) && ! empty( $args['action'] )) {
34
-			$args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' )));
33
+		if (isset($args['action']) && ! empty($args['action'])) {
34
+			$args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce')));
35 35
 		} else {
36
-			$args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' )));
36
+			$args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')));
37 37
 		}
38 38
 
39 39
 		//finally, let's always add a return address (if present) :)
40
-		$args = !empty( $_REQUEST['action'] ) ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) : $args;
40
+		$args = ! empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args;
41 41
 
42
-		return add_query_arg( $args, $url );
42
+		return add_query_arg($args, $url);
43 43
 
44 44
 	}
45 45
 
@@ -51,17 +51,17 @@  discard block
 block discarded – undo
51 51
 	 * @param string $url
52 52
 	 * @return boolean
53 53
 	 */
54
-	public static function remote_file_exists($url){
55
-		$results = wp_remote_request($url,array(
54
+	public static function remote_file_exists($url) {
55
+		$results = wp_remote_request($url, array(
56 56
 			'method'=>'GET',
57 57
 			'redirection'=>1,
58 58
 		));
59
-		if( ! $results instanceof WP_Error &&
59
+		if ( ! $results instanceof WP_Error &&
60 60
 				isset($results['response']) &&
61 61
 				isset($results['response']['code']) &&
62
-				$results['response']['code'] == '200'){
62
+				$results['response']['code'] == '200') {
63 63
 			return true;
64
-		}else{
64
+		} else {
65 65
 			return false;
66 66
 		}
67 67
 	}
@@ -77,29 +77,29 @@  discard block
 block discarded – undo
77 77
 	 * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
78 78
 	 * @return string
79 79
 	 */
80
-	public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) {
80
+	public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) {
81 81
 		// break apart incoming URL
82
-		$url_bits = parse_url( $url );
82
+		$url_bits = parse_url($url);
83 83
 		// HTTP or HTTPS ?
84
-		$scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://';
84
+		$scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://';
85 85
 		// domain
86
-		$host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : '';
86
+		$host = isset($url_bits['host']) ? $url_bits['host'] : '';
87 87
 		// if only the base URL is requested, then return that now
88
-		if ( $base_url_only ) {
89
-			return $scheme . $host;
88
+		if ($base_url_only) {
89
+			return $scheme.$host;
90 90
 		}
91
-		$port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : '';
92
-		$user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : '';
93
-		$pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : '';
94
-		$pass = ( $user || $pass ) ? $pass . '@' : '';
95
-		$path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : '';
91
+		$port = isset($url_bits['port']) ? ':'.$url_bits['port'] : '';
92
+		$user = isset($url_bits['user']) ? $url_bits['user'] : '';
93
+		$pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : '';
94
+		$pass = ($user || $pass) ? $pass.'@' : '';
95
+		$path = isset($url_bits['path']) ? $url_bits['path'] : '';
96 96
 		// if the query string is not required, then return what we have so far
97
-		if ( $remove_query ) {
98
-			return $scheme . $user . $pass . $host . $port . $path;
97
+		if ($remove_query) {
98
+			return $scheme.$user.$pass.$host.$port.$path;
99 99
 		}
100
-		$query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : '';
101
-		$fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : '';
102
-		return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
100
+		$query = isset($url_bits['query']) ? '?'.$url_bits['query'] : '';
101
+		$fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : '';
102
+		return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
103 103
 	}
104 104
 
105 105
 
@@ -112,29 +112,29 @@  discard block
 block discarded – undo
112 112
 	 * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string
113 113
 	 * @return string|array
114 114
 	 */
115
-	public static function get_query_string( $url = '', $as_array = TRUE ) {
115
+	public static function get_query_string($url = '', $as_array = TRUE) {
116 116
 		// break apart incoming URL
117
-		$url_bits = parse_url( $url );
117
+		$url_bits = parse_url($url);
118 118
 		// grab query string from URL
119
-		$query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : '';
119
+		$query = isset($url_bits['query']) ? $url_bits['query'] : '';
120 120
 		// if we don't want the query string formatted into an array of key => value pairs, then just return it as is
121
-		if ( ! $as_array ) {
121
+		if ( ! $as_array) {
122 122
 			return $query;
123 123
 		}
124 124
 		// if no query string exists then just return an empty array now
125
-		if ( empty( $query )) {
125
+		if (empty($query)) {
126 126
 			return array();
127 127
 		}
128 128
 		// empty array to hold results
129 129
 		$query_params = array();
130 130
 		// now break apart the query string into separate params
131
-		$query = explode( '&', $query );
131
+		$query = explode('&', $query);
132 132
 		// loop thru our query params
133
-		foreach ( $query as $query_args ) {
133
+		foreach ($query as $query_args) {
134 134
 			// break apart the key value pairs
135
-			$query_args = explode( '=', $query_args );
135
+			$query_args = explode('=', $query_args);
136 136
 			// and add to our results array
137
-			$query_params[ $query_args[0] ] = $query_args[1];
137
+			$query_params[$query_args[0]] = $query_args[1];
138 138
 		}
139 139
 		return $query_params;
140 140
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * prevent_prefetching
146 146
 	 * @return void
147 147
 	 */
148
-	public static function prevent_prefetching(){
148
+	public static function prevent_prefetching() {
149 149
 		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
150 150
 		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
151 151
 	}
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * add_nocache_headers
157 157
 	 * @return void
158 158
 	 */
159
-	public static function add_nocache_headers(){
159
+	public static function add_nocache_headers() {
160 160
 		// add no cache headers
161 161
 //		add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 );
162 162
 		// plus a little extra for nginx
Please login to merge, or discard this patch.
core/helpers/EEH_Venue_View.helper.php 2 patches
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 	 *                             		     regardless of access.
45 45
 	 * @return EE_Venue | null
46 46
 	 */
47
-	public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true ) {
48
-		$VNU_ID = absint( $VNU_ID );
47
+	public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true) {
48
+		$VNU_ID = absint($VNU_ID);
49 49
 		// do we already have the Venue you are looking for?
50
-		if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID ) {
51
-			return EEH_Venue_View::_get_venue( $privacy_check );
50
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID) {
51
+			return EEH_Venue_View::_get_venue($privacy_check);
52 52
 		}
53 53
 		// international newspaper?
54 54
 		global $post;
55
-		if ( $post instanceof WP_Post ) {
56
-			switch ( $post->post_type ) {
55
+		if ($post instanceof WP_Post) {
56
+			switch ($post->post_type) {
57 57
 				// if this is being called from an EE_Venue post,
58 58
 				// and the EE_Venue post corresponds to the EE_Venue that is being asked for,
59 59
 				// then we can try to just grab the attached EE_Venue object
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
 					// the post already contains the related EE_Venue object AND one of the following is TRUE:
62 62
 					// the requested Venue ID matches the post ID OR...
63 63
 					// there was no specific Venue ID requested
64
-					if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
64
+					if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) {
65 65
 						// use existing related EE_Venue object
66
-						EEH_Venue_View::$_venue =  $post->EE_Venue;
67
-					} else if ( $VNU_ID ) {
66
+						EEH_Venue_View::$_venue = $post->EE_Venue;
67
+					} else if ($VNU_ID) {
68 68
 						// there WAS a specific Venue ID requested, but it's NOT the current post object
69
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
69
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
70 70
 					} else {
71 71
 						// no specific Venue ID requested, so use post ID to generate EE_Venue object
72
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID );
72
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
73 73
 					}
74 74
 				break;
75 75
 
76 76
 				case 'espresso_events':
77
-					if ( $look_in_event ) {
77
+					if ($look_in_event) {
78 78
 						// grab the events related venues
79 79
 						$venues = EEH_Venue_View::get_event_venues();
80 80
 						// make sure the result is an array
81
-						$venues = is_array( $venues ) ? $venues : array();
81
+						$venues = is_array($venues) ? $venues : array();
82 82
 						// do we have an ID for a specific venue?
83
-						if ( $VNU_ID ) {
83
+						if ($VNU_ID) {
84 84
 							// loop thru the related venues
85
-							foreach( $venues as $venue ) {
86
-								if ( $venue instanceof EE_Venue ) {
85
+							foreach ($venues as $venue) {
86
+								if ($venue instanceof EE_Venue) {
87 87
 									// until we find the venue we're looking for
88
-									if ( $venue->ID() == $VNU_ID ) {
88
+									if ($venue->ID() == $VNU_ID) {
89 89
 										EEH_Venue_View::$_venue = $venue;
90 90
 										break;
91 91
 									}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 							// then the global post is an events post and this function was called with no argument
98 98
 						} else {
99 99
 							// just grab the first related event venue
100
-							EEH_Venue_View::$_venue = reset( $venues );
100
+							EEH_Venue_View::$_venue = reset($venues);
101 101
 						}
102 102
 					}
103 103
 				break;
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 			}
106 106
 		}
107 107
 		// now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
108
-		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
108
+		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
109 109
 			// sigh... pull it from the db
110
-			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
110
+			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
111 111
 		}
112
-		return EEH_Venue_View::_get_venue( $privacy_check );
112
+		return EEH_Venue_View::_get_venue($privacy_check);
113 113
 	}
114 114
 
115 115
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 *                             		     regardless of access.
122 122
 	 *  @return 	EE_Venue
123 123
 	 */
124
-	protected static function _get_venue( $privacy_check = true ) {
124
+	protected static function _get_venue($privacy_check = true) {
125 125
 		// check for private venues.
126
-		if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' ) ) {
126
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->status() == 'private' && $privacy_check && ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
127 127
 			return null;
128 128
 		}
129 129
 		return EEH_Venue_View::$_venue instanceof EE_Venue ? EEH_Venue_View::$_venue : null;
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public static function get_event_venues() {
141 141
 		global $post;
142
-		if ( $post->post_type == 'espresso_events' ) {
143
-			if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) {
142
+		if ($post->post_type == 'espresso_events') {
143
+			if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
144 144
 				return $post->EE_Event->venues();
145 145
 			}
146 146
 		}
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return bool|null
162 162
 	 */
163
-	public static function is_venue_private( $VNU_ID = false ) {
164
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true );
165
-		if ( ! $venue instanceof EE_Venue ) {
163
+	public static function is_venue_private($VNU_ID = false) {
164
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
165
+		if ( ! $venue instanceof EE_Venue) {
166 166
 			return null;
167 167
 		}
168 168
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 	 * @param int $VNU_ID
179 179
 	 * @return string
180 180
 	 */
181
-	public static function venue_description( $VNU_ID = 0 ) {
182
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
183
-		if ( $venue instanceof EE_Venue ) {
181
+	public static function venue_description($VNU_ID = 0) {
182
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
183
+		if ($venue instanceof EE_Venue) {
184 184
 			return$venue->description();
185 185
 		}
186 186
 		return '';
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
 	 * @param int $VNU_ID
196 196
 	 * @return string
197 197
 	 */
198
-	public static function venue_excerpt( $VNU_ID = 0 ) {
199
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
200
-		if ( $venue instanceof EE_Venue ) {
198
+	public static function venue_excerpt($VNU_ID = 0) {
199
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
200
+		if ($venue instanceof EE_Venue) {
201 201
 			$excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description();
202
-			$venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '&hellip;' );
203
-			return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : '';
202
+			$venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'&hellip;');
203
+			return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : '';
204 204
 		}
205 205
 		return '';
206 206
 	}
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 	 * @param bool $hide_uncategorized
216 216
 	 * @return string
217 217
 	 */
218
-	public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) {
218
+	public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) {
219 219
 		$category_links = array();
220
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
221
-		if ( $venue instanceof EE_Venue ) {
220
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
221
+		if ($venue instanceof EE_Venue) {
222 222
 			// get category terms
223
-			if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) {
223
+			if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
224 224
 				// loop thru terms and create links
225
-				foreach ( $venue_categories as $term ) {
226
-					$url = get_term_link( $term, 'espresso_venue_categories' );
227
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
228
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> ';
225
+				foreach ($venue_categories as $term) {
226
+					$url = get_term_link($term, 'espresso_venue_categories');
227
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
228
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> ';
229 229
 					}
230 230
 				}
231 231
 			}
232 232
 		}
233
-		return implode( ', ', $category_links );
233
+		return implode(', ', $category_links);
234 234
 	}
235 235
 
236 236
 
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 * @param bool $add_wrapper
246 246
 	 * @return string
247 247
 	 */
248
-	public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) {
249
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
250
-		if ( $venue instanceof EE_Venue ) {
251
-			EE_Registry::instance()->load_helper( 'Formatter' );
252
-			return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper );
248
+	public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) {
249
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
250
+		if ($venue instanceof EE_Venue) {
251
+			EE_Registry::instance()->load_helper('Formatter');
252
+			return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
253 253
 		}
254 254
 		return '';
255 255
 	}
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 	 * @param int $VNU_ID
264 264
 	 * @return bool|string
265 265
 	 */
266
-	public static function venue_has_address( $VNU_ID = 0 ) {
267
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
268
-		if ( $venue instanceof EE_Venue ) {
269
-			EE_Registry::instance()->load_helper( 'Formatter' );
270
-			return EEH_Address::format( $venue, 'inline', FALSE, FALSE );
266
+	public static function venue_has_address($VNU_ID = 0) {
267
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
268
+		if ($venue instanceof EE_Venue) {
269
+			EE_Registry::instance()->load_helper('Formatter');
270
+			return EEH_Address::format($venue, 'inline', FALSE, FALSE);
271 271
 		}
272 272
 		return false;
273 273
 	}
@@ -282,31 +282,31 @@  discard block
 block discarded – undo
282 282
 	 * @param int $VNU_ID
283 283
 	 * @return string
284 284
 	 */
285
-	public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) {
286
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
287
-		if ( $venue instanceof EE_Venue ) {
288
-			EE_Registry::instance()->load_helper( 'Formatter' );
285
+	public static function venue_name($link_to = 'details', $VNU_ID = 0) {
286
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
287
+		if ($venue instanceof EE_Venue) {
288
+			EE_Registry::instance()->load_helper('Formatter');
289 289
 			$venue_name = apply_filters(
290 290
 				'FHEE__EEH_Venue__venue_name__append_private_venue_name',
291 291
 				EEH_Venue_View::is_venue_private()
292
-					? EEH_Venue_View::$_venue->name() . "&nbsp;" . __( '(Private)', 'event_espresso' )
292
+					? EEH_Venue_View::$_venue->name()."&nbsp;".__('(Private)', 'event_espresso')
293 293
 					: EEH_Venue_View::$_venue->name(),
294 294
 				EEH_Venue_View::$_venue
295 295
 			);
296
-			$venue_name = EEH_Schema::name( $venue_name );
296
+			$venue_name = EEH_Schema::name($venue_name);
297 297
 
298 298
 			//if venue is trashed then ignore the "link to" setting because the venue is trashed.
299
-			if ( $venue->get('status') == 'trash' ) {
299
+			if ($venue->get('status') == 'trash') {
300 300
 				$link_to = '';
301 301
 			}
302
-			switch( $link_to ) {
302
+			switch ($link_to) {
303 303
 
304 304
 				case 'details' :
305
-					return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name );
305
+					return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
306 306
 				break;
307 307
 
308 308
 				case 'website' :
309
-					return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name );
309
+					return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
310 310
 				break;
311 311
 
312 312
 				default :
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @param    string $text
327 327
 	 * @return string
328 328
 	 */
329
-	public static function venue_details_link( $VNU_ID = 0, $text = '' ) {
330
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
331
-		if ( $venue instanceof EE_Venue ) {
332
-			return EEH_Schema::url( get_permalink( $venue->ID() ), $text );
329
+	public static function venue_details_link($VNU_ID = 0, $text = '') {
330
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
331
+		if ($venue instanceof EE_Venue) {
332
+			return EEH_Schema::url(get_permalink($venue->ID()), $text);
333 333
 		}
334 334
 		return '';
335 335
 	}
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 * @param    string $text
345 345
 	 * @return string
346 346
 	 */
347
-	public static function venue_website_link( $VNU_ID = 0, $text = '' ) {
348
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
349
-		if ( $venue instanceof EE_Venue ) {
350
-			EE_Registry::instance()->load_helper( 'Formatter' );
347
+	public static function venue_website_link($VNU_ID = 0, $text = '') {
348
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
349
+		if ($venue instanceof EE_Venue) {
350
+			EE_Registry::instance()->load_helper('Formatter');
351 351
 			$url = $venue->venue_url();
352
-			$text = ! empty( $text ) ? $text : $url;
353
-			return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : '';
352
+			$text = ! empty($text) ? $text : $url;
353
+			return ! empty($url) ? EEH_Schema::url($url, $text) : '';
354 354
 		}
355 355
 		return '';
356 356
 	}
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 	 * @param int $VNU_ID
365 365
 	 * @return string
366 366
 	 */
367
-	public static function venue_phone( $VNU_ID = 0) {
368
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
369
-		if ( $venue instanceof EE_Venue ) {
370
-			EE_Registry::instance()->load_helper( 'Formatter' );
371
-			return EEH_Schema::telephone( $venue->phone() );
367
+	public static function venue_phone($VNU_ID = 0) {
368
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
369
+		if ($venue instanceof EE_Venue) {
370
+			EE_Registry::instance()->load_helper('Formatter');
371
+			return EEH_Schema::telephone($venue->phone());
372 372
 		}
373 373
 		return '';
374 374
 	}
@@ -384,51 +384,51 @@  discard block
 block discarded – undo
384 384
 	 * @param    array $gmap map options
385 385
 	 * @return string
386 386
 	 */
387
-	public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) {
387
+	public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) {
388 388
 
389
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
390
-		if ( $venue instanceof EE_Venue ) {
389
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
390
+		if ($venue instanceof EE_Venue) {
391 391
 			// check for global espresso_events post and use it's ID if no map_ID is set
392 392
 			global $post;
393
-			$map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
393
+			$map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
394 394
 			// grab map settings
395 395
 			$map_cfg = EE_Registry::instance()->CFG->map_settings;
396 396
 			// are maps enabled ?
397
-			if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) {
397
+			if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
398 398
 
399
-				EE_Registry::instance()->load_helper( 'Maps' );
400
-				EE_Registry::instance()->load_helper( 'Formatter' );
399
+				EE_Registry::instance()->load_helper('Maps');
400
+				EE_Registry::instance()->load_helper('Formatter');
401 401
 
402 402
 				$details_page = is_single();
403 403
 				$options = array();
404
-				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
404
+				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
405 405
 
406
-				$options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE );
406
+				$options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE);
407 407
 
408 408
 				$options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
409
-				$options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width'];
409
+				$options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
410 410
 
411 411
 				$options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
412
-				$options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height'];
412
+				$options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
413 413
 
414 414
 				$options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
415
-				$options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
415
+				$options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
416 416
 
417 417
 				$options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
418
-				$options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];;
418
+				$options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ;
419 419
 
420 420
 				$options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
421
-				$options['ee_map_nav_size'] =  isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
421
+				$options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
422 422
 
423 423
 				$options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
424
-				$options['ee_map_type_control'] =  isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
424
+				$options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
425 425
 
426 426
 				$options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
427
-				$options['ee_map_align'] =  isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align'];
427
+				$options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align'];
428 428
 
429
-				$options['ee_static_url'] =  isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link();
429
+				$options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
430 430
 
431
-				return EEH_Maps::google_map( $options );
431
+				return EEH_Maps::google_map($options);
432 432
 
433 433
 			}
434 434
 		}
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 	 * @param array $atts like EEH_Maps::google_map_link
444 444
 	 * @return string
445 445
 	 */
446
-	public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){
446
+	public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) {
447 447
 		EE_Registry::instance()->load_helper('Maps');
448 448
 		$state = $venue->state_obj();
449 449
 		$country = $venue->country_obj();
@@ -475,23 +475,23 @@  discard block
 block discarded – undo
475 475
 	 * @param string $after
476 476
 	 * @return string
477 477
 	 */
478
-	public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) {
479
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
480
-		if ( $venue instanceof EE_Venue ) {
478
+	public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') {
479
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
480
+		if ($venue instanceof EE_Venue) {
481 481
 			// can the user edit this post ?
482
-			if ( current_user_can( 'edit_post', $venue->ID() )) {
482
+			if (current_user_can('edit_post', $venue->ID())) {
483 483
 				// set link text
484
-				$link = ! empty( $link ) ? $link : __('edit this venue');
484
+				$link = ! empty($link) ? $link : __('edit this venue');
485 485
 				// generate nonce
486
-				$nonce = wp_create_nonce( 'edit_nonce' );
486
+				$nonce = wp_create_nonce('edit_nonce');
487 487
 				// generate url to venue editor for this venue
488
-				$url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) );
488
+				$url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php'));
489 489
 				// get edit CPT text
490
-				$post_type_obj = get_post_type_object( 'espresso_venues' );
490
+				$post_type_obj = get_post_type_object('espresso_venues');
491 491
 				// build final link html
492
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
492
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
493 493
 				// put it all together
494
-				return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after;
494
+				return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after;
495 495
 			}
496 496
 		}
497 497
 		return '';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/libraries/form_sections/EE_Sample_Form.form.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class EE_Sample_Form extends EE_Form_Section_Proper{
3
-	function __construct(){
2
+class EE_Sample_Form extends EE_Form_Section_Proper {
3
+	function __construct() {
4 4
 		$this->_subsections = array(
5 5
 			'h1'=>new EE_Form_Section_HTML('hello wordl'),
6
-			'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')),
6
+			'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')),
7 7
 			'email'=>new EE_Email_Input(array('required'=>false)),
8
-			'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=>  __("Small", "event_espresso"),'m'=>  __("Medium", "event_espresso"),'l'=>  __("Large", "event_espresso")),array('required'=>true,'default'=>'s')),
8
+			'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=>  __("Small", "event_espresso"), 'm'=>  __("Medium", "event_espresso"), 'l'=>  __("Large", "event_espresso")), array('required'=>true, 'default'=>'s')),
9 9
 			'month_normal'=>new EE_Month_Input(),
10 10
 			'month_leading_zero'=>new EE_Month_Input(true),
11 11
 			'year_2'=>new EE_Year_Input(false, 1, 1),
12
-			'year_4'=>new EE_Year_Input(true, 0,10,array('default'=>'2017')),
12
+			'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')),
13 13
 			'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=>  __("Yes or No", "event_espresso"))),
14 14
 			'credit_card'=>new EE_Credit_Card_Input(),
15 15
 			'image_1'=>new EE_Admin_File_Uploader_Input(),
16 16
 			'image_2'=>new EE_Admin_File_Uploader_Input(),
17
-			'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'),array('default'=>array('php'))),
17
+			'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))),
18 18
 			'float'=>new EE_Float_Input(),
19 19
 			'essay'=>new EE_Text_Area_Input(),
20 20
 			'amenities'=>new EE_Select_Multiple_Input(
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 * Extra validation for the 'name' input.
41 41
 	 * @param EE_Text_Input $form_input
42 42
 	 */
43
-	function _validate_name($form_input){
44
-		if($form_input->raw_value() != 'Mike'){
43
+	function _validate_name($form_input) {
44
+		if ($form_input->raw_value() != 'Mike') {
45 45
 			$form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike');
46 46
 		}
47 47
 	}
48 48
 
49
-	function _validate(){
49
+	function _validate() {
50 50
 		parent::_validate();
51
-		if($this->_subsections['shirt_size']->normalized_value() =='s'
52
-				&& $this->_subsections['year_4']->normalized_value() < 2010){
51
+		if ($this->_subsections['shirt_size']->normalized_value() == 's'
52
+				&& $this->_subsections['year_4']->normalized_value() < 2010) {
53 53
 			$this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old');
54 54
 		}
55 55
 	}
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_HTML.form.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@
 block discarded – undo
2 2
 if (!defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('No direct script access allowed');
4 4
 /**
5
- * EE_Form_Section_HTML
6
- * HTML to be laid out like a proper subsection
7
- *
8
- *
9
- * @package			Event Espresso
10
- * @subpackage
11
- * @author				Mike Nelson
12
- *
13
- * ------------------------------------------------------------------------
14
- */
5
+	 * EE_Form_Section_HTML
6
+	 * HTML to be laid out like a proper subsection
7
+	 *
8
+	 *
9
+	 * @package			Event Espresso
10
+	 * @subpackage
11
+	 * @author				Mike Nelson
12
+	 *
13
+	 * ------------------------------------------------------------------------
14
+	 */
15 15
 class EE_Form_Section_HTML extends EE_Form_Section_Base{
16 16
 
17 17
 	protected $_html = '';
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('No direct script access allowed');
4 4
 /**
5 5
  * EE_Form_Section_HTML
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  *
13 13
  * ------------------------------------------------------------------------
14 14
  */
15
-class EE_Form_Section_HTML extends EE_Form_Section_Base{
15
+class EE_Form_Section_HTML extends EE_Form_Section_Base {
16 16
 
17 17
 	protected $_html = '';
18 18
 
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	 * @param string $html
23 23
 	 * @param array $options_array
24 24
 	 */
25
-	public function __construct( $html = '', $options_array = array() ) {
25
+	public function __construct($html = '', $options_array = array()) {
26 26
 		$this->_html = $html;
27
-		parent::__construct( $options_array );
27
+		parent::__construct($options_array);
28 28
 	}
29 29
 
30 30
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if (!defined('EVENT_ESPRESSO_VERSION')) {
3 3
 	exit('No direct script access allowed');
4
+}
4 5
 /**
5 6
  * EE_Form_Section_HTML
6 7
  * HTML to be laid out like a proper subsection
Please login to merge, or discard this patch.