Completed
Branch BUG-6292-conflict-legacy-wp-me... (9adae4)
by
unknown
44:46 queued 30:08
created
core/helpers/EEH_Line_Item.helper.php 4 patches
Doc Comments   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 * Ensures that taxes have been applied to the order, if not applies them.
575 575
 	 * Returns the total amount of tax
576 576
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
577
-	 * @return float
577
+	 * @return boolean
578 578
 	 */
579 579
 	public static function ensure_taxes_applied( $total_line_item ){
580 580
 		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 	 * Deletes ALL children of the passed line item
591 591
 	 *
592 592
 	 * @param EE_Line_Item $parent_line_item
593
-	 * @return bool
593
+	 * @return integer
594 594
 	 */
595 595
 	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
596 596
 		$deleted = 0;
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * You should call EE_Registration_Processor::calculate_reg_final_prices_per_line_item()
621 621
 	 * after using this, to keep the registration final prices in-sync with the transaction's total.
622 622
 	 * @param EE_Line_Item      $total_line_item of type EEM_Line_Item::type_total
623
-	 * @param array|bool|string $line_item_codes
623
+	 * @param boolean $line_item_codes
624 624
 	 * @return int number of items successfully removed
625 625
 	 */
626 626
 	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
@@ -784,6 +784,7 @@  discard block
 block discarded – undo
784 784
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
785 785
 	 * @param string $line_item_type one of the EEM_Line_Item constants
786 786
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
787
+	 * @param string $obj_type
787 788
 	 * @return EE_Line_Item[]
788 789
 	 */
789 790
 	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
@@ -809,7 +810,7 @@  discard block
 block discarded – undo
809 810
 	 * @uses  EEH_Line_Item::_get_descendants_by_type_and_object_type()
810 811
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
811 812
 	 * @param string $OBJ_type object type (like Event)
812
-	 * @param array $OBJ_IDs array of OBJ_IDs
813
+	 * @param boolean[] $OBJ_IDs array of OBJ_IDs
813 814
 	 * @return EE_Line_Item[]
814 815
 	 */
815 816
 	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.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 /**
3
- *
4
- * EEH_Line_Item
5
- *
6
- * This should be the main class which is aware of the line item tree structure, and
7
- * should take care of common operations like inserting items into it, updating
8
- * items in it based on what the line items are for, and removed line items.
9
- * All this logic was originally contained in EE_Cart, but because there are
10
- * actually other places that need to modify the record of what was purchased
11
- * (eg when a PayPal IPN is received, if PayPal changes the taxes, we need to update the line items;
12
- * or admin-side cancellations etc).
13
- * Generally all these functions will first take the total line item and figure things out from there
14
- *
15
- * @package			Event Espresso
16
- * @subpackage
17
- * @author				Mike Nelson
18
- *
19
- */
3
+	 *
4
+	 * EEH_Line_Item
5
+	 *
6
+	 * This should be the main class which is aware of the line item tree structure, and
7
+	 * should take care of common operations like inserting items into it, updating
8
+	 * items in it based on what the line items are for, and removed line items.
9
+	 * All this logic was originally contained in EE_Cart, but because there are
10
+	 * actually other places that need to modify the record of what was purchased
11
+	 * (eg when a PayPal IPN is received, if PayPal changes the taxes, we need to update the line items;
12
+	 * or admin-side cancellations etc).
13
+	 * Generally all these functions will first take the total line item and figure things out from there
14
+	 *
15
+	 * @package			Event Espresso
16
+	 * @subpackage
17
+	 * @author				Mike Nelson
18
+	 *
19
+	 */
20 20
 class EEH_Line_Item {
21 21
 
22 22
 	//other functions: cancel ticket purchase
@@ -460,15 +460,15 @@  discard block
 block discarded – undo
460 460
 	}
461 461
 
462 462
 	/**
463
-	  * Given the grand total line item and a ticket, finds the event sub-total
464
-	  * line item the ticket's purchase should be added onto
465
-	  *
466
-	  * @access public
467
-	  * @param EE_Line_Item $grand_total the grand total line item
468
-	  * @param EE_Ticket $ticket
469
-	  * @throws \EE_Error
470
-	  * @return EE_Line_Item
471
-	  */
463
+	 * Given the grand total line item and a ticket, finds the event sub-total
464
+	 * line item the ticket's purchase should be added onto
465
+	 *
466
+	 * @access public
467
+	 * @param EE_Line_Item $grand_total the grand total line item
468
+	 * @param EE_Ticket $ticket
469
+	 * @throws \EE_Error
470
+	 * @return EE_Line_Item
471
+	 */
472 472
 	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
473 473
 		$first_datetime = $ticket->first_datetime();
474 474
 		if( ! $first_datetime instanceof EE_Datetime ){
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
 		//so in case teh IPN is arriving later, let's try to process an IPN!
91 91
 		if($_SERVER['REQUEST_METHOD'] == 'POST'){
92 92
 			return $this->handle_ipn($_POST, $transaction );
93
-		}else{
93
+		} else{
94 94
 			return parent::finalize_payment_for( $transaction );
95 95
 		}
96 96
 	}
Please login to merge, or discard this patch.
Spacing   +274 added lines, -274 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
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 * @param boolean $code if set to a value, ensures there is only one line item with that code
41 41
 	 * @return boolean success
42 42
 	 */
43
-	public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
44
-		$items_subtotal = self::get_pre_tax_subtotal( $parent_line_item );
43
+	public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
44
+		$items_subtotal = self::get_pre_tax_subtotal($parent_line_item);
45 45
 		$line_item = EE_Line_Item::new_instance(array(
46 46
 			'LIN_name' => $name,
47 47
 			'LIN_desc' => $description,
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 			'LIN_quantity' => $quantity,
50 50
 			'LIN_percent' => null,
51 51
 			'LIN_is_taxable' => $taxable,
52
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
53
-			'LIN_total' => floatval( $unit_price ) * intval( $quantity ),
52
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
53
+			'LIN_total' => floatval($unit_price) * intval($quantity),
54 54
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
55 55
 			'LIN_code' => $code,
56 56
 		));
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			'FHEE__EEH_Line_Item__add_unrelated_item__line_item',
59 59
 			$line_item
60 60
 		);
61
-		return self::add_item( $parent_line_item, $line_item );
61
+		return self::add_item($parent_line_item, $line_item);
62 62
 	}
63 63
 
64 64
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @param boolean      $taxable
80 80
 	 * @return boolean success
81 81
 	 */
82
-	public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){
82
+	public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) {
83 83
 		$line_item = EE_Line_Item::new_instance(array(
84 84
 			'LIN_name' => $name,
85 85
 			'LIN_desc' => $description,
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			'LIN_percent' => $percentage_amount,
88 88
 			'LIN_quantity' => NULL,
89 89
 			'LIN_is_taxable' => $taxable,
90
-			'LIN_total' => floatval( $percentage_amount * ( $parent_line_item->total() / 100 )),
90
+			'LIN_total' => floatval($percentage_amount * ($parent_line_item->total() / 100)),
91 91
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
92 92
 			'LIN_parent' => $parent_line_item->ID()
93 93
 		));
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			'FHEE__EEH_Line_Item__add_percentage_based_item__line_item',
96 96
 			$line_item
97 97
 		);
98
-		return self::add_item( $parent_line_item, $line_item );
98
+		return self::add_item($parent_line_item, $line_item);
99 99
 	}
100 100
 
101 101
 
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 	 * @return \EE_Line_Item
117 117
 	 * @throws \EE_Error
118 118
 	 */
119
-	public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
120
-		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) {
121
-			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() ) );
119
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
120
+		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) {
121
+			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()));
122 122
 		}
123 123
 		// either increment the qty for an existing ticket
124
-		$line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty );
124
+		$line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty);
125 125
 		// or add a new one
126
-		if ( ! $line_item instanceof EE_Line_Item ) {
127
-			$line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty );
126
+		if ( ! $line_item instanceof EE_Line_Item) {
127
+			$line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty);
128 128
 		}
129 129
 		$total_line_item->recalculate_total_including_taxes();
130 130
 		return $line_item;
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 	 * @return \EE_Line_Item
141 141
 	 * @throws \EE_Error
142 142
 	 */
143
-	public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
143
+	public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
144 144
 		$line_item = null;
145
-		if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) {
146
-			$ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item );
147
-			foreach ( (array)$ticket_line_items as $ticket_line_item ) {
148
-				if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID() ) {
145
+		if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) {
146
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
147
+			foreach ((array) $ticket_line_items as $ticket_line_item) {
148
+				if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_ID() == $ticket->ID()) {
149 149
 					$line_item = $ticket_line_item;
150 150
 					break;
151 151
 				}
152 152
 			}
153 153
 		}
154
-		if ( $line_item instanceof EE_Line_Item ) {
155
-			EEH_Line_Item::increment_quantity( $line_item, $qty );
154
+		if ($line_item instanceof EE_Line_Item) {
155
+			EEH_Line_Item::increment_quantity($line_item, $qty);
156 156
 			return $line_item;
157 157
 		}
158 158
 		return null;
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
 	 * @param int $qty
166 166
 	 * @return void
167 167
 	 */
168
-	public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) {
169
-		if( ! $line_item->is_percent() ) {
168
+	public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) {
169
+		if ( ! $line_item->is_percent()) {
170 170
 			$qty += $line_item->quantity();
171
-			$line_item->set_quantity( $qty );
172
-			$line_item->set_total( $line_item->unit_price() * $qty );
171
+			$line_item->set_quantity($qty);
172
+			$line_item->set_total($line_item->unit_price() * $qty);
173 173
 		}
174
-		foreach( $line_item->children() as $child ) {
175
-			if( $child->is_sub_line_item() ) {
176
-				EEH_Line_Item::update_quantity( $child, $line_item->quantity() );
174
+		foreach ($line_item->children() as $child) {
175
+			if ($child->is_sub_line_item()) {
176
+				EEH_Line_Item::update_quantity($child, $line_item->quantity());
177 177
 			}
178 178
 		}
179 179
 	}
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
 	 * @param EE_Line_Item $line_item
185 185
 	 * @param int $new_quantity
186 186
 	 */
187
-	public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) {
188
-		if( ! $line_item->is_percent() ) {
189
-			$line_item->set_quantity( $new_quantity );
190
-			$line_item->set_total( $line_item->unit_price() * $new_quantity );
187
+	public static function update_quantity(EE_Line_Item $line_item, $new_quantity) {
188
+		if ( ! $line_item->is_percent()) {
189
+			$line_item->set_quantity($new_quantity);
190
+			$line_item->set_total($line_item->unit_price() * $new_quantity);
191 191
 		}
192
-		foreach( $line_item->children() as $child ) {
193
-			if( $child->is_sub_line_item() ) {
194
-				EEH_Line_Item::update_quantity( $child, $new_quantity );
192
+		foreach ($line_item->children() as $child) {
193
+			if ($child->is_sub_line_item()) {
194
+				EEH_Line_Item::update_quantity($child, $new_quantity);
195 195
 			}
196 196
 		}
197 197
 	}
@@ -206,45 +206,45 @@  discard block
 block discarded – undo
206 206
 	 * @return \EE_Line_Item
207 207
 	 * @throws \EE_Error
208 208
 	 */
209
-	public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
209
+	public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
210 210
 		$datetimes = $ticket->datetimes();
211
-		$first_datetime = reset( $datetimes );
212
-		if( $first_datetime instanceof EE_Datetime &&
213
-				$first_datetime->event() instanceof EE_Event ) {
211
+		$first_datetime = reset($datetimes);
212
+		if ($first_datetime instanceof EE_Datetime &&
213
+				$first_datetime->event() instanceof EE_Event) {
214 214
 			$first_datetime_name = $first_datetime->event()->name();
215 215
 		} else {
216
-			$first_datetime_name = __( 'Event', 'event_espresso' );
216
+			$first_datetime_name = __('Event', 'event_espresso');
217 217
 		}
218
-		$event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name );
218
+		$event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name);
219 219
 		// get event subtotal line
220
-		$events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket );
221
-		if ( ! $events_sub_total instanceof EE_Line_Item ) {
222
-			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() ) );
220
+		$events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket);
221
+		if ( ! $events_sub_total instanceof EE_Line_Item) {
222
+			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()));
223 223
 		}
224 224
 		// add $ticket to cart
225
-		$line_item = EE_Line_Item::new_instance( array(
225
+		$line_item = EE_Line_Item::new_instance(array(
226 226
 			'LIN_name'       	=> $ticket->name(),
227
-			'LIN_desc'       		=> $ticket->description() != '' ? $ticket->description() . ' ' . $event : $event,
227
+			'LIN_desc'       		=> $ticket->description() != '' ? $ticket->description().' '.$event : $event,
228 228
 			'LIN_unit_price' 	=> $ticket->price(),
229 229
 			'LIN_quantity'   	=> $qty,
230 230
 			'LIN_is_taxable' 	=> $ticket->taxable(),
231
-			'LIN_order'      	=> count( $events_sub_total->children() ),
231
+			'LIN_order'      	=> count($events_sub_total->children()),
232 232
 			'LIN_total'      		=> $ticket->price() * $qty,
233 233
 			'LIN_type'       		=> EEM_Line_Item::type_line_item,
234 234
 			'OBJ_ID'         		=> $ticket->ID(),
235 235
 			'OBJ_type'       	=> 'Ticket'
236
-		) );
236
+		));
237 237
 		$line_item = apply_filters(
238 238
 			'FHEE__EEH_Line_Item__create_ticket_line_item__line_item',
239 239
 			$line_item
240 240
 		);
241
-		$events_sub_total->add_child_line_item( $line_item );
241
+		$events_sub_total->add_child_line_item($line_item);
242 242
 		//now add the sub-line items
243 243
 		$running_total_for_ticket = 0;
244
-		foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) {
244
+		foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) {
245 245
 			$sign = $price->is_discount() ? -1 : 1;
246 246
 			$price_total = $price->is_percent() ? $running_total_for_ticket * $price->amount() / 100 : $price->amount() * $qty;
247
-			$sub_line_item = EE_Line_Item::new_instance( array(
247
+			$sub_line_item = EE_Line_Item::new_instance(array(
248 248
 				'LIN_name'       	=> $price->name(),
249 249
 				'LIN_desc'       		=> $price->desc(),
250 250
 				'LIN_quantity'   	=> $price->is_percent() ? null : $qty,
@@ -254,18 +254,18 @@  discard block
 block discarded – undo
254 254
 				'LIN_type'       		=> EEM_Line_Item::type_sub_line_item,
255 255
 				'OBJ_ID'         		=> $price->ID(),
256 256
 				'OBJ_type'       	=> 'Price'
257
-			) );
257
+			));
258 258
 			$sub_line_item = apply_filters(
259 259
 				'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item',
260 260
 				$sub_line_item
261 261
 			);
262
-			if ( $price->is_percent() ) {
263
-				$sub_line_item->set_percent( $sign * $price->amount() );
262
+			if ($price->is_percent()) {
263
+				$sub_line_item->set_percent($sign * $price->amount());
264 264
 			} else {
265
-				$sub_line_item->set_unit_price( $sign * $price->amount() );
265
+				$sub_line_item->set_unit_price($sign * $price->amount());
266 266
 			}
267 267
 			$running_total_for_ticket += $price_total;
268
-			$line_item->add_child_line_item( $sub_line_item );
268
+			$line_item->add_child_line_item($sub_line_item);
269 269
 		}
270 270
 		return $line_item;
271 271
 	}
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	 * @param EE_Line_Item $item to be added
284 284
 	 * @return boolean
285 285
 	 */
286
-	public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){
287
-		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
288
-		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
286
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
287
+		$pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item);
288
+		if ($pre_tax_subtotal instanceof EE_Line_Item) {
289 289
 			$success = $pre_tax_subtotal->add_child_line_item($item);
290
-		}else{
290
+		} else {
291 291
 			return FALSE;
292 292
 		}
293 293
 		$total_line_item->recalculate_total_including_taxes();
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
302 302
 	 *	@return \EE_Line_Item
303 303
 	 */
304
-	public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){
305
-		$pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' );
306
-		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal( $total_line_item );
304
+	public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) {
305
+		$pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal');
306
+		return $pre_tax_subtotal instanceof EE_Line_Item ? $pre_tax_subtotal : self::create_pre_tax_subtotal($total_line_item);
307 307
 	}
308 308
 
309 309
 
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
314 314
 	 * @return \EE_Line_Item
315 315
 	 */
316
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
317
-		$taxes = $total_line_item->get_child_line_item( 'taxes' );
318
-		return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item );
316
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
317
+		$taxes = $total_line_item->get_child_line_item('taxes');
318
+		return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item);
319 319
 	}
320 320
 
321 321
 
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 	 * @param EE_Transaction $transaction
327 327
 	 * @return void
328 328
 	 */
329
-	public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){
330
-		if( $transaction ){
329
+	public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) {
330
+		if ($transaction) {
331 331
 			/** @type EEM_Transaction $EEM_Transaction */
332
-			$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' );
333
-			$transaction = $EEM_Transaction->ensure_is_ID( $transaction );
334
-			$line_item->set_TXN_ID( $transaction );
332
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
333
+			$transaction = $EEM_Transaction->ensure_is_ID($transaction);
334
+			$line_item->set_TXN_ID($transaction);
335 335
 		}
336 336
 	}
337 337
 
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
 	 * @param EE_Transaction $transaction
345 345
 	 * @return \EE_Line_Item of type total
346 346
 	 */
347
-	public static function create_total_line_item( $transaction = NULL ){
348
-		$total_line_item = EE_Line_Item::new_instance( array(
347
+	public static function create_total_line_item($transaction = NULL) {
348
+		$total_line_item = EE_Line_Item::new_instance(array(
349 349
 			'LIN_code'	=> 'total',
350 350
 			'LIN_name'	=> __('Grand Total', 'event_espresso'),
351 351
 			'LIN_type'	=> EEM_Line_Item::type_total,
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 			'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
356 356
 			$total_line_item
357 357
 		);
358
-		self::set_TXN_ID( $total_line_item, $transaction );
359
-		self::create_pre_tax_subtotal( $total_line_item, $transaction );
360
-		self::create_taxes_subtotal( $total_line_item, $transaction );
358
+		self::set_TXN_ID($total_line_item, $transaction);
359
+		self::create_pre_tax_subtotal($total_line_item, $transaction);
360
+		self::create_taxes_subtotal($total_line_item, $transaction);
361 361
 		return $total_line_item;
362 362
 	}
363 363
 
@@ -369,19 +369,19 @@  discard block
 block discarded – undo
369 369
 	 * @param EE_Transaction $transaction
370 370
 	 * @return EE_Line_Item
371 371
 	 */
372
-	protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
373
-		$pre_tax_line_item = EE_Line_Item::new_instance( array(
372
+	protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
373
+		$pre_tax_line_item = EE_Line_Item::new_instance(array(
374 374
 			'LIN_code' 	=> 'pre-tax-subtotal',
375
-			'LIN_name' 	=> __( 'Pre-Tax Subtotal', 'event_espresso' ),
375
+			'LIN_name' 	=> __('Pre-Tax Subtotal', 'event_espresso'),
376 376
 			'LIN_type' 	=> EEM_Line_Item::type_sub_total
377
-		) );
377
+		));
378 378
 		$pre_tax_line_item = apply_filters(
379 379
 			'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
380 380
 			$pre_tax_line_item
381 381
 		);
382
-		self::set_TXN_ID( $pre_tax_line_item, $transaction );
383
-		$total_line_item->add_child_line_item( $pre_tax_line_item );
384
-		self::create_event_subtotal( $pre_tax_line_item, $transaction );
382
+		self::set_TXN_ID($pre_tax_line_item, $transaction);
383
+		$total_line_item->add_child_line_item($pre_tax_line_item);
384
+		self::create_event_subtotal($pre_tax_line_item, $transaction);
385 385
 		return $pre_tax_line_item;
386 386
 	}
387 387
 
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 	 * @param EE_Transaction $transaction
395 395
 	 * @return EE_Line_Item
396 396
 	 */
397
-	protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
397
+	protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
398 398
 		$tax_line_item = EE_Line_Item::new_instance(array(
399 399
 			'LIN_code'	=> 'taxes',
400 400
 			'LIN_name' 	=> __('Taxes', 'event_espresso'),
401 401
 			'LIN_type'	=> EEM_Line_Item::type_tax_sub_total,
402
-			'LIN_order' => 1000,//this should always come last
402
+			'LIN_order' => 1000, //this should always come last
403 403
 		));
404 404
 		$tax_line_item = apply_filters(
405 405
 			'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
406 406
 			$tax_line_item
407 407
 		);
408
-		self::set_TXN_ID( $tax_line_item, $transaction );
409
-		$total_line_item->add_child_line_item( $tax_line_item );
408
+		self::set_TXN_ID($tax_line_item, $transaction);
409
+		$total_line_item->add_child_line_item($tax_line_item);
410 410
 		//and lastly, add the actual taxes
411
-		self::apply_taxes( $total_line_item );
411
+		self::apply_taxes($total_line_item);
412 412
 		return $tax_line_item;
413 413
 	}
414 414
 
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	 * @param EE_Event $event
422 422
 	 * @return EE_Line_Item
423 423
 	 */
424
-	public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){
424
+	public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) {
425 425
 		$event_line_item = EE_Line_Item::new_instance(array(
426
-			'LIN_code'	=> self::get_event_code( $event ),
427
-			'LIN_name' 	=> self::get_event_name( $event ),
428
-			'LIN_desc' 	=> self::get_event_desc( $event ),
426
+			'LIN_code'	=> self::get_event_code($event),
427
+			'LIN_name' 	=> self::get_event_name($event),
428
+			'LIN_desc' 	=> self::get_event_desc($event),
429 429
 			'LIN_type'	=> EEM_Line_Item::type_sub_total,
430 430
 			'OBJ_type' 	=> 'Event',
431 431
 			'OBJ_ID' 		=>  $event instanceof EE_Event ? $event->ID() : 0
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 			'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item',
435 435
 			$event_line_item
436 436
 		);
437
-		self::set_TXN_ID( $event_line_item, $transaction );
438
-		$pre_tax_line_item->add_child_line_item( $event_line_item );
437
+		self::set_TXN_ID($event_line_item, $transaction);
438
+		$pre_tax_line_item->add_child_line_item($event_line_item);
439 439
 		return $event_line_item;
440 440
 	}
441 441
 
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 	 * @param EE_Event $event
445 445
 	 * @return string
446 446
 	 */
447
-	public static function get_event_code( $event ) {
448
-		return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' );
447
+	public static function get_event_code($event) {
448
+		return 'event-'.($event instanceof EE_Event ? $event->ID() : '0');
449 449
 	}
450 450
 
451 451
 	/**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param EE_Event $event
454 454
 	 * @return string
455 455
 	 */
456
-	public static function get_event_name( $event ) {
457
-		return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' );
456
+	public static function get_event_name($event) {
457
+		return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
458 458
 	}
459 459
 
460 460
 	/**
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 	 * @param EE_Event $event
463 463
 	 * @return string
464 464
 	 */
465
-	public static function get_event_desc( $event ) {
465
+	public static function get_event_desc($event) {
466 466
 		return $event instanceof EE_Event ? $event->short_description() : '';
467 467
 	}
468 468
 
@@ -476,37 +476,37 @@  discard block
 block discarded – undo
476 476
 	  * @throws \EE_Error
477 477
 	  * @return EE_Line_Item
478 478
 	  */
479
-	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
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
-		if( ! $first_datetime instanceof EE_Datetime ){
482
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() ) );
481
+		if ( ! $first_datetime instanceof EE_Datetime) {
482
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID()));
483 483
 		}
484 484
 		$event = $first_datetime->event();
485
-		if ( ! $event instanceof EE_Event ) {
486
-			throw new EE_Error( sprintf( __( 'The supplied ticket (ID %d) has no event data associated with it.','event_espresso' ), $ticket->ID() ) );
485
+		if ( ! $event instanceof EE_Event) {
486
+			throw new EE_Error(sprintf(__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'), $ticket->ID()));
487 487
 		}
488 488
 		$event_line_item = NULL;
489 489
 		$found = false;
490
-		foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) {
490
+		foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) {
491 491
 			// default event subtotal, we should only ever find this the first time this method is called
492
-			if ( ! $event_line_item->OBJ_ID() ) {
492
+			if ( ! $event_line_item->OBJ_ID()) {
493 493
 				// let's use this! but first... set the event details
494
-				EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
494
+				EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
495 495
 				$found = true;
496 496
 				break;
497
-			} else if ( $event_line_item->OBJ_ID() === $event->ID() ) {
497
+			} else if ($event_line_item->OBJ_ID() === $event->ID()) {
498 498
 				// found existing line item for this event in the cart, so break out of loop and use this one
499 499
 				$found = true;
500 500
 				break;
501 501
 			}
502 502
 		}
503
-		if ( ! $found ) {
503
+		if ( ! $found) {
504 504
 			//there is no event sub-total yet, so add it
505
-			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total );
505
+			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total);
506 506
 			// create a new "event" subtotal below that
507
-			$event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event );
507
+			$event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event);
508 508
 			// and set the event details
509
-			EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
509
+			EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
510 510
 		}
511 511
 		return $event_line_item;
512 512
 	}
@@ -520,14 +520,14 @@  discard block
 block discarded – undo
520 520
 	 * @param EE_Transaction $transaction
521 521
 	 * @return EE_Line_Item
522 522
 	 */
523
-	public static function set_event_subtotal_details( EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL ){
524
-		if ( $event instanceof EE_Event ) {
525
-			$event_line_item->set_code( self::get_event_code( $event ) );
526
-			$event_line_item->set_name( self::get_event_name( $event ) );
527
-			$event_line_item->set_desc( self::get_event_desc( $event ) );
528
-			$event_line_item->set_OBJ_ID( $event->ID() );
523
+	public static function set_event_subtotal_details(EE_Line_Item $event_line_item, EE_Event $event, $transaction = NULL) {
524
+		if ($event instanceof EE_Event) {
525
+			$event_line_item->set_code(self::get_event_code($event));
526
+			$event_line_item->set_name(self::get_event_name($event));
527
+			$event_line_item->set_desc(self::get_event_desc($event));
528
+			$event_line_item->set_OBJ_ID($event->ID());
529 529
 		}
530
-		self::set_TXN_ID( $event_line_item, $transaction );
530
+		self::set_TXN_ID($event_line_item, $transaction);
531 531
 	}
532 532
 
533 533
 
@@ -538,19 +538,19 @@  discard block
 block discarded – undo
538 538
 	 * any old taxes are removed
539 539
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
540 540
 	 */
541
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
541
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
542 542
 		/** @type EEM_Price $EEM_Price */
543
-		$EEM_Price = EE_Registry::instance()->load_model( 'Price' );
543
+		$EEM_Price = EE_Registry::instance()->load_model('Price');
544 544
 		// get array of taxes via Price Model
545 545
 		$ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes();
546
-		ksort( $ordered_taxes );
547
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
546
+		ksort($ordered_taxes);
547
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
548 548
 		//just to be safe, remove its old tax line items
549 549
 		$taxes_line_item->delete_children_line_items();
550 550
 		//loop thru taxes
551
-		foreach ( $ordered_taxes as $order => $taxes ) {
552
-			foreach ( $taxes as $tax ) {
553
-				if ( $tax instanceof EE_Price ) {
551
+		foreach ($ordered_taxes as $order => $taxes) {
552
+			foreach ($taxes as $tax) {
553
+				if ($tax instanceof EE_Price) {
554 554
 					$tax_line_item = EE_Line_Item::new_instance(
555 555
 						array(
556 556
 							'LIN_name'       => $tax->name(),
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 						'FHEE__EEH_Line_Item__apply_taxes__tax_line_item',
569 569
 						$tax_line_item
570 570
 					);
571
-					$taxes_line_item->add_child_line_item( $tax_line_item );
571
+					$taxes_line_item->add_child_line_item($tax_line_item);
572 572
 				}
573 573
 			}
574 574
 		}
@@ -583,10 +583,10 @@  discard block
 block discarded – undo
583 583
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
584 584
 	 * @return float
585 585
 	 */
586
-	public static function ensure_taxes_applied( $total_line_item ){
587
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
588
-		if( ! $taxes_subtotal->children()){
589
-			self::apply_taxes( $total_line_item );
586
+	public static function ensure_taxes_applied($total_line_item) {
587
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
588
+		if ( ! $taxes_subtotal->children()) {
589
+			self::apply_taxes($total_line_item);
590 590
 		}
591 591
 		return $taxes_subtotal->total();
592 592
 	}
@@ -599,16 +599,16 @@  discard block
 block discarded – undo
599 599
 	 * @param EE_Line_Item $parent_line_item
600 600
 	 * @return bool
601 601
 	 */
602
-	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
602
+	public static function delete_all_child_items(EE_Line_Item $parent_line_item) {
603 603
 		$deleted = 0;
604
-		foreach ( $parent_line_item->children() as $child_line_item ) {
605
-			if ( $child_line_item instanceof EE_Line_Item ) {
606
-				$deleted += EEH_Line_Item::delete_all_child_items( $child_line_item );
607
-				if ( $child_line_item->ID() ) {
604
+		foreach ($parent_line_item->children() as $child_line_item) {
605
+			if ($child_line_item instanceof EE_Line_Item) {
606
+				$deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
607
+				if ($child_line_item->ID()) {
608 608
 					$child_line_item->delete();
609
-					unset( $child_line_item );
609
+					unset($child_line_item);
610 610
 				} else {
611
-					$parent_line_item->delete_child_line_item( $child_line_item->code() );
611
+					$parent_line_item->delete_child_line_item($child_line_item->code());
612 612
 				}
613 613
 				$deleted++;
614 614
 			}
@@ -630,25 +630,25 @@  discard block
 block discarded – undo
630 630
 	 * @param array|bool|string $line_item_codes
631 631
 	 * @return int number of items successfully removed
632 632
 	 */
633
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
633
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
634 634
 
635
-		if( $total_line_item->type() != EEM_Line_Item::type_total ){
636
-			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' );
635
+		if ($total_line_item->type() != EEM_Line_Item::type_total) {
636
+			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');
637 637
 		}
638
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
638
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
639 639
 
640 640
 		// check if only a single line_item_id was passed
641
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
641
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
642 642
 			// place single line_item_id in an array to appear as multiple line_item_ids
643
-			$line_item_codes = array ( $line_item_codes );
643
+			$line_item_codes = array($line_item_codes);
644 644
 		}
645 645
 		$removals = 0;
646 646
 		// cycle thru line_item_ids
647
-		foreach ( $line_item_codes as $line_item_id ) {
647
+		foreach ($line_item_codes as $line_item_id) {
648 648
 			$removals += $total_line_item->delete_child_line_item($line_item_id);
649 649
 		}
650 650
 
651
-		if ( $removals > 0 ) {
651
+		if ($removals > 0) {
652 652
 			$total_line_item->recalculate_taxes_and_tax_total();
653 653
 			return $removals;
654 654
 		} else {
@@ -665,17 +665,17 @@  discard block
 block discarded – undo
665 665
 	 * @param string $description
666 666
 	 * @return EE_Line_Item the new tax line item created
667 667
 	 */
668
-	public static function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL ){
668
+	public static function set_total_tax_to(EE_Line_Item $total_line_item, $amount, $name = NULL, $description = NULL) {
669 669
 		//first: remove all tax descendants
670 670
 		//add this as a new tax descendant
671
-		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
671
+		$tax_subtotal = self::get_taxes_subtotal($total_line_item);
672 672
 		$tax_subtotal->delete_children_line_items();
673 673
 		$taxable_total = $total_line_item->taxable_total();
674 674
 		$new_tax_subtotal = EE_Line_Item::new_instance(array(
675 675
 			'TXN_ID' => $total_line_item->TXN_ID(),
676 676
 			'LIN_name' => $name ? $name : __('Tax', 'event_espresso'),
677 677
 			'LIN_desc' => $description ? $description : '',
678
-			'LIN_percent' => $taxable_total ? ( $amount / $total_line_item->taxable_total()  * 100 ) : 0,
678
+			'LIN_percent' => $taxable_total ? ($amount / $total_line_item->taxable_total() * 100) : 0,
679 679
 			'LIN_total' => $amount,
680 680
 			'LIN_parent' => $tax_subtotal->ID(),
681 681
 			'LIN_type' => EEM_Line_Item::type_tax
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 			$new_tax_subtotal
686 686
 		);
687 687
 		$new_tax_subtotal->save();
688
-		$tax_subtotal->set_total( $amount );
688
+		$tax_subtotal->set_total($amount);
689 689
 		$tax_subtotal->save();
690 690
 		$total_line_item->recalculate_total_including_taxes();
691 691
 		return $new_tax_subtotal;
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
701 701
 	 * @return EE_Line_Item[]
702 702
 	 */
703
-	public static function get_event_subtotals( EE_Line_Item $parent_line_item ) {
704
-		return self::get_subtotals_of_object_type( $parent_line_item, 'Event' );
703
+	public static function get_event_subtotals(EE_Line_Item $parent_line_item) {
704
+		return self::get_subtotals_of_object_type($parent_line_item, 'Event');
705 705
 	}
706 706
 
707 707
 
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
 	 * @param string $obj_type
715 715
 	 * @return EE_Line_Item[]
716 716
 	 */
717
-	public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
718
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_sub_total, $obj_type );
717
+	public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
718
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_sub_total, $obj_type);
719 719
 	}
720 720
 
721 721
 
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
728 728
 	 * @return EE_Line_Item[]
729 729
 	 */
730
-	public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) {
731
-		return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' );
730
+	public static function get_ticket_line_items(EE_Line_Item $parent_line_item) {
731
+		return self::get_line_items_of_object_type($parent_line_item, 'Ticket');
732 732
 	}
733 733
 
734 734
 
@@ -741,8 +741,8 @@  discard block
 block discarded – undo
741 741
 	 * @param string $obj_type
742 742
 	 * @return EE_Line_Item[]
743 743
 	 */
744
-	public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
745
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type );
744
+	public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
745
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type);
746 746
 	}
747 747
 
748 748
 
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
754 754
 	 * @return EE_Line_Item[]
755 755
 	 */
756
-	public static function get_tax_descendants( EE_Line_Item $parent_line_item ) {
757
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax );
756
+	public static function get_tax_descendants(EE_Line_Item $parent_line_item) {
757
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax);
758 758
 	}
759 759
 
760 760
 
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
766 766
 	 * @return EE_Line_Item[]
767 767
 	 */
768
-	public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) {
769
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item );
768
+	public static function get_line_item_descendants(EE_Line_Item $parent_line_item) {
769
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item);
770 770
 	}
771 771
 
772 772
 
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 	 * @param string $line_item_type one of the EEM_Line_Item constants
780 780
 	 * @return EE_Line_Item[]
781 781
 	 */
782
-	public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) {
783
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL );
782
+	public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) {
783
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL);
784 784
 	}
785 785
 
786 786
 
@@ -793,15 +793,15 @@  discard block
 block discarded – undo
793 793
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
794 794
 	 * @return EE_Line_Item[]
795 795
 	 */
796
-	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
796
+	protected static function _get_descendants_by_type_and_object_type(EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL) {
797 797
 		$objects = array();
798
-		foreach ( $parent_line_item->children() as $child_line_item ) {
799
-			if ( $child_line_item instanceof EE_Line_Item ) {
800
-				if ( $child_line_item->type() == $line_item_type && ( $child_line_item->OBJ_type() == $obj_type || $obj_type === NULL )) {
798
+		foreach ($parent_line_item->children() as $child_line_item) {
799
+			if ($child_line_item instanceof EE_Line_Item) {
800
+				if ($child_line_item->type() == $line_item_type && ($child_line_item->OBJ_type() == $obj_type || $obj_type === NULL)) {
801 801
 					$objects[] = $child_line_item;
802 802
 				} else {
803 803
 					//go-through-all-its children looking for more matches
804
-					$objects = array_merge( $objects, self::_get_descendants_by_type_and_object_type( $child_line_item, $line_item_type, $obj_type ));
804
+					$objects = array_merge($objects, self::_get_descendants_by_type_and_object_type($child_line_item, $line_item_type, $obj_type));
805 805
 				}
806 806
 			}
807 807
 		}
@@ -819,8 +819,8 @@  discard block
 block discarded – undo
819 819
 	 * @param array $OBJ_IDs array of OBJ_IDs
820 820
 	 * @return EE_Line_Item[]
821 821
 	 */
822
-	public static function get_line_items_by_object_type_and_IDs( EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array() ) {
823
-		return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs );
822
+	public static function get_line_items_by_object_type_and_IDs(EE_Line_Item $parent_line_item, $OBJ_type = '', $OBJ_IDs = array()) {
823
+		return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs);
824 824
 	}
825 825
 
826 826
 
@@ -833,15 +833,15 @@  discard block
 block discarded – undo
833 833
 	 * @param array $OBJ_IDs array of OBJ_IDs
834 834
 	 * @return EE_Line_Item[]
835 835
 	 */
836
-	protected static function _get_descendants_by_object_type_and_object_ID( EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs ) {
836
+	protected static function _get_descendants_by_object_type_and_object_ID(EE_Line_Item $parent_line_item, $OBJ_type, $OBJ_IDs) {
837 837
 		$objects = array();
838
-		foreach ( $parent_line_item->children() as $child_line_item ) {
839
-			if ( $child_line_item instanceof EE_Line_Item ) {
840
-				if ( is_array( $OBJ_IDs ) && $child_line_item->OBJ_type() == $OBJ_type && in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )) {
838
+		foreach ($parent_line_item->children() as $child_line_item) {
839
+			if ($child_line_item instanceof EE_Line_Item) {
840
+				if (is_array($OBJ_IDs) && $child_line_item->OBJ_type() == $OBJ_type && in_array($child_line_item->OBJ_ID(), $OBJ_IDs)) {
841 841
 					$objects[] = $child_line_item;
842 842
 				} else {
843 843
 					//go-through-all-its children looking for more matches
844
-					$objects = array_merge( $objects, self::_get_descendants_by_object_type_and_object_ID( $child_line_item, $OBJ_type, $OBJ_IDs ));
844
+					$objects = array_merge($objects, self::_get_descendants_by_object_type_and_object_ID($child_line_item, $OBJ_type, $OBJ_IDs));
845 845
 				}
846 846
 			}
847 847
 		}
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 	 * @param string $type like one of the EEM_Line_Item::type_*
860 860
 	 * @return EE_Line_Item
861 861
 	 */
862
-	public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) {
863
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type );
862
+	public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) {
863
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type);
864 864
 	}
865 865
 
866 866
 
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param string $code any value used for LIN_code
874 874
 	 * @return EE_Line_Item
875 875
 	 */
876
-	public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) {
877
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code );
876
+	public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) {
877
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code);
878 878
 	}
879 879
 
880 880
 
@@ -887,15 +887,15 @@  discard block
 block discarded – undo
887 887
 	 * @param string $value any value stored in $search_field
888 888
 	 * @return EE_Line_Item
889 889
 	 */
890
-	protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) {
891
-		foreach( $parent_line_item->children() as $child ){
892
-			if ( $child->get( $search_field ) == $value ){
890
+	protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) {
891
+		foreach ($parent_line_item->children() as $child) {
892
+			if ($child->get($search_field) == $value) {
893 893
 				return $child;
894 894
 			}
895 895
 		}
896
-		foreach( $parent_line_item->children() as $child ){
897
-			$descendant_found = self::_get_nearest_descendant( $child, $search_field, $value );
898
-			if ( $descendant_found ){
896
+		foreach ($parent_line_item->children() as $child) {
897
+			$descendant_found = self::_get_nearest_descendant($child, $search_field, $value);
898
+			if ($descendant_found) {
899 899
 				return $descendant_found;
900 900
 			}
901 901
 		}
@@ -911,22 +911,22 @@  discard block
 block discarded – undo
911 911
 	 * @param int $indentation
912 912
 	 * @return void
913 913
 	 */
914
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
914
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
915 915
 		echo "\n<br />";
916
-		for( $i = 0; $i < $indentation; $i++ ){
916
+		for ($i = 0; $i < $indentation; $i++) {
917 917
 			echo " - ";
918 918
 		}
919
-		if( $line_item->is_percent() ) {
920
-			$breakdown = $line_item->percent() . '%';
919
+		if ($line_item->is_percent()) {
920
+			$breakdown = $line_item->percent().'%';
921 921
 		} else {
922
-			$breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity();
922
+			$breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity();
923 923
 		}
924
-		echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")";
925
-		if( $line_item->is_taxable() ){
924
+		echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")";
925
+		if ($line_item->is_taxable()) {
926 926
 			echo "  * taxable";
927 927
 		}
928
-		if( $line_item->children() ){
929
-			foreach($line_item->children() as $child){
928
+		if ($line_item->children()) {
929
+			foreach ($line_item->children() as $child) {
930 930
 				self::visualize($child, $indentation + 1);
931 931
 			}
932 932
 		}
@@ -967,88 +967,88 @@  discard block
 block discarded – undo
967 967
 	 *                                          is theirs, which can be done with
968 968
 	 *                                          `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );`
969 969
 	 */
970
-	public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) {
970
+	public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) {
971 971
 		//init running grand total if not already
972
-		if ( ! isset( $running_totals[ 'total' ] ) ) {
973
-			$running_totals[ 'total' ] = 0;
972
+		if ( ! isset($running_totals['total'])) {
973
+			$running_totals['total'] = 0;
974 974
 		}
975
-		if( ! isset( $running_totals[ 'taxable' ] ) ) {
976
-			$running_totals[ 'taxable' ] = array( 'total' => 0 );
975
+		if ( ! isset($running_totals['taxable'])) {
976
+			$running_totals['taxable'] = array('total' => 0);
977 977
 		}
978
-		foreach ( $line_item->children() as $child_line_item ) {
979
-			switch ( $child_line_item->type() ) {
978
+		foreach ($line_item->children() as $child_line_item) {
979
+			switch ($child_line_item->type()) {
980 980
 
981 981
 				case EEM_Line_Item::type_sub_total :
982
-					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities );
982
+					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities);
983 983
 					//combine arrays but preserve numeric keys
984
-					$running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals );
985
-					$running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ];
986
-					$running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ];
984
+					$running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals);
985
+					$running_totals['total'] += $running_totals_from_subtotal['total'];
986
+					$running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total'];
987 987
 					break;
988 988
 
989 989
 				case EEM_Line_Item::type_tax_sub_total :
990 990
 
991 991
 					//find how much the taxes percentage is
992
-					if ( $child_line_item->percent() != 0 ) {
992
+					if ($child_line_item->percent() != 0) {
993 993
 						$tax_percent_decimal = $child_line_item->percent() / 100;
994 994
 					} else {
995 995
 						$tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100;
996 996
 					}
997 997
 					//and apply to all the taxable totals, and add to the pretax totals
998
-					foreach ( $running_totals as $line_item_id => $this_running_total ) {
998
+					foreach ($running_totals as $line_item_id => $this_running_total) {
999 999
 						//"total" and "taxable" array key is an exception
1000
-						if ( $line_item_id === 'taxable' ) {
1000
+						if ($line_item_id === 'taxable') {
1001 1001
 							continue;
1002 1002
 						}
1003
-						$taxable_total = $running_totals[ 'taxable' ][ $line_item_id ];
1004
-						$running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal );
1003
+						$taxable_total = $running_totals['taxable'][$line_item_id];
1004
+						$running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal);
1005 1005
 					}
1006 1006
 					break;
1007 1007
 
1008 1008
 				case EEM_Line_Item::type_line_item :
1009 1009
 
1010 1010
 					// ticket line items or ????
1011
-					if ( $child_line_item->OBJ_type() === 'Ticket' ) {
1011
+					if ($child_line_item->OBJ_type() === 'Ticket') {
1012 1012
 						// kk it's a ticket
1013
-						if ( isset( $running_totals[ $child_line_item->ID() ] ) ) {
1013
+						if (isset($running_totals[$child_line_item->ID()])) {
1014 1014
 							//huh? that shouldn't happen.
1015
-							$running_totals[ 'total' ] += $child_line_item->total();
1015
+							$running_totals['total'] += $child_line_item->total();
1016 1016
 						} else {
1017 1017
 							//its not in our running totals yet. great.
1018
-							if ( $child_line_item->is_taxable() ) {
1018
+							if ($child_line_item->is_taxable()) {
1019 1019
 								$taxable_amount = $child_line_item->unit_price();
1020 1020
 							} else {
1021 1021
 								$taxable_amount = 0;
1022 1022
 							}
1023 1023
 							// are we only calculating totals for some tickets?
1024
-							if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) {
1025
-								$quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ];
1026
-								$running_totals[ $child_line_item->ID() ] = $quantity ? $child_line_item->unit_price() : 0;
1027
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity ? $taxable_amount : 0;
1024
+							if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) {
1025
+								$quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()];
1026
+								$running_totals[$child_line_item->ID()] = $quantity ? $child_line_item->unit_price() : 0;
1027
+								$running_totals['taxable'][$child_line_item->ID()] = $quantity ? $taxable_amount : 0;
1028 1028
 							} else {
1029 1029
 								$quantity = $child_line_item->quantity();
1030
-								$running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price();
1031
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount;
1030
+								$running_totals[$child_line_item->ID()] = $child_line_item->unit_price();
1031
+								$running_totals['taxable'][$child_line_item->ID()] = $taxable_amount;
1032 1032
 							}
1033
-							$running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity;
1034
-							$running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity;
1033
+							$running_totals['taxable']['total'] += $taxable_amount * $quantity;
1034
+							$running_totals['total'] += $child_line_item->unit_price() * $quantity;
1035 1035
 						}
1036 1036
 					} else {
1037 1037
 						// it's some other type of item added to the cart
1038 1038
 						// it should affect the running totals
1039 1039
 						// basically we want to convert it into a PERCENT modifier. Because
1040 1040
 						// more clearly affect all registration's final price equally
1041
-						$line_items_percent_of_running_total = $running_totals[ 'total' ] > 0 ? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1 : 1;
1042
-						foreach ( $running_totals as $line_item_id => $this_running_total ) {
1041
+						$line_items_percent_of_running_total = $running_totals['total'] > 0 ? ($child_line_item->total() / $running_totals['total']) + 1 : 1;
1042
+						foreach ($running_totals as $line_item_id => $this_running_total) {
1043 1043
 							//the "taxable" array key is an exception
1044
-							if ( $line_item_id === 'taxable' ) {
1044
+							if ($line_item_id === 'taxable') {
1045 1045
 								continue;
1046 1046
 							}
1047 1047
 							// update the running totals
1048 1048
 							// yes this actually even works for the running grand total!
1049
-							$running_totals[ $line_item_id ] = $line_items_percent_of_running_total * $this_running_total;
1050
-							if ( $child_line_item->is_taxable() ) {
1051
-								$running_totals[ 'taxable' ][ $line_item_id ] = $line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ];
1049
+							$running_totals[$line_item_id] = $line_items_percent_of_running_total * $this_running_total;
1050
+							if ($child_line_item->is_taxable()) {
1051
+								$running_totals['taxable'][$line_item_id] = $line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id];
1052 1052
 							}
1053 1053
 						}
1054 1054
 					}
@@ -1067,15 +1067,15 @@  discard block
 block discarded – undo
1067 1067
 	 * @param EE_Registration[] $registrations
1068 1068
 	 * @return \EE_Line_Item
1069 1069
 	 */
1070
-	public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) {
1071
-		$copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations );
1072
-		foreach ( $line_item->children() as $child_li ) {
1073
-			$copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) );
1070
+	public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) {
1071
+		$copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations);
1072
+		foreach ($line_item->children() as $child_li) {
1073
+			$copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations));
1074 1074
 		}
1075 1075
 		//if this is the grand total line item, make sure the totals all add up
1076 1076
 		//(we could have duplicated this logic AS we copied the line items, but
1077 1077
 		//it seems DRYer this way)
1078
-		if ( $copy_li->type() === EEM_Line_Item::type_total ) {
1078
+		if ($copy_li->type() === EEM_Line_Item::type_total) {
1079 1079
 			$copy_li->recalculate_total_including_taxes();
1080 1080
 		}
1081 1081
 		return $copy_li;
@@ -1090,26 +1090,26 @@  discard block
 block discarded – undo
1090 1090
 	 * @return EE_Line_Item
1091 1091
 	 * @param EE_Registration[] $registrations
1092 1092
 	 */
1093
-	public static function billable_line_item( EE_Line_Item $line_item, $registrations ) {
1093
+	public static function billable_line_item(EE_Line_Item $line_item, $registrations) {
1094 1094
 		$new_li_fields = $line_item->model_field_array();
1095
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1095
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1096 1096
 			$line_item->OBJ_type() === 'Ticket'
1097 1097
 		) {
1098 1098
 			$count = 0;
1099
-			foreach ( $registrations as $registration ) {
1100
-				if ( $line_item->OBJ_ID() === $registration->ticket_ID() &&
1101
-					in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() )
1099
+			foreach ($registrations as $registration) {
1100
+				if ($line_item->OBJ_ID() === $registration->ticket_ID() &&
1101
+					in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment())
1102 1102
 				) {
1103 1103
 					$count++;
1104 1104
 				}
1105 1105
 			}
1106
-			$new_li_fields[ 'LIN_quantity' ] = $count;
1106
+			$new_li_fields['LIN_quantity'] = $count;
1107 1107
 		}
1108 1108
 		//don't set the total. We'll leave that up to the code that calculates it
1109
-		unset( $new_li_fields[ 'LIN_ID' ] );
1110
-		unset( $new_li_fields[ 'LIN_parent' ] );
1111
-		unset( $new_li_fields[ 'LIN_total' ] );
1112
-		return EE_Line_Item::new_instance( $new_li_fields );
1109
+		unset($new_li_fields['LIN_ID']);
1110
+		unset($new_li_fields['LIN_parent']);
1111
+		unset($new_li_fields['LIN_total']);
1112
+		return EE_Line_Item::new_instance($new_li_fields);
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1121,19 +1121,19 @@  discard block
 block discarded – undo
1121 1121
 	 * @param EE_Line_Item $line_item |null
1122 1122
 	 * @return \EE_Line_Item|null
1123 1123
 	 */
1124
-	public static function non_empty_line_items( EE_Line_Item $line_item ) {
1125
-		$copied_li = EEH_Line_Item::non_empty_line_item( $line_item );
1126
-		if ( $copied_li === null ) {
1124
+	public static function non_empty_line_items(EE_Line_Item $line_item) {
1125
+		$copied_li = EEH_Line_Item::non_empty_line_item($line_item);
1126
+		if ($copied_li === null) {
1127 1127
 			return null;
1128 1128
 		}
1129 1129
 		//if this is an event subtotal, we want to only include it if it
1130 1130
 		//has a non-zero total and at least one ticket line item child
1131 1131
 		$ticket_children = 0;
1132
-		foreach ( $line_item->children() as $child_li ) {
1133
-			$child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li );
1134
-			if ( $child_li_copy !== null ) {
1135
-				$copied_li->add_child_line_item( $child_li_copy );
1136
-				if ( $child_li_copy->type() === EEM_Line_Item::type_line_item &&
1132
+		foreach ($line_item->children() as $child_li) {
1133
+			$child_li_copy = EEH_Line_Item::non_empty_line_items($child_li);
1134
+			if ($child_li_copy !== null) {
1135
+				$copied_li->add_child_line_item($child_li_copy);
1136
+				if ($child_li_copy->type() === EEM_Line_Item::type_line_item &&
1137 1137
 					$child_li_copy->OBJ_type() === 'Ticket'
1138 1138
 				) {
1139 1139
 					$ticket_children++;
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 		}
1143 1143
 		//if this is an event subtotal with NO ticket children
1144 1144
 		//we basically want to ignore it
1145
-		if ( $line_item->type() === EEM_Line_Item::type_sub_total &&
1145
+		if ($line_item->type() === EEM_Line_Item::type_sub_total &&
1146 1146
 			$line_item->OBJ_type() === 'Event' &&
1147 1147
 			$ticket_children === 0 &&
1148 1148
 			$line_item->total() === 0
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 	 * @param EE_Line_Item      $line_item
1161 1161
 	 * @return EE_Line_Item
1162 1162
 	 */
1163
-	public static function non_empty_line_item( EE_Line_Item $line_item ) {
1164
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1163
+	public static function non_empty_line_item(EE_Line_Item $line_item) {
1164
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1165 1165
 			$line_item->OBJ_type() === 'Ticket' &&
1166 1166
 			$line_item->quantity() == 0
1167 1167
 		) {
@@ -1169,9 +1169,9 @@  discard block
 block discarded – undo
1169 1169
 		}
1170 1170
 		$new_li_fields = $line_item->model_field_array();
1171 1171
 		//don't set the total. We'll leave that up to the code that calculates it
1172
-		unset( $new_li_fields[ 'LIN_ID' ] );
1173
-		unset( $new_li_fields[ 'LIN_parent' ] );
1174
-		return EE_Line_Item::new_instance( $new_li_fields );
1172
+		unset($new_li_fields['LIN_ID']);
1173
+		unset($new_li_fields['LIN_parent']);
1174
+		return EE_Line_Item::new_instance($new_li_fields);
1175 1175
 	}
1176 1176
 
1177 1177
 
@@ -1185,9 +1185,9 @@  discard block
 block discarded – undo
1185 1185
 	 * @param EE_Line_Item $total_line_item
1186 1186
 	 *	@return \EE_Line_Item
1187 1187
 	 */
1188
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
1189
-		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' );
1190
-		return self::get_pre_tax_subtotal( $total_line_item );
1188
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
1189
+		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');
1190
+		return self::get_pre_tax_subtotal($total_line_item);
1191 1191
 	}
1192 1192
 
1193 1193
 
@@ -1197,9 +1197,9 @@  discard block
 block discarded – undo
1197 1197
 	 * @param EE_Transaction $transaction
1198 1198
 	 *	@return \EE_Line_Item
1199 1199
 	 */
1200
-	public static function create_default_total_line_item( $transaction = NULL) {
1201
-		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' );
1202
-		return self::create_total_line_item( $transaction );
1200
+	public static function create_default_total_line_item($transaction = NULL) {
1201
+		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');
1202
+		return self::create_total_line_item($transaction);
1203 1203
 	}
1204 1204
 
1205 1205
 
@@ -1210,9 +1210,9 @@  discard block
 block discarded – undo
1210 1210
 	 * @param EE_Transaction $transaction
1211 1211
 	 *	@return \EE_Line_Item
1212 1212
 	 */
1213
-	public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1214
-		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' );
1215
-		return self::create_pre_tax_subtotal( $total_line_item, $transaction );
1213
+	public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1214
+		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');
1215
+		return self::create_pre_tax_subtotal($total_line_item, $transaction);
1216 1216
 	}
1217 1217
 
1218 1218
 
@@ -1223,9 +1223,9 @@  discard block
 block discarded – undo
1223 1223
 	 * @param EE_Transaction $transaction
1224 1224
 	 *	@return \EE_Line_Item
1225 1225
 	 */
1226
-	public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1227
-		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' );
1228
-		return self::create_taxes_subtotal( $total_line_item, $transaction );
1226
+	public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1227
+		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');
1228
+		return self::create_taxes_subtotal($total_line_item, $transaction);
1229 1229
 	}
1230 1230
 
1231 1231
 
@@ -1236,9 +1236,9 @@  discard block
 block discarded – undo
1236 1236
 	 * @param EE_Transaction $transaction
1237 1237
 	 *	@return \EE_Line_Item
1238 1238
 	 */
1239
-	public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1240
-		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' );
1241
-		return self::create_event_subtotal( $total_line_item, $transaction );
1239
+	public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1240
+		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');
1241
+		return self::create_event_subtotal($total_line_item, $transaction);
1242 1242
 	}
1243 1243
 
1244 1244
 
Please login to merge, or discard this patch.
core/helpers/EEH_Maps.helper.php 2 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -31,7 +31,6 @@  discard block
 block discarded – undo
31 31
 
32 32
 	/**
33 33
 	 * google_map - creates a Google Map Link
34
-	 * @param  array $atts aray of attributes required for the map link generation
35 34
 	 * @return string (link to map!)
36 35
 	 */
37 36
 	public static function google_map( $ee_gmaps_opts ){
@@ -116,7 +115,6 @@  discard block
 block discarded – undo
116 115
 
117 116
 	/**
118 117
 	 * creates a Google Map Link
119
-	 * @param  array $atts aray of attributes required for the map link generation
120 118
 	 * @return string (link to map!)
121 119
 	 */
122 120
 	public static function espresso_google_map_js() {
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
 	 * @param  array $atts aray of attributes required for the map link generation
35 35
 	 * @return string (link to map!)
36 36
 	 */
37
-	public static function google_map( $ee_gmaps_opts ){
37
+	public static function google_map($ee_gmaps_opts) {
38 38
 
39 39
 		//d( $ee_gmaps_opts );
40 40
 
41
-		$ee_map_width = isset( $ee_gmaps_opts['ee_map_width'] ) && ! empty( $ee_gmaps_opts['ee_map_width'] ) ? $ee_gmaps_opts['ee_map_width'] : '300';
42
-		$ee_map_height = isset( $ee_gmaps_opts['ee_map_height'] ) && ! empty( $ee_gmaps_opts['ee_map_height'] ) ? $ee_gmaps_opts['ee_map_height'] : '185';
43
-		$ee_map_zoom = isset( $ee_gmaps_opts['ee_map_zoom'] ) && ! empty( $ee_gmaps_opts['ee_map_zoom'] ) ? $ee_gmaps_opts['ee_map_zoom'] : '12';
44
-		$ee_map_nav_display = isset( $ee_gmaps_opts['ee_map_nav_display'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_display'] ) ? 'true' : 'false';
45
-		$ee_map_nav_size =  isset( $ee_gmaps_opts['ee_map_nav_size'] ) && ! empty( $ee_gmaps_opts['ee_map_nav_size'] )? $ee_gmaps_opts['ee_map_nav_size'] : 'default';
46
-		$ee_map_type_control =  isset( $ee_gmaps_opts['ee_map_type_control'] ) && ! empty( $ee_gmaps_opts['ee_map_type_control'] )? $ee_gmaps_opts['ee_map_type_control'] : 'default';
47
-		$static_url =  isset( $ee_gmaps_opts['ee_static_url'] ) && ! empty( $ee_gmaps_opts['ee_static_url'] )? $ee_gmaps_opts['ee_static_url'] : FALSE;
41
+		$ee_map_width = isset($ee_gmaps_opts['ee_map_width']) && ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300';
42
+		$ee_map_height = isset($ee_gmaps_opts['ee_map_height']) && ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185';
43
+		$ee_map_zoom = isset($ee_gmaps_opts['ee_map_zoom']) && ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12';
44
+		$ee_map_nav_display = isset($ee_gmaps_opts['ee_map_nav_display']) && ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false';
45
+		$ee_map_nav_size = isset($ee_gmaps_opts['ee_map_nav_size']) && ! empty($ee_gmaps_opts['ee_map_nav_size']) ? $ee_gmaps_opts['ee_map_nav_size'] : 'default';
46
+		$ee_map_type_control = isset($ee_gmaps_opts['ee_map_type_control']) && ! empty($ee_gmaps_opts['ee_map_type_control']) ? $ee_gmaps_opts['ee_map_type_control'] : 'default';
47
+		$static_url = isset($ee_gmaps_opts['ee_static_url']) && ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : FALSE;
48 48
 
49
-		if( isset( $ee_gmaps_opts['ee_map_align'] ) && ! empty( $ee_gmaps_opts['ee_map_align'] )){
50
-			switch( $ee_gmaps_opts['ee_map_align'] ){
49
+		if (isset($ee_gmaps_opts['ee_map_align']) && ! empty($ee_gmaps_opts['ee_map_align'])) {
50
+			switch ($ee_gmaps_opts['ee_map_align']) {
51 51
 				case "left":
52 52
 					$map_align = 'ee-gmap-align-left left';
53 53
 					break;
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 
69 69
 		// Determine whether user has set a hardoded url to use and
70 70
 		// if so display a Google static iframe map else run V3 api
71
-		if( $static_url ) {
71
+		if ($static_url) {
72 72
 
73
-			$html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">';
74
-			$html .= '<iframe src="' . $static_url . '&output=embed" style="width: ' . $ee_map_width  .'px; height: ' . $ee_map_height . 'px;" frameborder="0" scrolling="no">';
73
+			$html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper '.$map_align.'">';
74
+			$html .= '<iframe src="'.$static_url.'&output=embed" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;" frameborder="0" scrolling="no">';
75 75
 			$html .= '</iframe>';
76
-			$html .= '<a href="' . $static_url . '">View Large map</a>';
76
+			$html .= '<a href="'.$static_url.'">View Large map</a>';
77 77
 			$html .= '</div>';
78 78
 			return $html;
79 79
 
80 80
 		 } else {
81 81
 
82
-			EEH_Maps::$gmap_vars[ $ee_gmaps_opts['map_ID'] ] = array(
82
+			EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array(
83 83
 				'map_ID' => $ee_gmaps_opts['map_ID'],
84 84
 				'ee_map_zoom' => $ee_map_zoom,
85 85
 				'ee_map_nav_display' => $ee_map_nav_display,
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 			);
90 90
 
91 91
 			$html = '<div class="ee-gmap-wrapper '.$map_align.';">';
92
-			$html .= '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] .'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>';  //
92
+			$html .= '<div class="ee-gmap" id="map_canvas_'.$ee_gmaps_opts['map_ID'].'" style="width: '.$ee_map_width.'px; height: '.$ee_map_height.'px;"></div>'; //
93 93
 			$html .= '</div>';
94 94
 
95
-			wp_enqueue_script( 'gmap_api' );
96
-			wp_enqueue_script( 'ee_gmap' );
97
-			add_action( 'wp_footer', array( 'EEH_Maps', 'footer_enqueue_script' ));
95
+			wp_enqueue_script('gmap_api');
96
+			wp_enqueue_script('ee_gmap');
97
+			add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script'));
98 98
 
99 99
 			return $html;
100 100
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return void
110 110
 	 */
111 111
 	public static function footer_enqueue_script() {
112
-		wp_localize_script( 'ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars );
112
+		wp_localize_script('ee_gmap', 'ee_gmap_vars', EEH_Maps::$gmap_vars);
113 113
 	}
114 114
 
115 115
 
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
 	 */
122 122
 	public static function espresso_google_map_js() {
123 123
 		$scheme = is_ssl() ? 'https://' : 'http://';
124
-		wp_register_script( 'gmap_api', $scheme . 'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE );
125
-		wp_register_script( 'ee_gmap', plugin_dir_url(__FILE__) . 'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE );
124
+		wp_register_script('gmap_api', $scheme.'maps.google.com/maps/api/js?sensor=false', array('jquery'), NULL, TRUE);
125
+		wp_register_script('ee_gmap', plugin_dir_url(__FILE__).'assets/ee_gmap.js', array('gmap_api'), '1.0', TRUE);
126 126
 	}
127 127
 
128 128
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return string (link to map!)
132 132
 	 */
133 133
 	public static function google_map_link($atts) {
134
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
134
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
135 135
 		extract($atts);
136 136
 
137 137
 		$address = "{$address}";
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 		$id = isset($id) ? $id : 'not_set';
147 147
 		$map_image_class = isset($map_image_class) ? $map_image_class : 'ee_google_map_view';
148 148
 
149
-		$address_string = ($address != '' ? $address : '') . ($city != '' ? ',' . $city : '') . ($state != '' ? ',' . $state : '') . ($zip != '' ? ',' . $zip : '') . ($country != '' ? ',' . $country : '');
149
+		$address_string = ($address != '' ? $address : '').($city != '' ? ','.$city : '').($state != '' ? ','.$state : '').($zip != '' ? ','.$zip : '').($country != '' ? ','.$country : '');
150 150
 
151
-		$google_map = htmlentities2('http://maps.google.com/maps?q=' . urlencode( $address_string ));
151
+		$google_map = htmlentities2('http://maps.google.com/maps?q='.urlencode($address_string));
152 152
 
153 153
 		switch ($type) {
154 154
 			case 'text':
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 
163 163
 			case 'map':
164 164
 				$scheme = is_ssl() ? 'https://' : 'http://';
165
-				return '<a class="a_map_image_link" href="' . $google_map . '" target="_blank">' . '<img class="map_image_link" id="venue_map_' . $id . '" ' . $map_image_class . ' src="' . htmlentities2( $scheme . 'maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $address_string ) . '&amp;zoom=14&amp;size=' . $map_w . 'x' . $map_h . '&amp;markers=color:green|label:|' . urlencode( $address_string ) . '&amp;sensor=false' ) . '" /></a>';
165
+				return '<a class="a_map_image_link" href="'.$google_map.'" target="_blank">'.'<img class="map_image_link" id="venue_map_'.$id.'" '.$map_image_class.' src="'.htmlentities2($scheme.'maps.googleapis.com/maps/api/staticmap?center='.urlencode($address_string).'&amp;zoom=14&amp;size='.$map_w.'x'.$map_h.'&amp;markers=color:green|label:|'.urlencode($address_string).'&amp;sensor=false').'" /></a>';
166 166
 		}
167 167
 
168
-		return '<a href="' . $google_map . '" target="_blank">' . $text . '</a>';
168
+		return '<a href="'.$google_map.'" target="_blank">'.$text.'</a>';
169 169
 	}
170 170
 
171 171
 
Please login to merge, or discard this patch.
core/helpers/EEH_Qtip_Loader.helper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
 	 * - registers and enqueues the qtip scripts and styles.
110 110
 	 *
111 111
 	 * @access public
112
-	 * @param  array  $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s) first.  If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded.
112
+	 * @param  string[]  $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s) first.  If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded.
113 113
 	 * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
114 114
 	 * @return void
115 115
 	 */
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function instance() {
34 34
 		// check if class object is instantiated
35
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
35
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) {
36 36
 			self::$_instance = new self();
37 37
 		}
38 38
 		return self::$_instance;
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	private function __construct() {
50 50
 		//let's just make sure this is instantiated in the right place.
51
-		if ( did_action( 'wp_print_styles' ) || did_action( 'admin_head' )) {
52
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso' ), '4.1' );
51
+		if (did_action('wp_print_styles') || did_action('admin_head')) {
52
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader', __('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1');
53 53
 		}
54 54
 	}
55 55
 
@@ -61,27 +61,27 @@  discard block
 block discarded – undo
61 61
 	 * @return void
62 62
 	 */
63 63
 	public function register_and_enqueue() {
64
-		$qtips_js = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.js';
65
-		$qtip_images_loaded = EE_THIRD_PARTY_URL . 'qtip/imagesloaded.pkg.min.js';
66
-		$qtip_map = EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.map';
67
-		$qtipcss = !defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL . 'qtip/jquery.qtip.css';
64
+		$qtips_js = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.js' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.js';
65
+		$qtip_images_loaded = EE_THIRD_PARTY_URL.'qtip/imagesloaded.pkg.min.js';
66
+		$qtip_map = EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.map';
67
+		$qtipcss = ! defined('SCRIPT_DEBUG') ? EE_THIRD_PARTY_URL.'qtip/jquery.qtip.min.css' : EE_THIRD_PARTY_URL.'qtip/jquery.qtip.css';
68 68
 
69
-		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE );
70
-		wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE );
71
-		wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE );
72
-		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE );
69
+		wp_register_script('qtip-map', $qtip_map, array(), '3', TRUE);
70
+		wp_register_script('qtip-images-loaded', $qtip_images_loaded, array(), '2.2.0', TRUE);
71
+		wp_register_script('qtip', $qtips_js, array('jquery'), '2.2.0', TRUE);
72
+		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, TRUE);
73 73
 
74
-		wp_register_style('qtip-css', $qtipcss, array(), '2.2' );
74
+		wp_register_style('qtip-css', $qtipcss, array(), '2.2');
75 75
 
76 76
 		//k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
77
-		if ( !empty( $this->_qtips ) ) {
77
+		if ( ! empty($this->_qtips)) {
78 78
 			wp_enqueue_script('ee-qtip-helper');
79 79
 			wp_enqueue_style('qtip-css');
80 80
 			$qtips = array();
81
-			foreach ( $this->_qtips as $qtip ) {
81
+			foreach ($this->_qtips as $qtip) {
82 82
 				$qts = $qtip->get_tips();
83
-				foreach ( $qts as $qt ) {
84
-					if ( ! $qt instanceof EE_Qtip )
83
+				foreach ($qts as $qt) {
84
+					if ( ! $qt instanceof EE_Qtip)
85 85
 						continue;
86 86
 					$qtips[] = array(
87 87
 						'content_id' => $qt->content_id,
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 						);
91 91
 				}
92 92
 			}
93
-			if ( !empty($qtips) )
94
-				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
93
+			if ( ! empty($qtips))
94
+				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips));
95 95
 
96 96
 		} else {
97 97
 			//qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -113,24 +113,24 @@  discard block
 block discarded – undo
113 113
 	 * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
114 114
 	 * @return void
115 115
 	 */
116
-	public function register( $configname, $paths = array() ) {
116
+	public function register($configname, $paths = array()) {
117 117
 
118 118
 		//let's just make sure this is instantiated in the right place.
119
-		if ( did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts') ) {
120
-			EE_Error::doing_it_wrong( 'EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso' ), '4.1' );
119
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
120
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', __('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
121 121
 		}
122 122
 
123 123
 		$configname = (array) $configname; //typecast to array
124
-		foreach ( $configname as $config ) {
125
-			$this->_register( $config, $paths );
124
+		foreach ($configname as $config) {
125
+			$this->_register($config, $paths);
126 126
 		}
127 127
 
128 128
 		//hook into appropriate footer
129 129
 		$footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
130
-		add_action($footer_action, array($this, 'setup_qtip'), 10 );
130
+		add_action($footer_action, array($this, 'setup_qtip'), 10);
131 131
 
132 132
 		//make sure we "turn on" qtip js.
133
-		add_filter('FHEE_load_qtip', '__return_true' );
133
+		add_filter('FHEE_load_qtip', '__return_true');
134 134
 	}
135 135
 
136 136
 
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	 * @throws EE_Error
145 145
 	 * @return void
146 146
 	 */
147
-	private function _register( $config, $paths ) {
147
+	private function _register($config, $paths) {
148 148
 		//before doing anything we have to make sure that EE_Qtip_Config parent is required.
149
-		EE_Registry::instance()->load_lib( 'Qtip_Config', array(), TRUE );
149
+		EE_Registry::instance()->load_lib('Qtip_Config', array(), TRUE);
150 150
 
151
-		if ( !empty( $paths ) ) {
151
+		if ( ! empty($paths)) {
152 152
 			$paths = (array) $paths;
153
-			foreach ( $paths as $path ) {
154
-				$path = $path . $config . '.lib.php';
155
-				if ( !is_readable($path ) ) {
153
+			foreach ($paths as $path) {
154
+				$path = $path.$config.'.lib.php';
155
+				if ( ! is_readable($path)) {
156 156
 					continue;
157 157
 				} else {
158 158
 					require_once $path;
@@ -161,26 +161,26 @@  discard block
 block discarded – undo
161 161
 		}
162 162
 
163 163
 		//does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
164
-		if ( !class_exists($config) ) {
165
-			$path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
166
-			if ( !is_readable($path ) ) {
167
-				throw new EE_Error( sprintf( __('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config ) );
164
+		if ( ! class_exists($config)) {
165
+			$path = EE_LIBRARIES.'qtips/'.$config.'.lib.php';
166
+			if ( ! is_readable($path)) {
167
+				throw new EE_Error(sprintf(__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
168 168
 			} else {
169 169
 				require_once $path;
170 170
 			}
171 171
 		}
172 172
 
173 173
 		//now we attempt a class_exists one more time.
174
-		if ( !class_exists( $config ) )
175
-			throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
174
+		if ( ! class_exists($config))
175
+			throw new EE_Error(sprintf(__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
176 176
 
177 177
 		//made it HERE?  FINALLY, let's get things setup.
178 178
 		$a = new ReflectionClass($config);
179 179
 		$qtip = $a->newInstance();
180 180
 
181 181
 		//verify that $qtip is a valid object
182
-		if ( ! $qtip instanceof EE_Qtip_Config )
183
-			throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) );
182
+		if ( ! $qtip instanceof EE_Qtip_Config)
183
+			throw new EE_Error(sprintf(__('The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config));
184 184
 
185 185
 		$this->_qtips[] = $a->newInstance();
186 186
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
 	 * @return void
197 197
 	 */
198 198
 	public function setup_qtip() {
199
-		if ( empty( $this->_qtips ) )
199
+		if (empty($this->_qtips))
200 200
 			return; //no qtips!
201 201
 
202 202
 		$content = array();
203 203
 
204
-		foreach ( $this->_qtips as $qtip ) {
204
+		foreach ($this->_qtips as $qtip) {
205 205
 			$content[] = $this->_generate_content_container($qtip);
206 206
 		}
207 207
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
 	private function _generate_content_container($qtip) {
219 219
 		$qts = $qtip->get_tips();
220 220
 		$content = array();
221
-		foreach ( $qts as $qt ) {
222
-			if ( ! $qt instanceof EE_Qtip )
221
+		foreach ($qts as $qt) {
222
+			if ( ! $qt instanceof EE_Qtip)
223 223
 				continue;
224
-			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>';
224
+			$content[] = '<div class="ee-qtip-helper-content hidden" id="'.$qt->content_id.'">'.$qt->content.'</div>';
225 225
 		}
226 226
 
227 227
 		return implode('<br />', $content);
Please login to merge, or discard this patch.
Braces   +19 added lines, -12 removed lines patch added patch discarded remove patch
@@ -81,8 +81,9 @@  discard block
 block discarded – undo
81 81
 			foreach ( $this->_qtips as $qtip ) {
82 82
 				$qts = $qtip->get_tips();
83 83
 				foreach ( $qts as $qt ) {
84
-					if ( ! $qt instanceof EE_Qtip )
85
-						continue;
84
+					if ( ! $qt instanceof EE_Qtip ) {
85
+											continue;
86
+					}
86 87
 					$qtips[] = array(
87 88
 						'content_id' => $qt->content_id,
88 89
 						'options' => $qt->options,
@@ -90,8 +91,9 @@  discard block
 block discarded – undo
90 91
 						);
91 92
 				}
92 93
 			}
93
-			if ( !empty($qtips) )
94
-				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
94
+			if ( !empty($qtips) ) {
95
+							wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ) );
96
+			}
95 97
 
96 98
 		} else {
97 99
 			//qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -171,16 +173,18 @@  discard block
 block discarded – undo
171 173
 		}
172 174
 
173 175
 		//now we attempt a class_exists one more time.
174
-		if ( !class_exists( $config ) )
175
-			throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
176
+		if ( !class_exists( $config ) ) {
177
+					throw new EE_Error( sprintf( __('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config ) );
178
+		}
176 179
 
177 180
 		//made it HERE?  FINALLY, let's get things setup.
178 181
 		$a = new ReflectionClass($config);
179 182
 		$qtip = $a->newInstance();
180 183
 
181 184
 		//verify that $qtip is a valid object
182
-		if ( ! $qtip instanceof EE_Qtip_Config )
183
-			throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) );
185
+		if ( ! $qtip instanceof EE_Qtip_Config ) {
186
+					throw new EE_Error( sprintf( __( 'The class given for the Qtip loader (%s) is not a child of the <strong>EE_Qtip_Config</strong> class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config ) );
187
+		}
184 188
 
185 189
 		$this->_qtips[] = $a->newInstance();
186 190
 
@@ -196,8 +200,10 @@  discard block
 block discarded – undo
196 200
 	 * @return void
197 201
 	 */
198 202
 	public function setup_qtip() {
199
-		if ( empty( $this->_qtips ) )
200
-			return; //no qtips!
203
+		if ( empty( $this->_qtips ) ) {
204
+					return;
205
+		}
206
+		//no qtips!
201 207
 
202 208
 		$content = array();
203 209
 
@@ -219,8 +225,9 @@  discard block
 block discarded – undo
219 225
 		$qts = $qtip->get_tips();
220 226
 		$content = array();
221 227
 		foreach ( $qts as $qt ) {
222
-			if ( ! $qt instanceof EE_Qtip )
223
-				continue;
228
+			if ( ! $qt instanceof EE_Qtip ) {
229
+							continue;
230
+			}
224 231
 			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . $qt->content_id . '">' . $qt->content . '</div>';
225 232
 		}
226 233
 
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 	/**
132 132
 	 * this just returns the properly formatted tab content for our tab box.
133 133
 	 * @param  string $name    name of tab (used for selector)
134
-	 * @param  string $content content of tab
134
+	 * @param  string $tab_content content of tab
135 135
 	 * @return string          html for content area
136 136
 	 */
137 137
 	private static function tab_content($name, $tab_content, $active = false) {
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 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
 /**
@@ -43,22 +43,22 @@  discard block
 block discarded – undo
43 43
 	 * @param  array $tabs_content an array of the content for each tab [required]
44 44
 	 * @return string               the assembled html string containing the tabbed content for display.
45 45
 	 */
46
-	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) {
46
+	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) {
47 47
 
48 48
 		//first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
49
-		if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) {
50
-			throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') );
49
+		if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
50
+			throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso'));
51 51
 		}
52 52
 
53 53
 		//make sure we've got incoming data setup properly
54
-		$tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents );
55
-		$tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents;
54
+		$tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents);
55
+		$tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents;
56 56
 
57
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
57
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
58 58
 		$all_tabs_content = '';
59 59
 
60 60
 		$index = 0;
61
-		foreach ( $tabs as $tab ) {
61
+		foreach ($tabs as $tab) {
62 62
 			$active = $index === 0 ? true : false;
63 63
 			$all_tabs .= self::tab($tab, $active);
64 64
 			$all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 
76 76
 		$tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs';
77 77
 
78
-		return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>';
78
+		return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>';
79 79
 	}
80 80
 
81 81
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 * @param array $nav_tabs tab array for nav tabs
99 99
 	 */
100 100
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
101
-		if ( empty($nav_tabs) )
102
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
101
+		if (empty($nav_tabs))
102
+			throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso'));
103 103
 
104
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
105
-		foreach ( $nav_tabs as $slug => $tab ) {
104
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
105
+		foreach ($nav_tabs as $slug => $tab) {
106 106
 			$all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
107 107
 		}
108 108
 		$all_tabs .= '</h2>';
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param bool|string $css If string given then the generated tab will include that as the class.
119 119
 	 * @return string          html for tab
120 120
 	 */
121
-	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) {
121
+	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) {
122 122
 		$name = str_replace(' ', '-', $name);
123 123
 		$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
124
-		$class = $css ? $class . ' ' . $css : $class;
125
-		$nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) );
126
-		$url = $url ? $url : '#' . $name;
127
-		$tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t";
124
+		$class = $css ? $class.' '.$css : $class;
125
+		$nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name));
126
+		$url = $url ? $url : '#'.$name;
127
+		$tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t";
128 128
 		return $tab;
129 129
 	}
130 130
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	private static function tab_content($name, $tab_content, $active = false) {
138 138
 		$class = $active ? 'nav-tab-content' : 'nav-tab-content hidden';
139
-		$name = str_replace( ' ', '-', $name);
140
-		$content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n";
141
-		$content .= "\t" . $tab_content . "\n";
139
+		$name = str_replace(' ', '-', $name);
140
+		$content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n";
141
+		$content .= "\t".$tab_content."\n";
142 142
 		$content .= '<div style="clear:both"></div></div>';
143 143
 		return $content;
144 144
 	}
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param string $default 			You can include a string for the item that will receive the "item_display" class for the js.
165 165
 	 * @return string                  a html snippet of of all the formatted link elements.
166 166
 	 */
167
-	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
168
-		if ( !is_array($item_array) || empty( $item_array ) )
167
+	public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') {
168
+		if ( ! is_array($item_array) || empty($item_array))
169 169
 			return false; //get out we don't have even the basic thing we need!
170 170
 
171 171
 
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
 			'title' => esc_attr__('Link for Item', 'event_espresso'),
177 177
 			'slug' => 'item_slug'
178 178
 		);
179
-		$container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links';
180
-		$list = '<ul class="' . $container_class . '">';
179
+		$container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links';
180
+		$list = '<ul class="'.$container_class.'">';
181 181
 
182 182
 		$ci = 1;
183
-		foreach ( $item_array as $item ) {
184
-			$item = wp_parse_args( $item, $defaults );
185
-			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
183
+		foreach ($item_array as $item) {
184
+			$item = wp_parse_args($item, $defaults);
185
+			$item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class'];
186 186
 			$list .= self::_text_link_item($item);
187
-			if ( !empty($sep) && $ci != count($item_array) )
187
+			if ( ! empty($sep) && $ci != count($item_array))
188 188
 				$list .= self::_text_link_item($sep);
189 189
 			$ci++;
190 190
 		}
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
 
197 197
 
198
-	private static function _text_link_item( $item ) {
198
+	private static function _text_link_item($item) {
199 199
 		//if this isn't an array then we're doing a separator
200
-		if ( !is_array( $item ) ) {
200
+		if ( ! is_array($item)) {
201 201
 			$label = $item;
202 202
 			$class = 'ee-text-link-sep';
203 203
 			$href = '';
@@ -206,12 +206,12 @@  discard block
 block discarded – undo
206 206
 			extract($item);
207 207
 		}
208 208
 
209
-		$class = $class != 'ee-text-link-sep'  ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"';
209
+		$class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"';
210 210
 
211
-		$content = '<li ' . $class . '>';
212
-		$content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : '';
211
+		$content = '<li '.$class.'>';
212
+		$content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : '';
213 213
 		$content .= $label;
214
-		$content .= !empty($href) ? '</a>' : '';
214
+		$content .= ! empty($href) ? '</a>' : '';
215 215
 		$content .= '</li>';
216 216
 		return $content;
217 217
 	}
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  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 6
 /**
6 7
  * Event Espresso
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 	 * @param array $nav_tabs tab array for nav tabs
99 100
 	 */
100 101
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
101
-		if ( empty($nav_tabs) )
102
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
102
+		if ( empty($nav_tabs) ) {
103
+					throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
104
+		}
103 105
 
104 106
 		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
105 107
 		foreach ( $nav_tabs as $slug => $tab ) {
@@ -165,8 +167,10 @@  discard block
 block discarded – undo
165 167
 	 * @return string                  a html snippet of of all the formatted link elements.
166 168
 	 */
167 169
 	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
168
-		if ( !is_array($item_array) || empty( $item_array ) )
169
-			return false; //get out we don't have even the basic thing we need!
170
+		if ( !is_array($item_array) || empty( $item_array ) ) {
171
+					return false;
172
+		}
173
+		//get out we don't have even the basic thing we need!
170 174
 
171 175
 
172 176
 		$defaults = array(
@@ -184,8 +188,9 @@  discard block
 block discarded – undo
184 188
 			$item = wp_parse_args( $item, $defaults );
185 189
 			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
186 190
 			$list .= self::_text_link_item($item);
187
-			if ( !empty($sep) && $ci != count($item_array) )
188
-				$list .= self::_text_link_item($sep);
191
+			if ( !empty($sep) && $ci != count($item_array) ) {
192
+							$list .= self::_text_link_item($sep);
193
+			}
189 194
 			$ci++;
190 195
 		}
191 196
 
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
 	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
249 249
 	 * @param  array      $template_args an array of arguments to be extracted for use in the template
250 250
 	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
251
-	 * @return mixed string
251
+	 * @return string string
252 252
 	 */
253 253
 	public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) {
254 254
 		//require the template validator for verifying variables are set according to how the template requires
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				return array();
100 100
 			}
101 101
 			if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) {
102
-			    unset( $espresso_themes[ $key ] );
102
+				unset( $espresso_themes[ $key ] );
103 103
 			}
104 104
 			EEH_Template::$_espresso_themes = array();
105 105
 			foreach ( $espresso_themes as $espresso_theme ) {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			foreach ( (array)$full_template_paths as $full_template_path ) {
227 227
 				if ( is_readable( $full_template_path )) {
228 228
 					$template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path );
229
-				    break;
229
+					break;
230 230
 				}
231 231
 			}
232 232
 		}
@@ -648,9 +648,9 @@  discard block
 block discarded – undo
648 648
 		);
649 649
 
650 650
 		if ( empty( $items_label )
651
-		     || ! is_array( $items_label )
652
-		     || ! isset( $items_label['single'] )
653
-		     || ! isset( $items_label['plural'] ) ) {
651
+			 || ! is_array( $items_label )
652
+			 || ! isset( $items_label['single'] )
653
+			 || ! isset( $items_label['plural'] ) ) {
654 654
 			$items_label = array(
655 655
 				'single' => __( '1 item', 'event_espresso' ),
656 656
 				'plural' => __( '%s items', 'event_espresso' )
Please login to merge, or discard this patch.
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-if ( ! function_exists( 'espresso_get_template_part' )) {
18
+if ( ! function_exists('espresso_get_template_part')) {
19 19
 	/**
20 20
 	 * espresso_get_template_part
21 21
 	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 	 * @param string $name The name of the specialised template.
26 26
 	 * @return string        the html output for the formatted money value
27 27
 	 */
28
-	function espresso_get_template_part( $slug = NULL, $name = NULL ) {
29
-		EEH_Template::get_template_part( $slug, $name );
28
+	function espresso_get_template_part($slug = NULL, $name = NULL) {
29
+		EEH_Template::get_template_part($slug, $name);
30 30
 	}
31 31
 }
32 32
 
33 33
 
34 34
 
35
-if ( ! function_exists( 'espresso_get_object_css_class' )) {
35
+if ( ! function_exists('espresso_get_object_css_class')) {
36 36
 	/**
37 37
 	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38 38
 	 *
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param  string $suffix added to the end of the generated class
43 43
 	 * @return string
44 44
 	 */
45
-	function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
46
-		return EEH_Template::get_object_css_class( $object, $prefix, $suffix );
45
+	function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47 47
 	}
48 48
 }
49 49
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * 	@return boolean
71 71
 	 */
72 72
 	public static function is_espresso_theme() {
73
-		return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE;
73
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE;
74 74
 	}
75 75
 
76 76
 	/**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * 	@return void
80 80
 	 */
81 81
 	public static function load_espresso_theme_functions() {
82
-		if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) {
83
-			if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) {
84
-				require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' );
82
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
83
+			if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
84
+				require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
85 85
 			}
86 86
 		}
87 87
 	}
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * 	@return array
94 94
 	 */
95 95
 	public static function get_espresso_themes() {
96
-		if ( empty( EEH_Template::$_espresso_themes )) {
97
-			$espresso_themes =  glob( EE_PUBLIC . '*', GLOB_ONLYDIR );
98
-			if ( empty( $espresso_themes ) ) {
96
+		if (empty(EEH_Template::$_espresso_themes)) {
97
+			$espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
98
+			if (empty($espresso_themes)) {
99 99
 				return array();
100 100
 			}
101
-			if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) {
102
-			    unset( $espresso_themes[ $key ] );
101
+			if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) {
102
+			    unset($espresso_themes[$key]);
103 103
 			}
104 104
 			EEH_Template::$_espresso_themes = array();
105
-			foreach ( $espresso_themes as $espresso_theme ) {
106
-				EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme;
105
+			foreach ($espresso_themes as $espresso_theme) {
106
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
107 107
 			}
108 108
 		}
109 109
 		return EEH_Template::$_espresso_themes;
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 	 * @param bool   $return_string
123 123
 	 * @return string        the html output for the formatted money value
124 124
 	 */
125
-	public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE  ) {
126
-		do_action( "get_template_part_{$slug}-{$name}", $slug, $name );
125
+	public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) {
126
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127 127
 		$templates = array();
128 128
 		$name = (string) $name;
129
-		if ( $name != '' ) {
129
+		if ($name != '') {
130 130
 			$templates[] = "{$slug}-{$name}.php";
131 131
 		}
132 132
 		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-		if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) {
134
-			EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) {
134
+			EEH_Template::locate_template($templates, $template_args, TRUE, $return_string);
135 135
 		}
136 136
 	}
137 137
 
@@ -156,26 +156,26 @@  discard block
 block discarded – undo
156 156
 	 * 				Used in places where you don't actually load the template, you just want to know if there's a custom version of it.
157 157
 	 * @return mixed
158 158
 	 */
159
-	public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) {
159
+	public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) {
160 160
 		// first use WP locate_template to check for template in the current theme folder
161
-		$template_path = locate_template( $templates );
161
+		$template_path = locate_template($templates);
162 162
 
163
-		if ( $check_if_custom && !empty( $template_path ) )
163
+		if ($check_if_custom && ! empty($template_path))
164 164
 			return TRUE;
165 165
 
166 166
 		// not in the theme
167
-		if ( empty( $template_path )) {
167
+		if (empty($template_path)) {
168 168
 			// not even a template to look for ?
169
-			if ( empty( $templates )) {
169
+			if (empty($templates)) {
170 170
 				// get post_type
171
-				$post_type = EE_Registry::instance()->REQ->get( 'post_type' );
171
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
172 172
 				// get array of EE Custom Post Types
173 173
 				$EE_CPTs = EE_Register_CPTs::get_CPTs();
174 174
 				// build template name based on request
175
-				if ( isset( $EE_CPTs[ $post_type ] )) {
176
-					$archive_or_single =  is_archive() ? 'archive' : '';
177
-					$archive_or_single =  is_single() ? 'single' : $archive_or_single;
178
-					$templates = $archive_or_single . '-' . $post_type . '.php';
175
+				if (isset($EE_CPTs[$post_type])) {
176
+					$archive_or_single = is_archive() ? 'archive' : '';
177
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
178
+					$templates = $archive_or_single.'-'.$post_type.'.php';
179 179
 				}
180 180
 			}
181 181
 			// currently active EE template theme
@@ -184,61 +184,61 @@  discard block
 block discarded – undo
184 184
 			// array of paths to folders that may contain templates
185 185
 			$template_folder_paths = array(
186 186
 				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
187
-				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
187
+				EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
188 188
 				// then in the root of the /wp-content/uploads/espresso/templates/ folder
189 189
 				EVENT_ESPRESSO_TEMPLATE_DIR
190 190
 			);
191 191
 
192 192
 			//add core plugin folders for checking only if we're not $check_if_custom
193
-			if ( ! $check_if_custom ) {
193
+			if ( ! $check_if_custom) {
194 194
 				$core_paths = array(
195 195
 					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
196
-					EE_PUBLIC . $current_theme,
196
+					EE_PUBLIC.$current_theme,
197 197
 					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
198
-					EE_TEMPLATES . $current_theme,
198
+					EE_TEMPLATES.$current_theme,
199 199
 					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
200 200
 					EE_PLUGIN_DIR_PATH
201 201
 					);
202
-				$template_folder_paths = array_merge( $template_folder_paths, $core_paths );
202
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
203 203
 			}
204 204
 
205 205
 			// now filter that array
206
-			$template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths );
206
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths);
207 207
 
208 208
 			// array to hold all possible template paths
209 209
 			$full_template_paths = array();
210 210
 
211 211
 			// loop through $templates
212
-			foreach ( (array)$templates as $template ) {
212
+			foreach ((array) $templates as $template) {
213 213
 				// while looping through all template folder paths
214
-				foreach ( (array)$template_folder_paths as $template_folder_path ) {
214
+				foreach ((array) $template_folder_paths as $template_folder_path) {
215 215
 					// build up our template locations array by combining our template folder paths with our templates
216
-					$full_template_paths[] = rtrim( $template_folder_path, DS ) . DS . $template;
216
+					$full_template_paths[] = rtrim($template_folder_path, DS).DS.$template;
217 217
 				}
218 218
 				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
219
-				array_unshift( $full_template_paths, $template );
219
+				array_unshift($full_template_paths, $template);
220 220
 			}
221 221
 			// filter final array of full template paths
222
-			$full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths );
222
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths);
223 223
 
224 224
 
225 225
 			// now loop through our final array of template location paths and check each location
226
-			foreach ( (array)$full_template_paths as $full_template_path ) {
227
-				if ( is_readable( $full_template_path )) {
228
-					$template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path );
226
+			foreach ((array) $full_template_paths as $full_template_path) {
227
+				if (is_readable($full_template_path)) {
228
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
229 229
 				    break;
230 230
 				}
231 231
 			}
232 232
 		}
233 233
 		// if we got it and you want to see it...
234
-		if ( $template_path && $load && ! $check_if_custom  ) {
235
-			if ( $return_string ) {
236
-				return EEH_Template::display_template( $template_path, $template_args, TRUE );
234
+		if ($template_path && $load && ! $check_if_custom) {
235
+			if ($return_string) {
236
+				return EEH_Template::display_template($template_path, $template_args, TRUE);
237 237
 			} else {
238
-				EEH_Template::display_template( $template_path, $template_args, FALSE );
238
+				EEH_Template::display_template($template_path, $template_args, FALSE);
239 239
 			}
240 240
 		}
241
-		return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path;
241
+		return $check_if_custom && ! empty($template_path) ? TRUE : $template_path;
242 242
 	}
243 243
 
244 244
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
251 251
 	 * @return mixed string
252 252
 	 */
253
-	public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) {
253
+	public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) {
254 254
 		//require the template validator for verifying variables are set according to how the template requires
255
-		EE_Registry::instance()->load_helper( 'Template_Validator' );
255
+		EE_Registry::instance()->load_helper('Template_Validator');
256 256
 
257 257
 		/**
258 258
 		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
@@ -263,26 +263,26 @@  discard block
 block discarded – undo
263 263
 		 *
264 264
 		 * @since 4.6.0
265 265
 		 */
266
-		$template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path );
267
-		$template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args );
266
+		$template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
267
+		$template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
268 268
 
269 269
 		// you gimme nuttin - YOU GET NUTTIN !!
270
-		if ( ! $template_path || ! is_readable( $template_path )) {
270
+		if ( ! $template_path || ! is_readable($template_path)) {
271 271
 			return '';
272 272
 		}
273 273
 		// if $template_args are not in an array, then make it so
274
-		if ( ! is_array( $template_args ) && ! is_object( $template_args )) {
275
-			$template_args = array( $template_args );
274
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
275
+			$template_args = array($template_args);
276 276
 		}
277
-		extract( (array) $template_args);
277
+		extract((array) $template_args);
278 278
 
279
-		if ( $return_string ) {
279
+		if ($return_string) {
280 280
 			// because we want to return a string, we are going to capture the output
281 281
 			ob_start();
282
-			include( $template_path );
282
+			include($template_path);
283 283
 			return ob_get_clean();
284 284
 		} else {
285
-			include( $template_path );
285
+			include($template_path);
286 286
 		}
287 287
 		return '';
288 288
 	}
@@ -300,27 +300,27 @@  discard block
 block discarded – undo
300 300
 	 * @param  string $suffix added to the end of the generated class
301 301
 	 * @return string
302 302
 	 */
303
-	public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
303
+	public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
304 304
 		// in the beginning...
305
-		$prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : '';
305
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
306 306
 		// da muddle
307 307
 		$class = '';
308 308
 		// the end
309
-		$suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : '';
309
+		$suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
310 310
 		// is the passed object an EE object ?
311
-		if ( $object instanceof EE_Base_Class ) {
311
+		if ($object instanceof EE_Base_Class) {
312 312
 			// grab the exact type of object
313
-			$obj_class = get_class( $object );
313
+			$obj_class = get_class($object);
314 314
 			// depending on the type of object...
315
-			switch ( $obj_class ) {
315
+			switch ($obj_class) {
316 316
 				// no specifics just yet...
317 317
 				default :
318
-					$class = strtolower( str_replace( '_', '-', $obj_class ));
319
-					$class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : '';
318
+					$class = strtolower(str_replace('_', '-', $obj_class));
319
+					$class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
320 320
 
321 321
 			}
322 322
 		}
323
-		return $prefix . $class . $suffix;
323
+		return $prefix.$class.$suffix;
324 324
 	}
325 325
 
326 326
 
@@ -336,50 +336,50 @@  discard block
 block discarded – undo
336 336
 	 * @param string      $cur_code_span_class
337 337
 	 * @return string        the html output for the formatted money value
338 338
 	 */
339
-	public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) {
339
+	public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') {
340 340
 		// ensure amount was received
341
-		if ( is_null( $amount ) ) {
342
-			$msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' );
343
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
341
+		if (is_null($amount)) {
342
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
343
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
344 344
 			return '';
345 345
 		}
346 346
 		//ensure amount is float
347 347
 		$amount = (float) $amount;
348 348
 		// filter raw amount (allows 0.00 to be changed to "free" for example)
349
-		$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw );
349
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
350 350
 		// still a number or was amount converted to a string like "free" ?
351
-		if ( is_float( $amount_formatted )) {
351
+		if (is_float($amount_formatted)) {
352 352
 			// was a country ISO code passed ? if so generate currency config object for that country
353
-			$mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL;
353
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL;
354 354
 			// verify results
355
-			if ( ! $mny instanceof EE_Currency_Config ) {
355
+			if ( ! $mny instanceof EE_Currency_Config) {
356 356
 				// set default config country currency settings
357 357
 				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
358 358
 			}
359 359
 			// format float
360
-			$amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds );
360
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
361 361
 			// add formatting ?
362
-			if ( ! $return_raw ) {
362
+			if ( ! $return_raw) {
363 363
 				// add currency sign
364
-				if( $mny->sign_b4 ){
365
-					if( $amount >= 0 ){
366
-						$amount_formatted = $mny->sign . $amount_formatted;
367
-					}else{
368
-						$amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted );
364
+				if ($mny->sign_b4) {
365
+					if ($amount >= 0) {
366
+						$amount_formatted = $mny->sign.$amount_formatted;
367
+					} else {
368
+						$amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
369 369
 					}
370 370
 
371
-				}else{
372
-					$amount_formatted =  $amount_formatted . $mny->sign;
371
+				} else {
372
+					$amount_formatted = $amount_formatted.$mny->sign;
373 373
 				}
374 374
 
375 375
 				// add currency code ?
376
-				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
376
+				$amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
377 377
 			}
378 378
 			// filter results
379
-			$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw );
379
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw);
380 380
 		}
381 381
 		// clean up vars
382
-		unset( $mny );
382
+		unset($mny);
383 383
 		// return formatted currency amount
384 384
 		return $amount_formatted;
385 385
 	}
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
 	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
395 395
 	 * @return string             The localized label for the status id.
396 396
 	 */
397
-	public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) {
397
+	public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') {
398 398
 		/** @type EEM_Status $EEM_Status */
399
-		$EEM_Status = EE_Registry::instance()->load_model( 'Status' );
400
-		$status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema );
401
-		return $status[ $status_id ];
399
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
400
+		$status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema);
401
+		return $status[$status_id];
402 402
 	}
403 403
 
404 404
 
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
 	 * @param string  $icon
412 412
 	 * @return string 	the html output for the button
413 413
 	 */
414
-	public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) {
415
-		$label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label;
416
-		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>';
414
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') {
415
+		$label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label;
416
+		$button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>';
417 417
 		return $button;
418 418
 	}
419 419
 
@@ -430,21 +430,21 @@  discard block
 block discarded – undo
430 430
 	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
431 431
 	 * @return string              generated link
432 432
 	 */
433
-	public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) {
433
+	public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) {
434 434
 
435
-		if ( ! $page )
436
-			$page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page;
435
+		if ( ! $page)
436
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
437 437
 
438
-		if ( ! $action )
439
-			$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action;
438
+		if ( ! $action)
439
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
440 440
 
441 441
 		$action = empty($action) ? 'default' : $action;
442 442
 
443 443
 
444
-		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
445
-		$icon = !$icon_style ? ' dashicons-editor-help' : $icon_style;
446
-		$help_text = !$help_text ? '' : $help_text;
447
-		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>';
444
+		$help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
445
+		$icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
446
+		$help_text = ! $help_text ? '' : $help_text;
447
+		return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>';
448 448
 	}
449 449
 
450 450
 
@@ -456,31 +456,31 @@  discard block
 block discarded – undo
456 456
 	 * @param EE_Help_Tour
457 457
 	 * @return string         html
458 458
 	 */
459
-	public static function help_tour_stops_generator( EE_Help_Tour $tour ) {
459
+	public static function help_tour_stops_generator(EE_Help_Tour $tour) {
460 460
 		$id = $tour->get_slug();
461 461
 		$stops = $tour->get_stops();
462 462
 
463
-		$content = '<ol style="display:none" id="' . $id . '">';
463
+		$content = '<ol style="display:none" id="'.$id.'">';
464 464
 
465
-		foreach ( $stops as $stop ) {
466
-			$data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : '';
467
-			$data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : '';
465
+		foreach ($stops as $stop) {
466
+			$data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
467
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
468 468
 
469 469
 			//if container is set to modal then let's make sure we set the options accordingly
470
-			if ( empty( $data_id ) && empty( $data_class ) ) {
470
+			if (empty($data_id) && empty($data_class)) {
471 471
 				$stop['options']['modal'] = true;
472 472
 				$stop['options']['expose'] = true;
473 473
 			}
474 474
 
475
-			$custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : '';
476
-			$button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : '';
475
+			$custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
476
+			$button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
477 477
 			$inner_content = isset($stop['content']) ? $stop['content'] : '';
478 478
 
479 479
 			//options
480
-			if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) {
480
+			if (isset($stop['options']) && is_array($stop['options'])) {
481 481
 				$options = ' data-options="';
482
-				foreach ( $stop['options'] as $option => $value ) {
483
-					$options .= $option . ':' . $value . ';';
482
+				foreach ($stop['options'] as $option => $value) {
483
+					$options .= $option.':'.$value.';';
484 484
 				}
485 485
 				$options .= '"';
486 486
 			} else {
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 			}
489 489
 
490 490
 			//let's put all together
491
-			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
491
+			$content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
492 492
 		}
493 493
 
494 494
 		$content .= '</ol>';
@@ -509,31 +509,31 @@  discard block
 block discarded – undo
509 509
 	 * @throws EE_Error
510 510
 	 * @return string               html structure for status.
511 511
 	 */
512
-	public static function status_legend( $status_array, $active_status = '' ) {
513
-		if ( !is_array( $status_array ) )
514
-			throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') );
512
+	public static function status_legend($status_array, $active_status = '') {
513
+		if ( ! is_array($status_array))
514
+			throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso'));
515 515
 
516 516
 		$setup_array = array();
517
-		foreach ( $status_array as $item => $status ) {
517
+		foreach ($status_array as $item => $status) {
518 518
 			$setup_array[$item] = array(
519
-					'class' => 'ee-status-legend ee-status-legend-' . $status,
520
-					'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ),
519
+					'class' => 'ee-status-legend ee-status-legend-'.$status,
520
+					'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'),
521 521
 					'status' => $status
522 522
 				);
523 523
 		}
524 524
 
525
-		$content = '<div class="ee-list-table-legend-container">' . "\n";
526
-		$content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n";
527
-		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
528
-		foreach ( $setup_array as $item => $details ) {
525
+		$content = '<div class="ee-list-table-legend-container">'."\n";
526
+		$content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n";
527
+		$content .= '<dl class="ee-list-table-legend">'."\n\t";
528
+		foreach ($setup_array as $item => $details) {
529 529
 			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
530
-			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
531
-			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
532
-			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
533
-			$content .= '</dt>' . "\n";
530
+			$content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
531
+			$content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
532
+			$content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
533
+			$content .= '</dt>'."\n";
534 534
 		}
535
-		$content .= '</dl>' . "\n";
536
-		$content .= '</div>' . "\n";
535
+		$content .= '</dl>'."\n";
536
+		$content .= '</div>'."\n";
537 537
 		return $content;
538 538
 	}
539 539
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 * @return string
547 547
 	 */
548 548
 	public static function layout_array_as_table($data) {
549
-	if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) {
550
-		$data = (array)$data;
549
+	if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
550
+		$data = (array) $data;
551 551
 	}
552 552
 	EE_Registry::instance()->load_helper('Array');
553 553
 	ob_start();
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
 						?>
562 562
 						<tr>
563 563
 							<td>
564
-								<?php echo $data_key;?>
564
+								<?php echo $data_key; ?>
565 565
 							</td>
566 566
 							<td>
567
-								<?php echo self::layout_array_as_table($data_values);?>
567
+								<?php echo self::layout_array_as_table($data_values); ?>
568 568
 							</td>
569 569
 						</tr>
570 570
 						<?php
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 			<ul>
579 579
 				<?php
580 580
 				foreach ($data as $datum) {
581
-					echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>";
581
+					echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>";
582 582
 				}?>
583 583
 			</ul>
584 584
 			<?php
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string
610 610
 	 */
611
-	public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
612
-		echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label );
611
+	public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
612
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label);
613 613
 	}
614 614
 
615 615
 
@@ -633,13 +633,13 @@  discard block
 block discarded – undo
633 633
 	 *                                 )
634 634
 	 * @return  string
635 635
 	 */
636
-	public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
636
+	public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
637 637
 		$page_links = array();
638 638
 		$disable_first = $disable_last = '';
639 639
 		$total_items = (int) $total_items;
640 640
 		$per_page = (int) $per_page;
641 641
 		$current = (int) $current;
642
-		$paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name );
642
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
643 643
 
644 644
 		//filter items_label
645 645
 		$items_label = apply_filters(
@@ -647,68 +647,68 @@  discard block
 block discarded – undo
647 647
 			$items_label
648 648
 		);
649 649
 
650
-		if ( empty( $items_label )
651
-		     || ! is_array( $items_label )
652
-		     || ! isset( $items_label['single'] )
653
-		     || ! isset( $items_label['plural'] ) ) {
650
+		if (empty($items_label)
651
+		     || ! is_array($items_label)
652
+		     || ! isset($items_label['single'])
653
+		     || ! isset($items_label['plural'])) {
654 654
 			$items_label = array(
655
-				'single' => __( '1 item', 'event_espresso' ),
656
-				'plural' => __( '%s items', 'event_espresso' )
655
+				'single' => __('1 item', 'event_espresso'),
656
+				'plural' => __('%s items', 'event_espresso')
657 657
 			);
658 658
 		} else {
659 659
 			$items_label = array(
660
-				'single' => '1 ' . esc_html( $items_label['single'] ),
661
-				'plural' => '%s ' . esc_html( $items_label['plural'] )
660
+				'single' => '1 '.esc_html($items_label['single']),
661
+				'plural' => '%s '.esc_html($items_label['plural'])
662 662
 			);
663 663
 		}
664 664
 
665
-		$total_pages = ceil( $total_items / $per_page );
665
+		$total_pages = ceil($total_items / $per_page);
666 666
 
667
-		if ( $total_pages <= 1 )
667
+		if ($total_pages <= 1)
668 668
 			return '';
669 669
 
670
-		$item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single'];
670
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
671 671
 
672
-		$output = '<span class="displaying-num">' . $item_label . '</span>';
672
+		$output = '<span class="displaying-num">'.$item_label.'</span>';
673 673
 
674
-		if ( $current === 1 ) {
674
+		if ($current === 1) {
675 675
 			$disable_first = ' disabled';
676 676
 		}
677
-		if ( $current == $total_pages ) {
677
+		if ($current == $total_pages) {
678 678
 			$disable_last = ' disabled';
679 679
 		}
680 680
 
681
-		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
682
-			'first-page' . $disable_first,
683
-			esc_attr__( 'Go to the first page' ),
684
-			esc_url( remove_query_arg( $paged_arg_name, $url ) ),
681
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
682
+			'first-page'.$disable_first,
683
+			esc_attr__('Go to the first page'),
684
+			esc_url(remove_query_arg($paged_arg_name, $url)),
685 685
 			'&laquo;'
686 686
 		);
687 687
 
688 688
 		$page_links[] = sprintf(
689 689
 			'<a class="%s" title="%s" href="%s">%s</a>',
690
-			'prev-page' . $disable_first,
691
-			esc_attr__( 'Go to the previous page' ),
692
-			esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ),
690
+			'prev-page'.$disable_first,
691
+			esc_attr__('Go to the previous page'),
692
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
693 693
 			'&lsaquo;'
694 694
 		);
695 695
 
696
-		if ( ! $show_num_field ) {
696
+		if ( ! $show_num_field) {
697 697
 			$html_current_page = $current;
698 698
 		} else {
699
-			$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
700
-				esc_attr__( 'Current page' ),
699
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
700
+				esc_attr__('Current page'),
701 701
 				$current,
702
-				strlen( $total_pages )
702
+				strlen($total_pages)
703 703
 			);
704 704
 		}
705 705
 
706 706
 		$html_total_pages = sprintf(
707 707
 			'<span class="total-pages">%s</span>',
708
-			number_format_i18n( $total_pages )
708
+			number_format_i18n($total_pages)
709 709
 		);
710 710
 		$page_links[] = sprintf(
711
-			_x( '%3$s%1$s of %2$s%4$s', 'paging' ),
711
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
712 712
 			$html_current_page,
713 713
 			$html_total_pages,
714 714
 			'<span class="paging-input">',
@@ -717,29 +717,29 @@  discard block
 block discarded – undo
717 717
 
718 718
 		$page_links[] = sprintf(
719 719
 			'<a class="%s" title="%s" href="%s">%s</a>',
720
-			'next-page' . $disable_last,
721
-			esc_attr__( 'Go to the next page' ),
722
-			esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ),
720
+			'next-page'.$disable_last,
721
+			esc_attr__('Go to the next page'),
722
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
723 723
 			'&rsaquo;'
724 724
 		);
725 725
 
726 726
 		$page_links[] = sprintf(
727 727
 			'<a class="%s" title="%s" href="%s">%s</a>',
728
-			'last-page' . $disable_last,
729
-			esc_attr__( 'Go to the last page' ),
730
-			esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ),
728
+			'last-page'.$disable_last,
729
+			esc_attr__('Go to the last page'),
730
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
731 731
 			'&raquo;'
732 732
 		);
733 733
 
734
-		$output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>';
734
+		$output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
735 735
 		// set page class
736
-		if ( $total_pages ) {
736
+		if ($total_pages) {
737 737
 			$page_class = $total_pages < 2 ? ' one-page' : '';
738 738
 		} else {
739 739
 			$page_class = ' no-pages';
740 740
 		}
741 741
 
742
-		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
742
+		return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
743 743
 	}
744 744
 
745 745
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -160,8 +160,9 @@  discard block
 block discarded – undo
160 160
 		// first use WP locate_template to check for template in the current theme folder
161 161
 		$template_path = locate_template( $templates );
162 162
 
163
-		if ( $check_if_custom && !empty( $template_path ) )
164
-			return TRUE;
163
+		if ( $check_if_custom && !empty( $template_path ) ) {
164
+					return TRUE;
165
+		}
165 166
 
166 167
 		// not in the theme
167 168
 		if ( empty( $template_path )) {
@@ -364,11 +365,11 @@  discard block
 block discarded – undo
364 365
 				if( $mny->sign_b4 ){
365 366
 					if( $amount >= 0 ){
366 367
 						$amount_formatted = $mny->sign . $amount_formatted;
367
-					}else{
368
+					} else{
368 369
 						$amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted );
369 370
 					}
370 371
 
371
-				}else{
372
+				} else{
372 373
 					$amount_formatted =  $amount_formatted . $mny->sign;
373 374
 				}
374 375
 
@@ -432,11 +433,13 @@  discard block
 block discarded – undo
432 433
 	 */
433 434
 	public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) {
434 435
 
435
-		if ( ! $page )
436
-			$page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page;
436
+		if ( ! $page ) {
437
+					$page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page;
438
+		}
437 439
 
438
-		if ( ! $action )
439
-			$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action;
440
+		if ( ! $action ) {
441
+					$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action;
442
+		}
440 443
 
441 444
 		$action = empty($action) ? 'default' : $action;
442 445
 
@@ -510,8 +513,9 @@  discard block
 block discarded – undo
510 513
 	 * @return string               html structure for status.
511 514
 	 */
512 515
 	public static function status_legend( $status_array, $active_status = '' ) {
513
-		if ( !is_array( $status_array ) )
514
-			throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') );
516
+		if ( !is_array( $status_array ) ) {
517
+					throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') );
518
+		}
515 519
 
516 520
 		$setup_array = array();
517 521
 		foreach ( $status_array as $item => $status ) {
@@ -572,8 +576,7 @@  discard block
 block discarded – undo
572 576
 				</tbody>
573 577
 			</table>
574 578
 			<?php
575
-		}
576
-		else {
579
+		} else {
577 580
 			?>
578 581
 			<ul>
579 582
 				<?php
@@ -583,8 +586,7 @@  discard block
 block discarded – undo
583 586
 			</ul>
584 587
 			<?php
585 588
 		}
586
-	}
587
-	else {
589
+	} else {
588 590
 		//simple value
589 591
 		echo $data;
590 592
 	}
@@ -664,8 +666,9 @@  discard block
 block discarded – undo
664 666
 
665 667
 		$total_pages = ceil( $total_items / $per_page );
666 668
 
667
-		if ( $total_pages <= 1 )
668
-			return '';
669
+		if ( $total_pages <= 1 ) {
670
+					return '';
671
+		}
669 672
 
670 673
 		$item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single'];
671 674
 
Please login to merge, or discard this patch.
core/helpers/EEH_Template_Validator.helper.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	/**
132 132
 	 * For verifying that a variable is indeed an array, else throw an EE_Error
133 133
 	 * @param type $variable_to_test
134
-	 * @param type $variable_name
134
+	 * @param string $variable_name
135 135
 	 * @param type $allow_empty one of 'allow_empty' or 'do_not_allow_empty'
136 136
 	 * @return void
137 137
 	 * @throws EE_Error
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * for verifying that a variable is one of the string optiosn supplied
160 160
 	 * @param mixed $variable_to_test
161 161
 	 * @param mixed $variable_name the name you've given the variable. Eg, '$foo'. THis helps in producing better error messages
162
-	 * @param array $string_options an array of acceptable values
162
+	 * @param string[] $string_options an array of acceptable values
163 163
 	 * @return void
164 164
 	 * @throws EE_Error
165 165
 	 */
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 * @throws EE_Error (indirectly)
52 52
 	 */
53
-	static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){
54
-		if(!WP_DEBUG)return;
55
-		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
56
-		if('allow_null' == $allow_null && is_null($variable_to_test)){
53
+	static function verify_is_array_of($variable_to_test, $name_of_variable, $class_name, $allow_null = 'allow_null') {
54
+		if ( ! WP_DEBUG)return;
55
+		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null'));
56
+		if ('allow_null' == $allow_null && is_null($variable_to_test)) {
57 57
 			return;
58 58
 		}
59 59
 		self::verify_is_array($variable_to_test, $name_of_variable);
60
-		foreach($variable_to_test as $key=>$array_element){
60
+		foreach ($variable_to_test as $key=>$array_element) {
61 61
 			self::verify_instanceof($array_element, $key, $class_name);
62 62
 		}
63 63
 	}
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 	 * @return void
74 74
 	 * @throws EE_Error
75 75
 	 */
76
-	static function verify_isnt_null($variable_to_test,$name_of_variable){
77
-		if(!WP_DEBUG)return;
78
-		if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){
79
-			$error[]=__('Variable named %s is null.','event_espresso');
80
-			$error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso');
81
-			throw new EE_Error(sprintf(implode(",",$error),$name_of_variable,$name_of_variable));
76
+	static function verify_isnt_null($variable_to_test, $name_of_variable) {
77
+		if ( ! WP_DEBUG)return;
78
+		if ($variable_to_test == null && $variable_to_test != 0 && $variable_to_test != FALSE) {
79
+			$error[] = __('Variable named %s is null.', 'event_espresso');
80
+			$error[] = __("Consider looking at the stack trace to see why it wasn't set.", 'event_espresso');
81
+			throw new EE_Error(sprintf(implode(",", $error), $name_of_variable, $name_of_variable));
82 82
 		}
83 83
 	}
84 84
 	
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
 	 * @return void
91 91
 	 * @throws EE_Error
92 92
 	 */
93
-	static function verify_is_true($expression_to_test,$expression_string_representation){
94
-		if(!WP_DEBUG)return;
95
-		if(!$expression_to_test){
96
-			$error[]=__('Template error.','event_espresso');
97
-			$error[]=__("%s evaluated to false, but it must be true!",'event_espresso');
98
-			throw new EE_Error(sprintf(implode(",",$error),$expression_string_representation));
93
+	static function verify_is_true($expression_to_test, $expression_string_representation) {
94
+		if ( ! WP_DEBUG)return;
95
+		if ( ! $expression_to_test) {
96
+			$error[] = __('Template error.', 'event_espresso');
97
+			$error[] = __("%s evaluated to false, but it must be true!", 'event_espresso');
98
+			throw new EE_Error(sprintf(implode(",", $error), $expression_string_representation));
99 99
 		}
100 100
 	}
101 101
 	
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws EE_Error
113 113
 	 */
114
-	static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){
115
-		if(!WP_DEBUG)return;
116
-		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
117
-		if($allow_null == 'allow_null' && is_null($variable_to_test)){
114
+	static function verify_instanceof($variable_to_test, $name_of_variable, $class_name, $allow_null = 'do_not_allow_null') {
115
+		if ( ! WP_DEBUG)return;
116
+		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null', 'do_not_allow_null'));
117
+		if ($allow_null == 'allow_null' && is_null($variable_to_test)) {
118 118
 			return;
119 119
 		}
120
-		if( $variable_to_test == NULL ||  ! ( $variable_to_test instanceof $class_name )){
121
-			$msg[]=__('Variable %s is not of the correct type.','event_espresso');
122
-			$msg[]=__("It should be of type %s",'event_espresso');
123
-			throw new EE_Error(sprintf(implode(",",$msg),$name_of_variable,$name_of_variable,$class_name));
120
+		if ($variable_to_test == NULL || ! ($variable_to_test instanceof $class_name)) {
121
+			$msg[] = __('Variable %s is not of the correct type.', 'event_espresso');
122
+			$msg[] = __("It should be of type %s", 'event_espresso');
123
+			throw new EE_Error(sprintf(implode(",", $msg), $name_of_variable, $name_of_variable, $class_name));
124 124
 		}
125 125
 	}
126 126
 	
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
 	 * @return void
137 137
 	 * @throws EE_Error
138 138
 	 */
139
-	static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){
140
-		if(!WP_DEBUG)return;
141
-		self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty'));
142
-		if(empty($variable_to_test) && 'allow_empty'==$allow_empty){
139
+	static function verify_is_array($variable_to_test, $variable_name, $allow_empty = 'allow_empty') {
140
+		if ( ! WP_DEBUG)return;
141
+		self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty', 'do_not_allow_empty'));
142
+		if (empty($variable_to_test) && 'allow_empty' == $allow_empty) {
143 143
 			return;
144 144
 		}
145
-		if(!is_array($variable_to_test)){
146
-			$error[]=__('Variable %s should be an array, but it is not.');
147
-			$error[]=__("Its value is, instead '%s'",'event_espresso');
148
-			throw new EE_Error(sprintf(implode(",",$error),$variable_name,$variable_name,$variable_to_test));
145
+		if ( ! is_array($variable_to_test)) {
146
+			$error[] = __('Variable %s should be an array, but it is not.');
147
+			$error[] = __("Its value is, instead '%s'", 'event_espresso');
148
+			throw new EE_Error(sprintf(implode(",", $error), $variable_name, $variable_name, $variable_to_test));
149 149
 		}
150 150
 	}
151 151
 	
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 	 * @return void
164 164
 	 * @throws EE_Error
165 165
 	 */
166
-	static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){
167
-		if(!WP_DEBUG)return;
168
-		if(!in_array($variable_to_test,$string_options)){
169
-			$msg[0]=__('Malconfigured template.','event_espresso');
170
-			$msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso');
171
-			throw new EE_Error(sprintf(implode("||",$msg),$variable_name,$variable_to_test, implode("', '",$string_options)));
166
+	static function verify_argument_is_one_of($variable_to_test, $variable_name, $string_options) {
167
+		if ( ! WP_DEBUG)return;
168
+		if ( ! in_array($variable_to_test, $string_options)) {
169
+			$msg[0] = __('Malconfigured template.', 'event_espresso');
170
+			$msg[1] = __("Variable named '%s' was set to '%s'. It can only be one of '%s'", 'event_espresso');
171
+			throw new EE_Error(sprintf(implode("||", $msg), $variable_name, $variable_to_test, implode("', '", $string_options)));
172 172
 		}
173 173
 	}
174 174
 
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 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
 /**
4 6
  * Event Espresso
@@ -51,7 +53,9 @@  discard block
 block discarded – undo
51 53
 	 * @throws EE_Error (indirectly)
52 54
 	 */
53 55
 	static function verify_is_array_of($variable_to_test,$name_of_variable,$class_name,$allow_null='allow_null'){
54
-		if(!WP_DEBUG)return;
56
+		if(!WP_DEBUG) {
57
+			return;
58
+		}
55 59
 		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
56 60
 		if('allow_null' == $allow_null && is_null($variable_to_test)){
57 61
 			return;
@@ -74,7 +78,9 @@  discard block
 block discarded – undo
74 78
 	 * @throws EE_Error
75 79
 	 */
76 80
 	static function verify_isnt_null($variable_to_test,$name_of_variable){
77
-		if(!WP_DEBUG)return;
81
+		if(!WP_DEBUG) {
82
+			return;
83
+		}
78 84
 		if($variable_to_test==null && $variable_to_test!=0 && $variable_to_test!=FALSE){
79 85
 			$error[]=__('Variable named %s is null.','event_espresso');
80 86
 			$error[]=__("Consider looking at the stack trace to see why it wasn't set.",'event_espresso');
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 	 * @throws EE_Error
92 98
 	 */
93 99
 	static function verify_is_true($expression_to_test,$expression_string_representation){
94
-		if(!WP_DEBUG)return;
100
+		if(!WP_DEBUG) {
101
+			return;
102
+		}
95 103
 		if(!$expression_to_test){
96 104
 			$error[]=__('Template error.','event_espresso');
97 105
 			$error[]=__("%s evaluated to false, but it must be true!",'event_espresso');
@@ -112,7 +120,9 @@  discard block
 block discarded – undo
112 120
 	 * @throws EE_Error
113 121
 	 */
114 122
 	static function verify_instanceof($variable_to_test,$name_of_variable,$class_name, $allow_null = 'do_not_allow_null'){
115
-		if(!WP_DEBUG)return;
123
+		if(!WP_DEBUG) {
124
+			return;
125
+		}
116 126
 		self::verify_argument_is_one_of($allow_null, 'allow_null', array('allow_null','do_not_allow_null'));
117 127
 		if($allow_null == 'allow_null' && is_null($variable_to_test)){
118 128
 			return;
@@ -137,7 +147,9 @@  discard block
 block discarded – undo
137 147
 	 * @throws EE_Error
138 148
 	 */
139 149
 	static function verify_is_array($variable_to_test,$variable_name,$allow_empty='allow_empty'){
140
-		if(!WP_DEBUG)return;
150
+		if(!WP_DEBUG) {
151
+			return;
152
+		}
141 153
 		self::verify_argument_is_one_of($allow_empty, $variable_name, array('allow_empty','do_not_allow_empty'));
142 154
 		if(empty($variable_to_test) && 'allow_empty'==$allow_empty){
143 155
 			return;
@@ -164,7 +176,9 @@  discard block
 block discarded – undo
164 176
 	 * @throws EE_Error
165 177
 	 */
166 178
 	static function verify_argument_is_one_of($variable_to_test,$variable_name,$string_options){
167
-		if(!WP_DEBUG)return;
179
+		if(!WP_DEBUG) {
180
+			return;
181
+		}
168 182
 		if(!in_array($variable_to_test,$string_options)){
169 183
 			$msg[0]=__('Malconfigured template.','event_espresso');
170 184
 			$msg[1]=__("Variable named '%s' was set to '%s'. It can only be one of '%s'",'event_espresso');
Please login to merge, or discard this patch.
core/helpers/EEH_URL.helper.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,6 @@
 block discarded – undo
49 49
 	 * Returns whether not the remote file exists.
50 50
 	 * Checking via GET because HEAD requests are blocked on some server configurations.
51 51
 	 * @param string $url
52
-	 * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly
53 52
 	 * @return boolean
54 53
 	 */
55 54
 	public static function remote_file_exists( $url, $args = array() ){
Please login to merge, or discard this patch.
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   +55 added lines, -55 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
@@ -21,28 +21,28 @@  discard block
 block discarded – undo
21 21
 	 * @param bool  $exclude_nonce  If true then the nonce will be excluded from the generated url.
22 22
 	 * @return string
23 23
 	 */
24
-	public static function add_query_args_and_nonce( $args = array(), $url = '', $exclude_nonce = false ) {
25
-		if ( empty( $url ) ) {
26
-			$user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso' );
27
-			$dev_msg = $user_msg . "\n" . sprintf(
28
-					__('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' ),
24
+	public static function add_query_args_and_nonce($args = array(), $url = '', $exclude_nonce = false) {
25
+		if (empty($url)) {
26
+			$user_msg = __('An error occurred. A URL is a required parameter for the add_query_args_and_nonce method.', 'event_espresso');
27
+			$dev_msg = $user_msg."\n".sprintf(
28
+					__('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'),
29 29
 					__CLASS__
30 30
 				);
31
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
31
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
32 32
 		}
33 33
 		// check that an action exists and add nonce
34
-		if ( ! $exclude_nonce ) {
35
-			if ( isset( $args['action'] ) && ! empty( $args['action'] ) ) {
36
-				$args = array_merge( $args, array( $args['action'] . '_nonce' => wp_create_nonce( $args['action'] . '_nonce' ) ) );
34
+		if ( ! $exclude_nonce) {
35
+			if (isset($args['action']) && ! empty($args['action'])) {
36
+				$args = array_merge($args, array($args['action'].'_nonce' => wp_create_nonce($args['action'].'_nonce')));
37 37
 			} else {
38
-				$args = array_merge( $args, array( 'action' => 'default', 'default_nonce' => wp_create_nonce( 'default_nonce' ) ) );
38
+				$args = array_merge($args, array('action' => 'default', 'default_nonce' => wp_create_nonce('default_nonce')));
39 39
 			}
40 40
 		}
41 41
 
42 42
 		//finally, let's always add a return address (if present) :)
43
-		$args = ! empty( $_REQUEST['action'] ) ? array_merge( $args, array( 'return' => $_REQUEST['action'] ) ) : $args;
43
+		$args = ! empty($_REQUEST['action']) ? array_merge($args, array('return' => $_REQUEST['action'])) : $args;
44 44
 
45
-		return add_query_arg( $args, $url );
45
+		return add_query_arg($args, $url);
46 46
 
47 47
 	}
48 48
 
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
 	 * @param boolean $sslverify whether we care if the SSL certificate for the requested site is setup properly
56 56
 	 * @return boolean
57 57
 	 */
58
-	public static function remote_file_exists( $url, $args = array() ){
59
-		$results = wp_remote_request($url,array_merge( array(
58
+	public static function remote_file_exists($url, $args = array()) {
59
+		$results = wp_remote_request($url, array_merge(array(
60 60
 			'method'=>'GET',
61 61
 			'redirection'=>1
62
-		), $args ) );
63
-		if( ! $results instanceof WP_Error &&
62
+		), $args));
63
+		if ( ! $results instanceof WP_Error &&
64 64
 				isset($results['response']) &&
65 65
 				isset($results['response']['code']) &&
66
-				$results['response']['code'] == '200'){
66
+				$results['response']['code'] == '200') {
67 67
 			return true;
68
-		}else{
68
+		} else {
69 69
 			return false;
70 70
 		}
71 71
 	}
@@ -81,29 +81,29 @@  discard block
 block discarded – undo
81 81
 	 * @param bool   $base_url_only - TRUE will only return the scheme and host with no other parameters
82 82
 	 * @return string
83 83
 	 */
84
-	public static function refactor_url( $url = '', $remove_query = TRUE, $base_url_only = FALSE ) {
84
+	public static function refactor_url($url = '', $remove_query = TRUE, $base_url_only = FALSE) {
85 85
 		// break apart incoming URL
86
-		$url_bits = parse_url( $url );
86
+		$url_bits = parse_url($url);
87 87
 		// HTTP or HTTPS ?
88
-		$scheme = isset( $url_bits[ 'scheme' ] ) ? $url_bits[ 'scheme' ] . '://' : 'http://';
88
+		$scheme = isset($url_bits['scheme']) ? $url_bits['scheme'].'://' : 'http://';
89 89
 		// domain
90
-		$host = isset( $url_bits[ 'host' ] ) ? $url_bits[ 'host' ] : '';
90
+		$host = isset($url_bits['host']) ? $url_bits['host'] : '';
91 91
 		// if only the base URL is requested, then return that now
92
-		if ( $base_url_only ) {
93
-			return $scheme . $host;
92
+		if ($base_url_only) {
93
+			return $scheme.$host;
94 94
 		}
95
-		$port = isset( $url_bits[ 'port' ] ) ? ':' . $url_bits[ 'port' ] : '';
96
-		$user = isset( $url_bits[ 'user' ] ) ? $url_bits[ 'user' ] : '';
97
-		$pass = isset( $url_bits[ 'pass' ] ) ? ':' . $url_bits[ 'pass' ] : '';
98
-		$pass = ( $user || $pass ) ? $pass . '@' : '';
99
-		$path = isset( $url_bits[ 'path' ] ) ? $url_bits[ 'path' ] : '';
95
+		$port = isset($url_bits['port']) ? ':'.$url_bits['port'] : '';
96
+		$user = isset($url_bits['user']) ? $url_bits['user'] : '';
97
+		$pass = isset($url_bits['pass']) ? ':'.$url_bits['pass'] : '';
98
+		$pass = ($user || $pass) ? $pass.'@' : '';
99
+		$path = isset($url_bits['path']) ? $url_bits['path'] : '';
100 100
 		// if the query string is not required, then return what we have so far
101
-		if ( $remove_query ) {
102
-			return $scheme . $user . $pass . $host . $port . $path;
101
+		if ($remove_query) {
102
+			return $scheme.$user.$pass.$host.$port.$path;
103 103
 		}
104
-		$query = isset( $url_bits[ 'query' ] ) ? '?' . $url_bits[ 'query' ] : '';
105
-		$fragment = isset( $url_bits[ 'fragment' ] ) ? '#' . $url_bits[ 'fragment' ] : '';
106
-		return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
104
+		$query = isset($url_bits['query']) ? '?'.$url_bits['query'] : '';
105
+		$fragment = isset($url_bits['fragment']) ? '#'.$url_bits['fragment'] : '';
106
+		return $scheme.$user.$pass.$host.$port.$path.$query.$fragment;
107 107
 	}
108 108
 
109 109
 
@@ -116,29 +116,29 @@  discard block
 block discarded – undo
116 116
 	 * @param bool   $as_array TRUE (default) will return query params as an array of key value pairs, FALSE will simply return the query string
117 117
 	 * @return string|array
118 118
 	 */
119
-	public static function get_query_string( $url = '', $as_array = TRUE ) {
119
+	public static function get_query_string($url = '', $as_array = TRUE) {
120 120
 		// break apart incoming URL
121
-		$url_bits = parse_url( $url );
121
+		$url_bits = parse_url($url);
122 122
 		// grab query string from URL
123
-		$query = isset( $url_bits[ 'query' ] ) ? $url_bits[ 'query' ] : '';
123
+		$query = isset($url_bits['query']) ? $url_bits['query'] : '';
124 124
 		// if we don't want the query string formatted into an array of key => value pairs, then just return it as is
125
-		if ( ! $as_array ) {
125
+		if ( ! $as_array) {
126 126
 			return $query;
127 127
 		}
128 128
 		// if no query string exists then just return an empty array now
129
-		if ( empty( $query )) {
129
+		if (empty($query)) {
130 130
 			return array();
131 131
 		}
132 132
 		// empty array to hold results
133 133
 		$query_params = array();
134 134
 		// now break apart the query string into separate params
135
-		$query = explode( '&', $query );
135
+		$query = explode('&', $query);
136 136
 		// loop thru our query params
137
-		foreach ( $query as $query_args ) {
137
+		foreach ($query as $query_args) {
138 138
 			// break apart the key value pairs
139
-			$query_args = explode( '=', $query_args );
139
+			$query_args = explode('=', $query_args);
140 140
 			// and add to our results array
141
-			$query_params[ $query_args[0] ] = $query_args[1];
141
+			$query_params[$query_args[0]] = $query_args[1];
142 142
 		}
143 143
 		return $query_params;
144 144
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * prevent_prefetching
150 150
 	 * @return void
151 151
 	 */
152
-	public static function prevent_prefetching(){
152
+	public static function prevent_prefetching() {
153 153
 		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
154 154
 		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
155 155
 	}
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	 * @param   string $prefix Use this to prefix the string with something.
165 165
 	 * @return string
166 166
 	 */
167
-	public static function generate_unique_token( $prefix = '' ) {
168
-		$token =  md5( uniqid() . mt_rand() );
169
-		return $prefix ? $prefix . '_' . $token : $token;
167
+	public static function generate_unique_token($prefix = '') {
168
+		$token = md5(uniqid().mt_rand());
169
+		return $prefix ? $prefix.'_'.$token : $token;
170 170
 	}
171 171
 
172 172
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * add_nocache_headers
176 176
 	 * @return void
177 177
 	 */
178
-	public static function add_nocache_headers(){
178
+	public static function add_nocache_headers() {
179 179
 		// add no cache headers
180 180
 //		add_action( 'wp_head' , array( 'EED_Single_Page_Checkout', 'nocache_headers' ), 10 );
181 181
 		// plus a little extra for nginx
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 	 * @param string $server_variable
193 193
 	 * @return string
194 194
 	 */
195
-	public static function filter_input_server_url( $server_variable = 'REQUEST_URI' ){
195
+	public static function filter_input_server_url($server_variable = 'REQUEST_URI') {
196 196
 		$URL = '';
197 197
 		$server_variables = array(
198 198
 			'REQUEST_URI' => 1,
199 199
 			'HTTP_HOST' => 1,
200 200
 			'PHP_SELF' => 1,
201 201
 		);
202
-		$server_variable = strtoupper( $server_variable );
202
+		$server_variable = strtoupper($server_variable);
203 203
 		// whitelist INPUT_SERVER var
204
-		if ( isset( $server_variables[ $server_variable ] ) ) {
205
-			$URL = filter_input( INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE );
206
-			if ( empty( $URL ) ) {
207
-				$URL = esc_url( $_SERVER[ $server_variable ] );
204
+		if (isset($server_variables[$server_variable])) {
205
+			$URL = filter_input(INPUT_SERVER, $server_variable, FILTER_SANITIZE_URL, FILTER_NULL_ON_FAILURE);
206
+			if (empty($URL)) {
207
+				$URL = esc_url($_SERVER[$server_variable]);
208 208
 			}
209 209
 		}
210 210
 		return $URL;
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
 	/**
187 187
 	 * _prep_name_for_html_id
188
-	 * @param $name
188
+	 * @param string $name
189 189
 	 * @return string
190 190
 	 */
191 191
 	private function _prep_name_for_html_id( $name ) {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 
233 233
 	/**
234
-	 * @param mixed $html_class
234
+	 * @param string $html_class
235 235
 	 */
236 236
 	public function set_html_class( $html_class ) {
237 237
 		$this->_html_class = $html_class;
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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
 /**
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
 	 *	@type $name string the name for this form section, if you want to explicitly define it
96 96
 	 * }
97 97
 	 */
98
-	function __construct( $options_array = array() ) {
98
+	function __construct($options_array = array()) {
99 99
 		// used by display strategies
100 100
 		EE_Registry::instance()->load_helper('HTML');
101 101
 		// assign incoming values to properties
102
-		foreach( $options_array as $key => $value ) {
103
-			$key = '_' . $key;
104
-			if ( property_exists( $this, $key ) && empty( $this->$key )) {
102
+		foreach ($options_array as $key => $value) {
103
+			$key = '_'.$key;
104
+			if (property_exists($this, $key) && empty($this->$key)) {
105 105
 				$this->$key = $value;
106 106
 			}
107 107
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @param $parent_form_section
114 114
 	 * @param $name
115 115
 	 */
116
-	protected function _construct_finalize( $parent_form_section, $name ){
116
+	protected function _construct_finalize($parent_form_section, $name) {
117 117
 		$this->_construction_finalized = TRUE;
118 118
 		$this->_parent_section = $parent_form_section;
119 119
 		$this->_name = $name;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	/**
135 135
 	 * @param string $action
136 136
 	 */
137
-	public function set_action( $action ) {
137
+	public function set_action($action) {
138 138
 		$this->_action = $action;
139 139
 	}
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return string
145 145
 	 */
146 146
 	public function method() {
147
-		return ! empty( $this->_method ) ? $this->_method : 'POST';
147
+		return ! empty($this->_method) ? $this->_method : 'POST';
148 148
 	}
149 149
 
150 150
 
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	/**
153 153
 	 * @param string $method
154 154
 	 */
155
-	public function set_method( $method ) {
156
-		switch ( $method ) {
155
+	public function set_method($method) {
156
+		switch ($method) {
157 157
 			case 'get' :
158 158
 			case 'GET' :
159 159
 				$this->_method = 'GET';
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	 * Calculation involves using the name and the parent's html id
172 172
 	 * return void
173 173
 	 */
174
-	protected function _set_default_html_id_if_empty(){
175
-		if( ! $this->_html_id ){
176
-			if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){
177
-				$this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() );
178
-			}else{
179
-				$this->_html_id = $this->_prep_name_for_html_id( $this->name() );
174
+	protected function _set_default_html_id_if_empty() {
175
+		if ( ! $this->_html_id) {
176
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
177
+				$this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name());
178
+			} else {
179
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
180 180
 			}
181 181
 		}
182 182
 	}
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param $name
189 189
 	 * @return string
190 190
 	 */
191
-	private function _prep_name_for_html_id( $name ) {
192
-		return sanitize_key( str_replace( array( '&nbsp;', ' ', '_' ), '-', $name ));
191
+	private function _prep_name_for_html_id($name) {
192
+		return sanitize_key(str_replace(array('&nbsp;', ' ', '_'), '-', $name));
193 193
 	}
194 194
 
195 195
 
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 * @param bool $add_pound_sign
207 207
 	 * @return string
208 208
 	 */
209
-	public function html_id( $add_pound_sign = FALSE ){
210
-		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
209
+	public function html_id($add_pound_sign = FALSE) {
210
+		return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id;
211 211
 	}
212 212
 
213 213
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	/**
216 216
 	 * @return string
217 217
 	 */
218
-	public function html_class(){
218
+	public function html_class() {
219 219
 		return $this->_html_class;
220 220
 	}
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	/**
225 225
 	 * @return string
226 226
 	 */
227
-	public function html_style(){
227
+	public function html_style() {
228 228
 		return $this->_html_style;
229 229
 	}
230 230
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	/**
234 234
 	 * @param mixed $html_class
235 235
 	 */
236
-	public function set_html_class( $html_class ) {
236
+	public function set_html_class($html_class) {
237 237
 		$this->_html_class = $html_class;
238 238
 	}
239 239
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	/**
243 243
 	 * @param mixed $html_id
244 244
 	 */
245
-	public function set_html_id( $html_id ) {
245
+	public function set_html_id($html_id) {
246 246
 		$this->_html_id = $html_id;
247 247
 	}
248 248
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	/**
252 252
 	 * @param mixed $html_style
253 253
 	 */
254
-	public function set_html_style( $html_style ) {
254
+	public function set_html_style($html_style) {
255 255
 		$this->_html_style = $html_style;
256 256
 	}
257 257
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	/**
261 261
 	 * @param string $other_html_attributes
262 262
 	 */
263
-	public function set_other_html_attributes( $other_html_attributes ) {
263
+	public function set_other_html_attributes($other_html_attributes) {
264 264
 		$this->_other_html_attributes = $other_html_attributes;
265 265
 	}
266 266
 
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 	 * @throws EE_Error
281 281
 	 * @return string
282 282
 	 */
283
-	function name(){
284
-		if( ! $this->_construction_finalized ){
285
-			throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) );
283
+	function name() {
284
+		if ( ! $this->_construction_finalized) {
285
+			throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this)));
286 286
 		}
287 287
 		return $this->_name;
288 288
 	}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * Gets the parent section
294 294
 	 * @return EE_Form_Section_Proper
295 295
 	 */
296
-	function parent_section(){
296
+	function parent_section() {
297 297
 		return $this->_parent_section;
298 298
 	}
299 299
 
@@ -306,18 +306,18 @@  discard block
 block discarded – undo
306 306
 	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
307 307
 	 * @return string
308 308
 	 */
309
-	public function form_open( $action = '', $method = '', $other_attributes = '' ) {
310
-		if ( ! empty( $action )) {
311
-			$this->set_action( $action );
309
+	public function form_open($action = '', $method = '', $other_attributes = '') {
310
+		if ( ! empty($action)) {
311
+			$this->set_action($action);
312 312
 		}
313
-		if ( ! empty( $method )) {
314
-			$this->set_method( $method );
313
+		if ( ! empty($method)) {
314
+			$this->set_method($method);
315 315
 		}
316
-		$html = EEH_HTML::nl( 1, 'form' ) . '<form';
317
-		$html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : '';
318
-		$html .= ' action="' . $this->action() . '"';
319
-		$html .= ' method="' . $this->method() . '"';
320
-		$html .= $other_attributes . '>';
316
+		$html = EEH_HTML::nl(1, 'form').'<form';
317
+		$html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : '';
318
+		$html .= ' action="'.$this->action().'"';
319
+		$html .= ' method="'.$this->method().'"';
320
+		$html .= $other_attributes.'>';
321 321
 		return $html;
322 322
 	}
323 323
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @return string
329 329
 	 */
330 330
 	public function form_close() {
331
-		return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl();
331
+		return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl();
332 332
 	}
333 333
 
334 334
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 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
@@ -69,7 +70,7 @@  discard block
 block discarded – undo
69 70
 				$default_address .=  $state ? $state->name() . '<br />' : '';
70 71
 				$default_address .= $country ? $country->name(). '<br />' : '';
71 72
 				$default_address .= $organization->zip != '' ? $organization->get_pretty( 'zip' ) : '';
72
-			}else{
73
+			} else{
73 74
 				$default_address = 'unknown';
74 75
 				$organization_name = 'unknown';
75 76
 			}
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Model_Form_Section.form.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -348,6 +348,7 @@
 block discarded – undo
348 348
 	 * Automatically finds the related model info from the form, if present, and
349 349
 	 * save the relations indicated
350 350
 	 * @type string $relation_name
351
+	 * @param integer $relation_name
351 352
 	 * @return bool
352 353
 	 * @throws EE_Error
353 354
 	 */
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- *
4
- * Class EE_Model_Form_Section
5
- *
6
- * For auto-generating form sections based off a model.
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage 	/core/libraries/form_sections/
10
- * @author 				Michael Nelson
11
- * @since                4.5.0
12
- *
13
- */
3
+	 *
4
+	 * Class EE_Model_Form_Section
5
+	 *
6
+	 * For auto-generating form sections based off a model.
7
+	 *
8
+	 * @package 			Event Espresso
9
+	 * @subpackage 	/core/libraries/form_sections/
10
+	 * @author 				Michael Nelson
11
+	 * @since                4.5.0
12
+	 *
13
+	 */
14 14
 class EE_Model_Form_Section extends EE_Form_Section_Proper{
15 15
 
16 16
 	/**
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @since                4.5.0
12 12
  *
13 13
  */
14
-class EE_Model_Form_Section extends EE_Form_Section_Proper{
14
+class EE_Model_Form_Section extends EE_Form_Section_Proper {
15 15
 
16 16
 	/**
17 17
 	 *
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
 	 * }
37 37
 	 * @throws EE_Error
38 38
 	 */
39
-	public function __construct($options_array = array()){
40
-		if(isset($options_array['model']) && $options_array['model'] instanceof EEM_Base){
39
+	public function __construct($options_array = array()) {
40
+		if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) {
41 41
 			$this->_model = $options_array['model'];
42 42
 		}
43
-		if( ! $this->_model || ! $this->_model instanceof EEM_Base ){
43
+		if ( ! $this->_model || ! $this->_model instanceof EEM_Base) {
44 44
 			throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso")));
45 45
 		}
46 46
 
47
-		if(isset($options_array['subsection_args'])){
47
+		if (isset($options_array['subsection_args'])) {
48 48
 			$subsection_args = $options_array['subsection_args'];
49
-		}else{
49
+		} else {
50 50
 			$subsection_args = array();
51 51
 		}
52 52
 
53 53
 		//gather fields and relations to convert to inputs
54 54
 		//but if they're just going to exclude a field anyways, don't bother converting it to an input
55 55
 		$exclude = $this->_subsections;
56
-		if(isset($options_array['exclude'])){
57
-			$exclude = array_merge($exclude,array_flip($options_array['exclude']));
56
+		if (isset($options_array['exclude'])) {
57
+			$exclude = array_merge($exclude, array_flip($options_array['exclude']));
58 58
 		}
59 59
 		$model_fields = array_diff_key($this->_model->field_settings(), $exclude);
60 60
 		$model_relations = array_diff_key($this->_model->relation_settings(), $exclude);
61 61
 		//convert fields and relations to inputs
62 62
 		$this->_subsections = array_merge(
63 63
 			$this->_convert_model_fields_to_inputs($model_fields),
64
-			$this->_convert_model_relations_to_inputs($model_relations,$subsection_args),
64
+			$this->_convert_model_relations_to_inputs($model_relations, $subsection_args),
65 65
 			$this->_subsections
66 66
 		);
67 67
 		parent::__construct($options_array);
68
-		if(isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class){
68
+		if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) {
69 69
 			$this->populate_model_obj($options_array['model_object']);
70 70
 		}
71 71
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * 	}
84 84
 	 * @return array
85 85
 	 */
86
-	protected function _convert_model_relations_to_inputs($relations,$subsection_args = array()){
86
+	protected function _convert_model_relations_to_inputs($relations, $subsection_args = array()) {
87 87
 		$inputs = array();
88
-		foreach( $relations as $relation_name => $relation_obj ) {
88
+		foreach ($relations as $relation_name => $relation_obj) {
89 89
 			$input_constructor_args = array(
90 90
 				array_merge(
91 91
 					array(
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 				)
97 97
 			);
98 98
 			$input = NULL;
99
-			switch(get_class($relation_obj)){
99
+			switch (get_class($relation_obj)) {
100 100
 				case 'EE_HABTM_Relation':
101
-					if(isset($subsection_args[$relation_name]) &&
102
-							isset($subsection_args[$relation_name]['model_objects'])){
101
+					if (isset($subsection_args[$relation_name]) &&
102
+							isset($subsection_args[$relation_name]['model_objects'])) {
103 103
 						$model_objects = $subsection_args[$relation_name]['model_objects'];
104
-					}else{
104
+					} else {
105 105
 						$model_objects = $relation_obj->get_other_model()->get_all();
106 106
 					}
107
-					$input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args);
107
+					$input = new EE_Select_Multi_Model_Input($model_objects, $input_constructor_args);
108 108
 					break;
109 109
 				default:
110 110
 			}
111
-			if($input){
111
+			if ($input) {
112 112
 				$inputs[$relation_name] = $input;
113 113
 			}
114 114
 		}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	 * @throws EE_Error
124 124
 	 * @return EE_Form_Input_Base[]
125 125
 	 */
126
-	protected function _convert_model_fields_to_inputs( $model_fields = array() ){
126
+	protected function _convert_model_fields_to_inputs($model_fields = array()) {
127 127
 		$inputs = array();
128
-		foreach( $model_fields as $field_name=>$model_field ){
129
-			if ( $model_field instanceof EE_Model_Field_Base ) {
128
+		foreach ($model_fields as $field_name=>$model_field) {
129
+			if ($model_field instanceof EE_Model_Field_Base) {
130 130
 				$input_constructor_args = array(
131 131
 					array(
132 132
 						'required'=> ! $model_field->is_nullable() && $model_field->get_default_value() === NULL,
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 						'default'=>$model_field->get_default_value(),
135 135
 					)
136 136
 				);
137
-				switch(get_class($model_field)){
137
+				switch (get_class($model_field)) {
138 138
 					case 'EE_All_Caps_Text_Field':
139 139
 					case 'EE_Any_Foreign_Model_Name_Field':
140 140
 						$input_class = 'EE_Text_Input';
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 						$input_class = 'EE_Yes_No_Input';
144 144
 						break;
145 145
 					case 'EE_Datetime_Field':
146
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
146
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
147 147
 						break;
148 148
 					case 'EE_Email_Field':
149 149
 						$input_class = 'EE_Email_Input';
150 150
 						break;
151 151
 					case 'EE_Enum_Integer_Field':
152
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
152
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
153 153
 						break;
154 154
 					case 'EE_Enum_Text_Field':
155
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
155
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
156 156
 						break;
157 157
 					case 'EE_Float_Field':
158 158
 						$input_class = 'EE_Float_Input';
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 					case 'EE_Foreign_Key_String_Field':
162 162
 					case 'EE_WP_User_Field':
163 163
 						$models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array();
164
-						if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){
164
+						if (true || is_array($models_pointed_to) && count($models_pointed_to) > 1) {
165 165
 							$input_class = 'EE_Text_Input';
166
-						}else{
166
+						} else {
167 167
 							//so its just one model
168 168
 							$model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to;
169 169
 							$model = EE_Registry::instance()->load_model($model_name);
170 170
 							$model_names = $model->get_all_names(array('limit'=>10));
171
-							if($model_field->is_nullable()){
172
-								array_unshift( $model_names, __( "Please Select", 'event_espresso' ));
171
+							if ($model_field->is_nullable()) {
172
+								array_unshift($model_names, __("Please Select", 'event_espresso'));
173 173
 							}
174 174
 							$input_constructor_args[1] = $input_constructor_args[0];
175 175
 							$input_constructor_args[0] = $model_names;
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 						break;
179 179
 					case 'EE_Full_HTML_Field':
180 180
 						$input_class = 'EE_Text_Area_Input';
181
-						$input_constructor_args[ 0 ]['validation_strategies'] = array( new EE_Full_HTML_Validation_Strategy() );
181
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy());
182 182
 						break;
183 183
 					case 'EE_Infinite_Integer':
184
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
184
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
185 185
 						break;
186 186
 					case 'EE_Integer_Field':
187 187
 						$input_class = 'EE_Text_Input';
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 						$input_class = 'EE_Text_Area_Input';
191 191
 						break;
192 192
 					case 'EE_Money_Field':
193
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
193
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
194 194
 						break;
195 195
 					case 'EE_Post_Content_Field':
196 196
 						$input_class = 'EE_Text_Area_Input';
197
-						$input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Full_HTML_Validation_Strategy() );
197
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Full_HTML_Validation_Strategy());
198 198
 						break;
199 199
 					case 'EE_Plain_Text_Field':
200 200
 						$input_class = 'EE_Text_Input';
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 						break;
212 212
 					case 'EE_Simple_HTML_Field':
213 213
 						$input_class = 'EE_Text_Area_Input';
214
-						$input_constructor_args[ 0 ][ 'validation_strategies' ] = array( new EE_Simple_HTML_Validation_Strategy() );
214
+						$input_constructor_args[0]['validation_strategies'] = array(new EE_Simple_HTML_Validation_Strategy());
215 215
 						break;
216 216
 					case 'EE_Slug_Field':
217 217
 						$input_class = 'EE_Text_Input';
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 						$input_class = 'EE_Yes_No_Input';
221 221
 						break;
222 222
 					case 'EE_WP_Post_Status_Field':
223
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
223
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
224 224
 						break;
225 225
 					case 'EE_WP_Post_Type_Field':
226
-						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"),get_class($model_field)));
226
+						throw new EE_Error(sprintf(__("Model field '%s' does not yet have a known conversion to form input", "event_espresso"), get_class($model_field)));
227 227
 						break;
228 228
 					default:
229
-						throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"),get_class($model_field)));
229
+						throw new EE_Error(sprintf(__("Model field of type '%s' does not convert to any known Form Input. Please add a case to EE_Model_Form_section's _convert_model_fields_to_inputs switch statement", "event_espresso"), get_class($model_field)));
230 230
 				}
231 231
 				$reflection = new ReflectionClass($input_class);
232 232
 				$input = $reflection->newInstanceArgs($input_constructor_args);
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
 	 * @param EE_Base_Class $model_obj
245 245
 	 * @return void
246 246
 	 */
247
-	public function populate_model_obj($model_obj){
247
+	public function populate_model_obj($model_obj) {
248 248
 		$model_obj = $this->_model->ensure_is_obj($model_obj);
249 249
 		$this->_model_object = $model_obj;
250 250
 		$defaults = $model_obj->model_field_array();
251
-		foreach($this->_model->relation_settings() as $relation_name => $relation_obj){
251
+		foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) {
252 252
 			$form_inputs = $this->inputs();
253
-			if(isset($form_inputs[$relation_name])){
254
-				if($relation_obj instanceof EE_Belongs_To_Relation){
253
+			if (isset($form_inputs[$relation_name])) {
254
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
255 255
 					//then we only expect there to be one
256 256
 					$related_item = $this->_model_object->get_first_related($relation_name);
257 257
 					$defaults[$relation_name] = $related_item->ID();
258
-				}else{
258
+				} else {
259 259
 					$related_items = $this->_model_object->get_many_related($relation_name);
260 260
 					$ids = array();
261
-					foreach($related_items as $related_item){
261
+					foreach ($related_items as $related_item) {
262 262
 						$ids[] = $related_item->ID();
263 263
 					}
264 264
 					$defaults[$relation_name] = $ids;
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
 	 * values are their normalized values
276 276
 	 * @return array
277 277
 	 */
278
-	public function inputs_values_corresponding_to_model_fields(){
279
-		return array_intersect_key($this->input_values(),$this->_model->field_settings());
278
+	public function inputs_values_corresponding_to_model_fields() {
279
+		return array_intersect_key($this->input_values(), $this->_model->field_settings());
280 280
 	}
281 281
 
282 282
 
@@ -299,21 +299,21 @@  discard block
 block discarded – undo
299 299
 	public function receive_form_submission($req_data = NULL, $validate = TRUE) {
300 300
 		parent::receive_form_submission($req_data, $validate);
301 301
 		//create or set the model object, if it isn't already
302
-		if( ! $this->_model_object ){
302
+		if ( ! $this->_model_object) {
303 303
 			//check to see if the form indicates a PK, in which case we want to only retrieve it and update it
304 304
 			$pk_name = $this->_model->primary_key_name();
305 305
 			$model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name));
306
-			if($model_obj){
306
+			if ($model_obj) {
307 307
 				$this->_model_object = $model_obj;
308
-			}else{
309
-				$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() );
308
+			} else {
309
+				$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name());
310 310
 			}
311 311
 		}
312 312
 		//ok so the model object is set. Just set it with the submitted form data (don't save yet though)
313
-		foreach($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value){
313
+		foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name=>$field_value) {
314 314
 			//only set the non-primary key
315
-			if($field_name != $this->_model->primary_key_name()){
316
-				$this->_model_object->set($field_name,$field_value);
315
+			if ($field_name != $this->_model->primary_key_name()) {
316
+				$this->_model_object->set($field_name, $field_value);
317 317
 			}
318 318
 		}
319 319
 
@@ -329,13 +329,13 @@  discard block
 block discarded – undo
329 329
 	 * @return int, 1 on a successful update, the ID of
330 330
 	 *                    the new entry on insert; 0 on failure
331 331
 	 */
332
-	public function save(){
333
-		if( ! $this->_model_object){
334
-			throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"),get_class($this->_model)));
332
+	public function save() {
333
+		if ( ! $this->_model_object) {
334
+			throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model)));
335 335
 		}
336
-		$success =  $this->_model_object->save();
337
-		foreach($this->_model->relation_settings() as $relation_name => $relation_obj){
338
-			if(isset($this->_subsections[$relation_name])){
336
+		$success = $this->_model_object->save();
337
+		foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) {
338
+			if (isset($this->_subsections[$relation_name])) {
339 339
 				$success = $this->_save_related_info($relation_name);
340 340
 			}
341 341
 		}
@@ -351,29 +351,29 @@  discard block
 block discarded – undo
351 351
 	 * @return bool
352 352
 	 * @throws EE_Error
353 353
 	 */
354
-	protected function _save_related_info($relation_name){
354
+	protected function _save_related_info($relation_name) {
355 355
 		$relation_obj = $this->_model->related_settings_for($relation_name);
356
-		if($relation_obj instanceof EE_Belongs_To_Relation){
356
+		if ($relation_obj instanceof EE_Belongs_To_Relation) {
357 357
 			//there is just a foreign key on this model pointing to that one
358 358
 			$this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name);
359
-		}elseif($relation_obj instanceof EE_Has_Many_Relation){
359
+		}elseif ($relation_obj instanceof EE_Has_Many_Relation) {
360 360
 			//then we want to consider all of its currently-related things.
361 361
 			//if they're in this list, keep them
362 362
 			//if they're not in this list, remove them
363 363
 			//and lastly add all the new items
364 364
 			throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso")));
365
-		}elseif($relation_obj instanceof EE_HABTM_Relation){
365
+		}elseif ($relation_obj instanceof EE_HABTM_Relation) {
366 366
 			//delete everything NOT in this list
367 367
 			$normalized_input_value = $this->get_input_value($relation_name);
368
-			if($normalized_input_value && is_array($normalized_input_value)){
368
+			if ($normalized_input_value && is_array($normalized_input_value)) {
369 369
 				$where_query_params = array(
370
-					$relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value));
371
-			}else{
370
+					$relation_obj->get_other_model()->primary_key_name() => array('NOT_IN', $normalized_input_value));
371
+			} else {
372 372
 				$where_query_params = array();
373 373
 			}
374
-			$this->_model_object->_remove_relations( $relation_name, $where_query_params );
375
-			foreach($normalized_input_value as $id){
376
-				$this->_model_object->_add_relation_to( $id, $relation_name );
374
+			$this->_model_object->_remove_relations($relation_name, $where_query_params);
375
+			foreach ($normalized_input_value as $id) {
376
+				$this->_model_object->_add_relation_to($id, $relation_name);
377 377
 			}
378 378
 		}
379 379
 		return TRUE;
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * Gets the model of this model form
386 386
 	 * @return EEM_Base
387 387
 	 */
388
-	public function get_model(){
388
+	public function get_model() {
389 389
 		return $this->_model;
390 390
 	}
391 391
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * when receive_form_submission($req_data) was called.
399 399
 	 * @return EE_Base_Class
400 400
 	 */
401
-	public function get_model_object(){
401
+	public function get_model_object() {
402 402
 		return $this->_model_object;
403 403
 	}
404 404
 
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
 	 * gets teh default name of this form section if none is specified
409 409
 	 * @return string
410 410
 	 */
411
-	protected function _set_default_name_if_empty(){
412
-		if( ! $this->_name ){
413
-			$default_name = str_replace("EEM_", "", get_class($this->_model)) . "_Model_Form";
414
-			$this->_name =  $default_name;
411
+	protected function _set_default_name_if_empty() {
412
+		if ( ! $this->_name) {
413
+			$default_name = str_replace("EEM_", "", get_class($this->_model))."_Model_Form";
414
+			$this->_name = $default_name;
415 415
 		}
416 416
 	}
417 417
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 		if(isset($options_array['subsection_args'])){
48 48
 			$subsection_args = $options_array['subsection_args'];
49
-		}else{
49
+		} else{
50 50
 			$subsection_args = array();
51 51
 		}
52 52
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 					if(isset($subsection_args[$relation_name]) &&
102 102
 							isset($subsection_args[$relation_name]['model_objects'])){
103 103
 						$model_objects = $subsection_args[$relation_name]['model_objects'];
104
-					}else{
104
+					} else{
105 105
 						$model_objects = $relation_obj->get_other_model()->get_all();
106 106
 					}
107 107
 					$input = new EE_Select_Multi_Model_Input($model_objects,$input_constructor_args);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 						$models_pointed_to = $model_field instanceof EE_Field_With_Model_Name ? $model_field->get_model_class_names_pointed_to() : array();
164 164
 						if(true || is_array($models_pointed_to) && count($models_pointed_to) > 1){
165 165
 							$input_class = 'EE_Text_Input';
166
-						}else{
166
+						} else{
167 167
 							//so its just one model
168 168
 							$model_name = is_array($models_pointed_to) ? reset($models_pointed_to) : $models_pointed_to;
169 169
 							$model = EE_Registry::instance()->load_model($model_name);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 					//then we only expect there to be one
256 256
 					$related_item = $this->_model_object->get_first_related($relation_name);
257 257
 					$defaults[$relation_name] = $related_item->ID();
258
-				}else{
258
+				} else{
259 259
 					$related_items = $this->_model_object->get_many_related($relation_name);
260 260
 					$ids = array();
261 261
 					foreach($related_items as $related_item){
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			$model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name));
306 306
 			if($model_obj){
307 307
 				$this->_model_object = $model_obj;
308
-			}else{
308
+			} else{
309 309
 				$this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name() );
310 310
 			}
311 311
 		}
@@ -356,19 +356,19 @@  discard block
 block discarded – undo
356 356
 		if($relation_obj instanceof EE_Belongs_To_Relation){
357 357
 			//there is just a foreign key on this model pointing to that one
358 358
 			$this->_model_object->_add_relation_to($this->get_input_value($relation_name), $relation_name);
359
-		}elseif($relation_obj instanceof EE_Has_Many_Relation){
359
+		} elseif($relation_obj instanceof EE_Has_Many_Relation){
360 360
 			//then we want to consider all of its currently-related things.
361 361
 			//if they're in this list, keep them
362 362
 			//if they're not in this list, remove them
363 363
 			//and lastly add all the new items
364 364
 			throw new EE_Error(sprintf(__('Automatic saving of related info across a "has many" relation is not yet supported', "event_espresso")));
365
-		}elseif($relation_obj instanceof EE_HABTM_Relation){
365
+		} elseif($relation_obj instanceof EE_HABTM_Relation){
366 366
 			//delete everything NOT in this list
367 367
 			$normalized_input_value = $this->get_input_value($relation_name);
368 368
 			if($normalized_input_value && is_array($normalized_input_value)){
369 369
 				$where_query_params = array(
370 370
 					$relation_obj->get_other_model()->primary_key_name() => array('NOT_IN',$normalized_input_value));
371
-			}else{
371
+			} else{
372 372
 				$where_query_params = array();
373 373
 			}
374 374
 			$this->_model_object->_remove_relations( $relation_name, $where_query_params );
Please login to merge, or discard this patch.