Completed
Branch BUG-8372-txn-meta-box-errors (d9e527)
by
unknown
33:55 queued 16:24
created
core/db_models/fields/EE_Money_Field.php 2 patches
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   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Text_Fields is a base class for any fields which are have float value. (Exception: foreign and private key fields. Wish PHP had multiple-inheritance for this...)
4 4
  */
5
-class EE_Money_Field extends EE_Float_Field{
6
-	function get_wpdb_data_type(){
5
+class EE_Money_Field extends EE_Float_Field {
6
+	function get_wpdb_data_type() {
7 7
 		return '%f';
8 8
 	}
9 9
 	/**
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
 	 * @param type $schema
16 16
 	 * @return string
17 17
 	 */
18
-	function prepare_for_pretty_echoing($value_on_field_to_be_outputted,$schema = null){
18
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
19 19
 		$pretty_float = parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted);
20 20
 
21
-		if($schema == 'localized_float'){
21
+		if ($schema == 'localized_float') {
22 22
 			return $pretty_float;
23 23
 		}
24
-		if($schema == 'no_currency_code'){
24
+		if ($schema == 'no_currency_code') {
25 25
 //			echo "schema no currency!";
26 26
 			$display_code = false;
27
-		}else{
27
+		} else {
28 28
 			$display_code = true;
29 29
 		}
30 30
 		//we don't use the $pretty_float because format_currency will take care of it.
31
-		return EEH_Template::format_currency( $value_on_field_to_be_outputted, false, $display_code );
31
+		return EEH_Template::format_currency($value_on_field_to_be_outputted, false, $display_code);
32 32
 	}
33 33
 
34 34
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		//now it's a float-style string or number
48 48
 		$float_val = parent::prepare_for_set($value_inputted_for_field_on_model_object);
49 49
 		//round to the correctly number of decimal places for this  currency
50
-		$rounded_value = round($float_val,  EE_Registry::instance()->CFG->currency->dec_plc);
50
+		$rounded_value = round($float_val, EE_Registry::instance()->CFG->currency->dec_plc);
51 51
 		return $rounded_value;
52 52
 	}
53 53
 
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Relation.php 2 patches
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   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
2
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
3 3
 /**
4 4
  * Class EE_Belongs_To_Relation
5 5
  *
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 		//create the sql string like
37 37
 		$this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
38 38
 		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
39
-		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()) . $this_table_fk_field->get_table_alias();
40
-		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()) . $other_table_pk_field->get_table_alias();
39
+		$this_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model()->get_this_model_name()).$this_table_fk_field->get_table_alias();
40
+		$other_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_other_model()->get_this_model_name()).$other_table_pk_field->get_table_alias();
41 41
 		$other_table = $this->get_other_model()->get_table_for_alias($other_table_alias);
42
-		return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
42
+		return $this->_left_join($other_table, $other_table_alias, $other_table_pk_field->get_table_column(), $this_table_alias, $this_table_fk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
43 43
 	}
44 44
 
45 45
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
54 54
 		//find the field on the other model which is a foreign key to this model
55 55
 		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
56
-		if ( $this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()){
56
+		if ($this_model_obj->get($fk_on_this_model->get_name()) != $other_model_obj->ID()) {
57 57
 			//set that field on the other model to this model's ID
58 58
 			$this_model_obj->set($fk_on_this_model->get_name(), $other_model_obj->ID());
59 59
 			$this_model_obj->save();
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function remove_relation_to($this_obj_or_id, $other_obj_or_id) {
71 71
 		$this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
72
-		$other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id );
72
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
73 73
 		//find the field on the other model which is a foreign key to this model
74 74
 		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
75 75
 		//set that field on the other model to this model's ID
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	 * @return EE_Base_Class[]
87 87
 	 */
88 88
 	public function get_all_related($model_obj_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) {
89
-		if( $values_already_prepared_by_model_object !== false ) {
90
-			EE_Error::doing_it_wrong( 'EE_Model_Relation_Base::get_all_related', __( 'The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso' ), '4.8.1' );
89
+		if ($values_already_prepared_by_model_object !== false) {
90
+			EE_Error::doing_it_wrong('EE_Model_Relation_Base::get_all_related', __('The argument $values_already_prepared_by_model_object is no longer used.', 'event_espresso'), '4.8.1');
91 91
 		}
92 92
 		//get column on this model object which is a foreign key to the other model
93 93
 		$fk_field_obj = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
94 94
 		//get its value
95
-		if( $model_obj_or_id instanceof EE_Base_Class){
95
+		if ($model_obj_or_id instanceof EE_Base_Class) {
96 96
 			$model_obj = $model_obj_or_id;
97
-		}else{
97
+		} else {
98 98
 			$model_obj = $this->get_this_model()->ensure_is_obj($model_obj_or_id);
99 99
 		}
100 100
 		$ID_value_on_other_model = $model_obj->get($fk_field_obj->get_name());
Please login to merge, or discard this patch.
core/db_models/strategies/EE_Soft_Delete_Where_Conditions.strategy.php 2 patches
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   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  *
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @author				Mike Nelson
14 14
  * @since		 	   4.6.0
15 15
  */
16
-class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{
16
+class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions {
17 17
 	/**
18 18
 	 * Strategy for setting default soft delete where conditions. This strategy will find
19 19
 	 * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 	 * Eg,
23 23
 	 *
24 24
 	 */
25
-	function __construct(){}
25
+	function __construct() {}
26 26
 	/**
27 27
 	 * Gets the where default where conditions for a custom post type model
28 28
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
29 29
 	 */
30
-	protected function _get_default_where_conditions(){
30
+	protected function _get_default_where_conditions() {
31 31
 		$trashed_field_name = $this->deleted_field_name();
32 32
 		return array(
33 33
 			$trashed_field_name => false
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	 * @return string
40 40
 	 * @throws EE_Error
41 41
 	 */
42
-	private function deleted_field_name(){
42
+	private function deleted_field_name() {
43 43
 		$field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field');
44
-		if($field){
44
+		if ($field) {
45 45
 			return $field->get_name();
46
-		}else{
47
-			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
46
+		} else {
47
+			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
48 48
 		}
49 49
 	}
50 50
 }
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
core/helpers/EEH_Class_Tools.helper.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function get_called_class() {
37 37
 		$backtrace = debug_backtrace();
38
-		if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) {
38
+		if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) {
39 39
 			return $backtrace[2]['class'];
40
-		} else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) {
40
+		} else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) {
41 41
 			return $backtrace[3]['class'];
42
-		} else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) {
43
-			if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) {
42
+		} else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) {
43
+			if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) {
44 44
 				self::$i++;
45 45
 			} else {
46 46
 				self::$i = 0;
47
-				self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line'];
47
+				self::$file_line = $backtrace[2]['file'].$backtrace[2]['line'];
48 48
 			}
49 49
 			// was  class method called via call_user_func ?
50
-			if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){
51
-				if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) {
50
+			if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) {
51
+				if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) {
52 52
 					$called_class = $backtrace[2]['args'][0][0];
53 53
 					// is it an EE function ?
54
-					if ( strpos( $called_class, 'EE' ) === 0 ) {
55
-						$prefix_chars = strpos( $called_class, '_' ) + 1;
56
-						$prefix = substr( $called_class, 0, $prefix_chars );
57
-						$classname = substr( $called_class, $prefix_chars, strlen( $called_class ));
58
-						$classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname  ))));
54
+					if (strpos($called_class, 'EE') === 0) {
55
+						$prefix_chars = strpos($called_class, '_') + 1;
56
+						$prefix = substr($called_class, 0, $prefix_chars);
57
+						$classname = substr($called_class, $prefix_chars, strlen($called_class));
58
+						$classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname))));
59 59
 						return $classname;
60 60
 					}
61 61
 				}
62 62
 			} else {
63
-				$lines = file( $backtrace[2]['file'] );
64
-				preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches );
65
-				if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) {
66
-					return $matches[1][ self::$i ];
63
+				$lines = file($backtrace[2]['file']);
64
+				preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches);
65
+				if (isset($matches[1]) && isset($matches[1][self::$i])) {
66
+					return $matches[1][self::$i];
67 67
 				}
68 68
 			}
69 69
 		}
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
 	 * 	@param 	string 	$hook
81 81
 	 * 	@return 	array
82 82
 	 */
83
-	public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) {
83
+	public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) {
84 84
 		global $wp_filter;
85 85
 		$class_names = array();
86 86
 		// are any callbacks registered for this hook ?
87
-		if ( isset( $wp_filter[ $hook ] )) {
87
+		if (isset($wp_filter[$hook])) {
88 88
 			// loop thru all of the callbacks attached to the deprecated hookpoint
89
-			foreach( $wp_filter[ $hook ] as $priority ) {
90
-				foreach( $priority as $callback ) {
89
+			foreach ($wp_filter[$hook] as $priority) {
90
+				foreach ($priority as $callback) {
91 91
 					// is the callback a non-static class method ?
92
-					if ( isset( $callback['function'] ) && is_array( $callback['function'] )) {
93
-						if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) {
94
-							$class_names[] = get_class( $callback['function'][0] );
92
+					if (isset($callback['function']) && is_array($callback['function'])) {
93
+						if (isset($callback['function'][0]) && is_object($callback['function'][0])) {
94
+							$class_names[] = get_class($callback['function'][0]);
95 95
 						}
96 96
 					// test for static method
97
-					} else if ( strpos( $callback['function'], '::' ) !== FALSE ) {
98
-						$class = explode( '::', $callback['function'] );
97
+					} else if (strpos($callback['function'], '::') !== FALSE) {
98
+						$class = explode('::', $callback['function']);
99 99
 						$class_names[] = $class[0];
100 100
 					} else {
101 101
 						// just a function
@@ -116,24 +116,24 @@  discard block
 block discarded – undo
116 116
 	 * 	@param		string 	$property
117 117
 	 * 	@return 		boolean
118 118
 	 */
119
-	public static function has_property( $class = NULL, $property = NULL ) {
119
+	public static function has_property($class = NULL, $property = NULL) {
120 120
 		// if $class or $property don't exist, then get out, cuz that would be like... fatal dude
121
-		if ( empty( $class ) || empty( $property )) {
121
+		if (empty($class) || empty($property)) {
122 122
 			return FALSE;
123 123
 		}
124 124
 		// if your hosting company doesn't cut the mustard
125
-		if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) {
125
+		if (version_compare(PHP_VERSION, '5.3.0') < 0) {
126 126
 			// just in case $class is an actual instantiated object
127
-			if ( is_object( $class )) {
128
-				return isset( $class->{$property} ) ? TRUE : FALSE;
127
+			if (is_object($class)) {
128
+				return isset($class->{$property} ) ? TRUE : FALSE;
129 129
 			} else {
130 130
 				// use reflection for < PHP 5.3 to get details using just the class name
131
-				$reflector = new ReflectionClass( $class );
132
-				return $reflector->hasProperty( $property );
131
+				$reflector = new ReflectionClass($class);
132
+				return $reflector->hasProperty($property);
133 133
 			}
134 134
 		} else {
135 135
 			// or try regular property exists method which works as expected in PHP 5.3+
136
-			return property_exists( $class, $property );
136
+			return property_exists($class, $property);
137 137
 		}
138 138
 	}
139 139
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 // if PHP version < 5.3
146
-if ( ! function_exists( 'get_called_class' )) {
146
+if ( ! function_exists('get_called_class')) {
147 147
 	/**
148 148
 	 * @return bool|string
149 149
 	 */
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 3 patches
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -89,7 +91,7 @@  discard block
 block discarded – undo
89 91
 			$payment_method_slug = EE_Registry::instance()->REQ->get( 'ee_payment_method', NULL );
90 92
 			if( $payment_method_slug ) {
91 93
 				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug( $payment_method_slug );
92
-			}else{
94
+			} else{
93 95
 				$payment_method = null;
94 96
 			}
95 97
 			/** @type EE_Payment_Processor $payment_processor */
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @access    public
40 40
 	 * @param    int $EVT_ID
41
-	 * @return    object
41
+	 * @return    null|boolean
42 42
 	 */
43 43
 	public static function get_event( $EVT_ID = 0 ) {
44 44
 		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 *  @access 	public
118 118
 	 * @param    int $EVT_ID
119
-	 *  @return 	string
119
+	 *  @return 	boolean
120 120
 	 */
121 121
 	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122 122
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *    event_active_status
137 137
 	 *
138 138
 	 * @access    public
139
-	 * @param null $num_words
139
+	 * @param integer $num_words
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @access    public
324 324
 	 * @param int $EVT_ID
325
-	 * @return    string
325
+	 * @return    string|null
326 326
 	 */
327 327
 	public static function get_primary_date_obj( $EVT_ID = 0 ) {
328 328
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @access    public
349 349
 	 * @param int $EVT_ID
350
-	 * @return    string
350
+	 * @return    string|null
351 351
 	 */
352 352
 	public static function get_last_date_obj( $EVT_ID = 0 ) {
353 353
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @access    public
374 374
 	 * @param int $EVT_ID
375
-	 * @return    string
375
+	 * @return    string|null
376 376
 	 */
377 377
 	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
378 378
 		$event = EEH_Event_View::get_event( $EVT_ID );
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @access    public
424 424
 	 * @param int $EVT_ID
425
-	 * @param null $include_expired
425
+	 * @param false|null $include_expired
426 426
 	 * @param bool $include_deleted
427 427
 	 * @param null $limit
428 428
 	 * @return EE_Datetime[]
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param    int $EVT_ID
41 41
 	 * @return    object
42 42
 	 */
43
-	public static function get_event( $EVT_ID = 0 ) {
44
-		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
43
+	public static function get_event($EVT_ID = 0) {
44
+		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
45 45
 		// do we already have the Event  you are looking for?
46
-		if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) {
46
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
47 47
 			return EEH_Event_View::$_event;
48 48
 		}
49 49
 		EEH_Event_View::$_event = NULL;
50 50
 		// international newspaper?
51 51
 		global $post;
52 52
 		// if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
53
-		 if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) {
53
+		 if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
54 54
 //			d( $post );
55 55
 			// grab the event we're looking for
56
-			if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) {
56
+			if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) {
57 57
 				EEH_Event_View::$_event = $post->EE_Event;
58 58
 //				d( EEH_Event_View::$_event );
59 59
 			}
60 60
 			// now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
61
-			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) {
61
+			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
62 62
 				// sigh... pull it from the db
63
-				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
63
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
64 64
 //				d( EEH_Event_View::$_event );
65 65
 			}
66 66
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @param    int $EVT_ID
77 77
 	 * @return    boolean
78 78
 	 */
79
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
80
-		$event = EEH_Event_View::get_event( $EVT_ID );
79
+	public static function display_ticket_selector($EVT_ID = 0) {
80
+		$event = EEH_Event_View::get_event($EVT_ID);
81 81
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
82 82
 	}
83 83
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param    int $EVT_ID
91 91
 	 * @return    string
92 92
 	 */
93
-	public static function event_status( $EVT_ID = 0 ) {
94
-		$event = EEH_Event_View::get_event( $EVT_ID );
95
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
93
+	public static function event_status($EVT_ID = 0) {
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
96 96
 	}
97 97
 
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param    int $EVT_ID
105 105
 	 *  @return 	string
106 106
 	 */
107
-	public static function event_active_status( $EVT_ID = 0 ) {
108
-		$event = EEH_Event_View::get_event( $EVT_ID );
107
+	public static function event_active_status($EVT_ID = 0) {
108
+		$event = EEH_Event_View::get_event($EVT_ID);
109 109
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
110 110
 	}
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param    int $EVT_ID
119 119
 	 *  @return 	string
120 120
 	 */
121
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122
-		$event = EEH_Event_View::get_event( $EVT_ID );
121
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
122
+		$event = EEH_Event_View::get_event($EVT_ID);
123 123
 		$has_content_or_excerpt = FALSE;
124
-		if ( $event instanceof EE_Event ) {
125
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
124
+		if ($event instanceof EE_Event) {
125
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
126 126
 		}
127
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
127
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
128 128
 			$has_content_or_excerpt = FALSE;
129 129
 		}
130 130
 		return $has_content_or_excerpt;
@@ -140,45 +140,45 @@  discard block
 block discarded – undo
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
143
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
143
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
144 144
 		global $post;
145 145
 
146 146
 		ob_start();
147
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
147
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
148 148
 
149 149
 			// admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option
150 150
 			the_content();
151 151
 
152
-		} else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) {
152
+		} else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
153 153
 
154 154
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
155 155
 			// AND an excerpt actually exists
156 156
 			the_excerpt();
157 157
 
158
-		} else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) {
158
+		} else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
159 159
 
160 160
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
161 161
 			// but NO excerpt actually exists, so we need to create one
162
-			if ( ! empty( $num_words )) {
163
-				if ( empty( $more )) {
164
-					$more_link_text = __( '(more&hellip;)' );
165
-					$more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>';
166
-					$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
162
+			if ( ! empty($num_words)) {
163
+				if (empty($more)) {
164
+					$more_link_text = __('(more&hellip;)');
165
+					$more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>';
166
+					$more = apply_filters('the_content_more_link', $more, $more_link_text);
167 167
 				}
168
-				$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
168
+				$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
169 169
 
170
-				$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
170
+				$content = wp_trim_words($content, $num_words, ' ').$more;
171 171
 			} else {
172
-				$content =  get_the_content();
172
+				$content = get_the_content();
173 173
 			}
174 174
 			global $allowedtags;
175
-			$content = wp_kses( $content, $allowedtags );
176
-			$content = strip_shortcodes( $content );
177
-			echo apply_filters( 'the_content', $content );
175
+			$content = wp_kses($content, $allowedtags);
176
+			$content = strip_shortcodes($content);
177
+			echo apply_filters('the_content', $content);
178 178
 
179 179
 		} else {
180 180
 			// admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option
181
-			echo apply_filters( 'the_content', '' );
181
+			echo apply_filters('the_content', '');
182 182
 		}
183 183
 		return ob_get_clean();
184 184
 	}
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param    int $EVT_ID
193 193
 	 *  @return 	EE_Ticket[]
194 194
 	 */
195
-	public static function event_tickets_available( $EVT_ID = 0 ) {
196
-		$event = EEH_Event_View::get_event( $EVT_ID );
195
+	public static function event_tickets_available($EVT_ID = 0) {
196
+		$event = EEH_Event_View::get_event($EVT_ID);
197 197
 		$tickets_available_for_purchase = array();
198
-		if( $event instanceof EE_Event ) {
199
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
200
-			foreach( $datetimes as $datetime ) {
201
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
198
+		if ($event instanceof EE_Event) {
199
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
200
+			foreach ($datetimes as $datetime) {
201
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
202 202
 			}
203 203
 		}
204 204
 		return $tickets_available_for_purchase;
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 	 * @param 	  bool   $hide_uncategorized
215 215
 	 * @return    string
216 216
 	 */
217
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
217
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
218 218
 		$category_links = array();
219
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
-		if ( $event instanceof EE_Event ) {
221
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
222
-			if ( $event_categories ) {
219
+		$event = EEH_Event_View::get_event($EVT_ID);
220
+		if ($event instanceof EE_Event) {
221
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
222
+			if ($event_categories) {
223 223
 				// loop thru terms and create links
224
-				foreach ( $event_categories as $term ) {
225
-					$url = get_term_link( $term, 'espresso_venue_categories' );
226
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
227
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>';
224
+				foreach ($event_categories as $term) {
225
+					$url = get_term_link($term, 'espresso_venue_categories');
226
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
227
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>';
228 228
 					}
229 229
 				}
230 230
 			}
231 231
 		}
232
-		return implode( ', ', $category_links );
232
+		return implode(', ', $category_links);
233 233
 	}
234 234
 
235 235
 
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 	 * @param int    $EVT_ID
244 244
 	 * @return    string
245 245
 	 */
246
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
247
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
248
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
249
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
246
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
247
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
248
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
249
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
250 250
 	}
251 251
 
252 252
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	 * @param int    $EVT_ID
261 261
 	 * @return    string
262 262
 	 */
263
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
264
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
265
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
266
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
263
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
264
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
265
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
266
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
267 267
 	}
268 268
 
269 269
 
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
 	 * @param int    $EVT_ID
278 278
 	 * @return    string
279 279
 	 */
280
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
281
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
282
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
283
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
280
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
281
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
282
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
283
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
284 284
 	}
285 285
 
286 286
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @param int    $EVT_ID
295 295
 	 * @return    string
296 296
 	 */
297
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
298
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
299
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
300
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
297
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
298
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
299
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
300
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
301 301
 	}
302 302
 
303 303
 
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * @param int $EVT_ID
310 310
 	 * @return    string
311 311
 	 */
312
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
313
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
314
-		if ( $datetime instanceof EE_Datetime ) {
312
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
313
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
314
+		if ($datetime instanceof EE_Datetime) {
315 315
 	?>
316 316
 		<div class="event-date-calendar-page-dv">
317
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
318
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
317
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
318
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
319 319
 		</div>
320 320
 	<?php
321 321
 		}
@@ -330,17 +330,17 @@  discard block
 block discarded – undo
330 330
 	 * @param int $EVT_ID
331 331
 	 * @return    string
332 332
 	 */
333
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
334
-		$event = EEH_Event_View::get_event( $EVT_ID );
335
-		if ( $event instanceof EE_Event ) {
333
+	public static function get_primary_date_obj($EVT_ID = 0) {
334
+		$event = EEH_Event_View::get_event($EVT_ID);
335
+		if ($event instanceof EE_Event) {
336 336
 			$datetimes = $event->get_many_related(
337 337
 				'Datetime',
338 338
 				array(
339 339
 					'limit' => 1,
340
-					'order_by' => array( 'DTT_order' => 'ASC' )
340
+					'order_by' => array('DTT_order' => 'ASC')
341 341
 				)
342 342
 			);
343
-			return reset( $datetimes );
343
+			return reset($datetimes);
344 344
 		} else {
345 345
 			 return FALSE;
346 346
 		}
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 * @param int $EVT_ID
356 356
 	 * @return    string
357 357
 	 */
358
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
359
-		$event = EEH_Event_View::get_event( $EVT_ID );
360
-		if ( $event instanceof EE_Event ) {
358
+	public static function get_last_date_obj($EVT_ID = 0) {
359
+		$event = EEH_Event_View::get_event($EVT_ID);
360
+		if ($event instanceof EE_Event) {
361 361
 			$datetimes = $event->get_many_related(
362 362
 				'Datetime',
363 363
 				array(
364 364
 					'limit' => 1,
365
-					'order_by' => array( 'DTT_order' => 'DESC' )
365
+					'order_by' => array('DTT_order' => 'DESC')
366 366
 				)
367 367
 			);
368
-			return end( $datetimes );
368
+			return end($datetimes);
369 369
 		} else {
370 370
 			return FALSE;
371 371
 		}
@@ -380,17 +380,17 @@  discard block
 block discarded – undo
380 380
 	 * @param int $EVT_ID
381 381
 	 * @return    string
382 382
 	 */
383
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
384
-		$event = EEH_Event_View::get_event( $EVT_ID );
385
-		if ( $event instanceof EE_Event ) {
383
+	public static function get_earliest_date_obj($EVT_ID = 0) {
384
+		$event = EEH_Event_View::get_event($EVT_ID);
385
+		if ($event instanceof EE_Event) {
386 386
 			$datetimes = $event->get_many_related(
387 387
 				'Datetime',
388 388
 				array(
389 389
 					'limit' => 1,
390
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
390
+					'order_by' => array('DTT_EVT_start' => 'ASC')
391 391
 				)
392 392
 			);
393
-			return reset( $datetimes );
393
+			return reset($datetimes);
394 394
 		} else {
395 395
 			 return FALSE;
396 396
 		}
@@ -405,17 +405,17 @@  discard block
 block discarded – undo
405 405
 	 * @param int $EVT_ID
406 406
 	 * @return    string
407 407
 	 */
408
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
409
-		$event = EEH_Event_View::get_event( $EVT_ID );
410
-		if ( $event instanceof EE_Event ) {
408
+	public static function get_latest_date_obj($EVT_ID = 0) {
409
+		$event = EEH_Event_View::get_event($EVT_ID);
410
+		if ($event instanceof EE_Event) {
411 411
 			$datetimes = $event->get_many_related(
412 412
 				'Datetime',
413 413
 				array(
414 414
 					'limit' => 1,
415
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
415
+					'order_by' => array('DTT_EVT_start' => 'DESC')
416 416
 				)
417 417
 			);
418
-			return end( $datetimes );
418
+			return end($datetimes);
419 419
 		} else {
420 420
 			return FALSE;
421 421
 		}
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
 	 * @param null $limit
434 434
 	 * @return EE_Datetime[]
435 435
 	 */
436
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
437
-		$event = EEH_Event_View::get_event( $EVT_ID );
438
-		if($include_expired === null){
439
-			if($event instanceof EE_Event && $event->is_expired()){
436
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
437
+		$event = EEH_Event_View::get_event($EVT_ID);
438
+		if ($include_expired === null) {
439
+			if ($event instanceof EE_Event && $event->is_expired()) {
440 440
 				$include_expired = true;
441
-			}else{
441
+			} else {
442 442
 				$include_expired = false;
443 443
 			}
444 444
 		}
445 445
 
446
-		if ( $event instanceof EE_Event ) {
446
+		if ($event instanceof EE_Event) {
447 447
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
448 448
 		} else {
449 449
 			 return array();
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 	 * @param int $EVT_ID
460 460
 	 * @return    string
461 461
 	 */
462
-	public static function event_link_url( $EVT_ID = 0 ) {
463
-		$event = EEH_Event_View::get_event( $EVT_ID );
464
-		if ( $event instanceof EE_Event ) {
465
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
466
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
462
+	public static function event_link_url($EVT_ID = 0) {
463
+		$event = EEH_Event_View::get_event($EVT_ID);
464
+		if ($event instanceof EE_Event) {
465
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
466
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
467 467
 		}
468 468
 		return NULL;
469 469
 	}
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
 	 * @param int $EVT_ID
478 478
 	 * @return    string
479 479
 	 */
480
-	public static function event_phone( $EVT_ID = 0 ) {
481
-		$event = EEH_Event_View::get_event( $EVT_ID );
482
-		if ( $event instanceof EE_Event ) {
483
-			return EEH_Schema::telephone( $event->phone() );
480
+	public static function event_phone($EVT_ID = 0) {
481
+		$event = EEH_Event_View::get_event($EVT_ID);
482
+		if ($event instanceof EE_Event) {
483
+			return EEH_Schema::telephone($event->phone());
484 484
 		}
485 485
 		return NULL;
486 486
 	}
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
 	 * @param string $after
498 498
 	 * @return    string
499 499
 	 */
500
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
501
-		$event = EEH_Event_View::get_event( $EVT_ID );
502
-		if ( $event instanceof EE_Event ) {
500
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
501
+		$event = EEH_Event_View::get_event($EVT_ID);
502
+		if ($event instanceof EE_Event) {
503 503
 			// can the user edit this post ?
504
-			if ( current_user_can( 'edit_post', $event->ID() )) {
504
+			if (current_user_can('edit_post', $event->ID())) {
505 505
 				// set link text
506
-				$link = ! empty( $link ) ? $link : __('edit this event');
506
+				$link = ! empty($link) ? $link : __('edit this event');
507 507
 				// generate nonce
508
-				$nonce = wp_create_nonce( 'edit_nonce' );
508
+				$nonce = wp_create_nonce('edit_nonce');
509 509
 				// generate url to event editor for this event
510
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
510
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
511 511
 				// get edit CPT text
512
-				$post_type_obj = get_post_type_object( 'espresso_events' );
512
+				$post_type_obj = get_post_type_object('espresso_events');
513 513
 				// build final link html
514
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
514
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
515 515
 				// put it all together
516
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
516
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
517 517
 			}
518 518
 		}
519 519
 		return '';
Please login to merge, or discard this patch.
core/helpers/EEH_File.helper.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -595,8 +595,6 @@
 block discarded – undo
595 595
 	 * converts it into a "remote" filepath (the filepath the currently-in-use 
596 596
 	 * $wp_filesystem needs to use access the folder or file).
597 597
 	 * See http://wordpress.stackexchange.com/questions/124900/using-wp-filesystem-in-plugins
598
-	 * @param WP_Filesystem_Base $wp_filesystem we aren't initially sure which one
599
-	 * is in use, so you need to provide it
600 598
 	 * @param string $local_filepath the filepath to the folder/file locally
601 599
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg 
602 600
 	 * ftp or ssh, will use to access the folder
Please login to merge, or discard this patch.
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
  * @ version		 	4.0
13 13
  *
14 14
  */
15
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
16
-require_once( EE_INTERFACES . 'EEI_Interfaces.php' );
15
+require_once(EE_HELPERS.'EEH_Base.helper.php');
16
+require_once(EE_INTERFACES.'EEI_Interfaces.php');
17 17
 /**
18 18
  *
19 19
  * Class EEH_File
@@ -42,30 +42,30 @@  discard block
 block discarded – undo
42 42
 	 * @throws EE_Error
43 43
 	 * @return WP_Filesystem_Base
44 44
 	 */
45
-	private static function _get_wp_filesystem( $filepath = null) {
46
-		if( apply_filters( 
45
+	private static function _get_wp_filesystem($filepath = null) {
46
+		if (apply_filters( 
47 47
 				'FHEE__EEH_File___get_wp_filesystem__allow_using_filesystem_direct', 
48
-				$filepath && EEH_File::is_in_uploads_folder( $filepath ), 
49
-				$filepath ) ) {
50
-			if( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct ) {
51
-				require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
48
+				$filepath && EEH_File::is_in_uploads_folder($filepath), 
49
+				$filepath )) {
50
+			if ( ! EEH_File::$_wp_filesystem_direct instanceof WP_Filesystem_Direct) {
51
+				require_once(ABSPATH.'wp-admin/includes/class-wp-filesystem-base.php');
52 52
 				$method = 'direct';
53
-				$wp_filesystem_direct_file = apply_filters( 'filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method );
53
+				$wp_filesystem_direct_file = apply_filters('filesystem_method_file', ABSPATH.'wp-admin/includes/class-wp-filesystem-'.$method.'.php', $method);
54 54
 				//check constants defined, just like in wp-admin/includes/file.php's WP_Filesystem()
55
-				if ( ! defined('FS_CHMOD_DIR') ) {
56
-					define('FS_CHMOD_DIR', ( fileperms( ABSPATH ) & 0777 | 0755 ) );
55
+				if ( ! defined('FS_CHMOD_DIR')) {
56
+					define('FS_CHMOD_DIR', (fileperms(ABSPATH) & 0777 | 0755));
57 57
 				}
58
-				if ( ! defined('FS_CHMOD_FILE') ) {
59
-					define('FS_CHMOD_FILE', ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ) );
58
+				if ( ! defined('FS_CHMOD_FILE')) {
59
+					define('FS_CHMOD_FILE', (fileperms(ABSPATH.'index.php') & 0777 | 0644));
60 60
 				}
61
-				require_once( $wp_filesystem_direct_file );
62
-				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct( array() );
61
+				require_once($wp_filesystem_direct_file);
62
+				EEH_File::$_wp_filesystem_direct = new WP_Filesystem_Direct(array());
63 63
 			}
64 64
 			return EEH_File::$_wp_filesystem_direct;
65 65
 		}
66 66
 		global $wp_filesystem;
67 67
 		// no filesystem setup ???
68
-		if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) {
68
+		if ( ! $wp_filesystem instanceof WP_Filesystem_Base) {
69 69
 			// if some eager beaver's just trying to get in there too early...
70 70
 			// let them do it, because we are one of those eager beavers! :P
71 71
 			/**
@@ -78,34 +78,34 @@  discard block
 block discarded – undo
78 78
 			 * and there may be troubles if the WP files are owned by a different user
79 79
 			 * than the server user. But both of these issues should exist in 4.4 and earlier too
80 80
 			 */
81
-			if ( FALSE && ! did_action( 'wp_loaded' )) {
81
+			if (FALSE && ! did_action('wp_loaded')) {
82 82
 				$msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso');
83
-				if ( WP_DEBUG ) {
84
-					$msg .= '<br />' .  __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
83
+				if (WP_DEBUG) {
84
+					$msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso');
85 85
 				}
86
-				throw new EE_Error( $msg );
86
+				throw new EE_Error($msg);
87 87
 			} else {
88 88
 				// should be loaded if we are past the wp_loaded hook...
89
-				if ( ! function_exists( 'WP_Filesystem' )) {
90
-					require_once( ABSPATH . 'wp-admin/includes/file.php' );
91
-					require_once( ABSPATH . 'wp-admin/includes/template.php' );
89
+				if ( ! function_exists('WP_Filesystem')) {
90
+					require_once(ABSPATH.'wp-admin/includes/file.php');
91
+					require_once(ABSPATH.'wp-admin/includes/template.php');
92 92
 				}
93 93
 				// turn on output buffering so that we can capture the credentials form
94 94
 				ob_start();
95
-				$credentials = request_filesystem_credentials( '' );
95
+				$credentials = request_filesystem_credentials('');
96 96
 				// store credentials form for the time being
97 97
 				EEH_File::$_credentials_form = ob_get_clean();
98 98
 				// basically check for direct or previously configured access
99
-				if ( ! WP_Filesystem( $credentials ) ) {
99
+				if ( ! WP_Filesystem($credentials)) {
100 100
 					// if credentials do NOT exist
101
-					if ( $credentials === FALSE ) {
102
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
103
-						throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
104
-					} elseif( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
105
-						add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 );
101
+					if ($credentials === FALSE) {
102
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
103
+						throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'));
104
+					} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
105
+						add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999);
106 106
 						throw new EE_Error(
107 107
 								sprintf(
108
-										__( 'WP Filesystem Error: $1%s', 'event_espresso' ),
108
+										__('WP Filesystem Error: $1%s', 'event_espresso'),
109 109
 										$wp_filesystem->errors->get_error_message() ) );
110 110
 					}
111 111
 				}
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 * display_request_filesystem_credentials_form
119 119
 	 */
120 120
 	public static function display_request_filesystem_credentials_form() {
121
-		if ( ! empty( EEH_File::$_credentials_form )) {
122
-			echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>';
121
+		if ( ! empty(EEH_File::$_credentials_form)) {
122
+			echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>';
123 123
 		}
124 124
 	}
125 125
 
@@ -137,29 +137,29 @@  discard block
 block discarded – undo
137 137
 	 * @throws EE_Error
138 138
 	 * @return bool
139 139
 	 */
140
-	public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) {
140
+	public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') {
141 141
 		// load WP_Filesystem and set file permissions
142
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
143
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
144
-		if ( ! $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) )) {
145
-			$file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name;
146
-			$file_name .= ! empty( $file_ext ) ? ' file' : ' folder';
142
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
143
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
144
+		if ( ! $wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
145
+			$file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name;
146
+			$file_name .= ! empty($file_ext) ? ' file' : ' folder';
147 147
 			$msg = sprintf(
148
-				__( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ),
148
+				__('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'),
149 149
 				$file_name,
150 150
 				'<br />'
151 151
 			);
152
-			if ( EEH_File::exists( $full_file_path )) {
153
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file );
152
+			if (EEH_File::exists($full_file_path)) {
153
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file);
154 154
 			} else {
155 155
 				// no file permissions means the file was not found
156 156
 				$msg .= sprintf(
157
-					__( 'Please ensure the following path is correct: "%s".', 'event_espresso' ),
157
+					__('Please ensure the following path is correct: "%s".', 'event_espresso'),
158 158
 					$full_file_path
159 159
 				);
160 160
 			}
161
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
162
-				throw new EE_Error( $msg . '||' . $msg );
161
+			if (defined('WP_DEBUG') && WP_DEBUG) {
162
+				throw new EE_Error($msg.'||'.$msg);
163 163
 			}
164 164
 			return FALSE;
165 165
 		}
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
 	 * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages
177 177
 	 * @return string
178 178
 	 */
179
-	private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){
179
+	private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') {
180 180
 		// load WP_Filesystem and set file permissions
181
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
181
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
182 182
 		// check file permissions
183
-		$perms = $wp_filesystem->getchmod( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
184
-		if ( $perms ) {
183
+		$perms = $wp_filesystem->getchmod(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
184
+		if ($perms) {
185 185
 			// file permissions exist, but way be set incorrectly
186
-			$type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : '';
187
-			$type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder';
186
+			$type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : '';
187
+			$type_of_file .= ! empty($type_of_file) ? 'file' : 'folder';
188 188
 			return sprintf(
189
-				__( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ),
189
+				__('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'),
190 190
 				$type_of_file,
191 191
 				$perms
192 192
 			);
193 193
 		} else {
194 194
 			// file exists but file permissions could not be read ?!?!
195 195
 			return sprintf(
196
-				__( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ),
196
+				__('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'),
197 197
 				$full_file_path
198 198
 			);
199 199
 		}
@@ -211,35 +211,35 @@  discard block
 block discarded – undo
211 211
 	 * can't write to it
212 212
 	 * @return bool false if folder isn't writable; true if it exists and is writeable,
213 213
 	 */
214
-	public static function ensure_folder_exists_and_is_writable( $folder = '' ){
215
-		if ( empty( $folder )) {
214
+	public static function ensure_folder_exists_and_is_writable($folder = '') {
215
+		if (empty($folder)) {
216 216
 			return false;
217 217
 		}
218 218
 		// remove ending DS
219
-		$folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' ));
220
-		$parent_folder = EEH_File::get_parent_folder( $folder );
219
+		$folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\'));
220
+		$parent_folder = EEH_File::get_parent_folder($folder);
221 221
 		// add DS to folder
222
-		$folder = EEH_File::end_with_directory_separator( $folder );
223
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $folder );
224
-		if ( ! $wp_filesystem->is_dir( EEH_File::convert_local_filepath_to_remote_filepath( $folder ) ) ) {
222
+		$folder = EEH_File::end_with_directory_separator($folder);
223
+		$wp_filesystem = EEH_File::_get_wp_filesystem($folder);
224
+		if ( ! $wp_filesystem->is_dir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
225 225
 			//ok so it doesn't exist. Does its parent? Can we write to it?
226
-			if(	! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
226
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
227 227
 				return false;
228 228
 			}
229
-			if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) {
229
+			if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) {
230 230
 				return false;
231 231
 			} else {
232
-				if ( ! $wp_filesystem->mkdir( EEH_File::convert_local_filepath_to_remote_filepath(  $folder ) ) ) {
233
-					if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
234
-						$msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder );
235
-						$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder );
236
-						throw new EE_Error( $msg );
232
+				if ( ! $wp_filesystem->mkdir(EEH_File::convert_local_filepath_to_remote_filepath($folder))) {
233
+					if (defined('WP_DEBUG') && WP_DEBUG) {
234
+						$msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder);
235
+						$msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder);
236
+						throw new EE_Error($msg);
237 237
 					}
238 238
 					return false;
239 239
 				}
240
-				EEH_File::add_index_file( $folder );
240
+				EEH_File::add_index_file($folder);
241 241
 			}
242
-		} elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
242
+		} elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) {
243 243
 			return false;
244 244
 		}
245 245
 		return true;
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
 	 * @throws EE_Error
255 255
 	 * @return bool
256 256
 	 */
257
-	public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){
257
+	public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') {
258 258
 		// load WP_Filesystem and set file permissions
259
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_path );
260
-		$full_path = EEH_File::standardise_directory_separators( $full_path );
261
-		if ( ! $wp_filesystem->is_writable( EEH_File::convert_local_filepath_to_remote_filepath( $full_path ) ) ) {
262
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
263
-				$msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder );
264
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path );
265
-				throw new EE_Error( $msg );
259
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_path);
260
+		$full_path = EEH_File::standardise_directory_separators($full_path);
261
+		if ( ! $wp_filesystem->is_writable(EEH_File::convert_local_filepath_to_remote_filepath($full_path))) {
262
+			if (defined('WP_DEBUG') && WP_DEBUG) {
263
+				$msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder);
264
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path);
265
+				throw new EE_Error($msg);
266 266
 			}
267 267
 			return FALSE;
268 268
 		}
@@ -279,25 +279,25 @@  discard block
 block discarded – undo
279 279
 	 * @throws EE_Error
280 280
 	 * @return bool
281 281
 	 */
282
-	public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) {
282
+	public static function ensure_file_exists_and_is_writable($full_file_path = '') {
283 283
 		// load WP_Filesystem and set file permissions
284
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
285
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
286
-		$parent_folder = EEH_File::get_parent_folder( $full_file_path );
287
-		if ( ! EEH_File::exists( $full_file_path )) {
288
-			if( ! EEH_File::ensure_folder_exists_and_is_writable( $parent_folder ) ) {
284
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
285
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
286
+		$parent_folder = EEH_File::get_parent_folder($full_file_path);
287
+		if ( ! EEH_File::exists($full_file_path)) {
288
+			if ( ! EEH_File::ensure_folder_exists_and_is_writable($parent_folder)) {
289 289
 				return false;
290 290
 			}
291
-			if ( ! $wp_filesystem->touch( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ) {
292
-				if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
293
-					$msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path );
294
-					$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
295
-					throw new EE_Error( $msg );
291
+			if ( ! $wp_filesystem->touch(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
292
+				if (defined('WP_DEBUG') && WP_DEBUG) {
293
+					$msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path);
294
+					$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
295
+					throw new EE_Error($msg);
296 296
 				}
297 297
 				return false;
298 298
 			}
299 299
 		}
300
-		if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) {
300
+		if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) {
301 301
 			return false;
302 302
 		}
303 303
 		return true;
@@ -309,15 +309,15 @@  discard block
 block discarded – undo
309 309
 	 * @param string $file_or_folder_path
310 310
 	 * @return string parent folder, ENDING with a directory separator
311 311
 	 */
312
-	public static function get_parent_folder( $file_or_folder_path ) {
312
+	public static function get_parent_folder($file_or_folder_path) {
313 313
 		//find the last DS, ignoring a DS on the very end
314 314
 		//eg if given "/var/something/somewhere/", we want to get "somewhere"'s
315 315
 		//parent folder, "/var/something/"
316
-		$ds = strrpos( $file_or_folder_path, DS, -2 );
317
-		return substr( $file_or_folder_path, 0, $ds + 1 );
316
+		$ds = strrpos($file_or_folder_path, DS, -2);
317
+		return substr($file_or_folder_path, 0, $ds + 1);
318 318
 	}
319 319
 	
320
-	public static function ensure_folder_exists_recursively( $folder ) {
320
+	public static function ensure_folder_exists_recursively($folder) {
321 321
 		
322 322
 	}
323 323
 
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 	 * @param string $full_file_path
329 329
 	 * @return string
330 330
 	 */
331
-	public static function get_file_contents( $full_file_path = '' ){
332
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
333
-		if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) {
331
+	public static function get_file_contents($full_file_path = '') {
332
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
333
+		if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) {
334 334
 			// load WP_Filesystem and set file permissions
335
-			$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
336
-			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) );
335
+			$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
336
+			return $wp_filesystem->get_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path));
337 337
 		}
338 338
 		return '';
339 339
 	}
@@ -348,26 +348,26 @@  discard block
 block discarded – undo
348 348
 	 * @throws EE_Error
349 349
 	 * @return bool
350 350
 	 */
351
-	public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){
352
-		$full_file_path = EEH_File::standardise_directory_separators( $full_file_path );
353
-		$file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : '';
354
-		$folder = EEH_File::remove_filename_from_filepath( $full_file_path );
355
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
356
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
357
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path );
358
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path );
359
-				throw new EE_Error( $msg );
351
+	public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') {
352
+		$full_file_path = EEH_File::standardise_directory_separators($full_file_path);
353
+		$file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : '';
354
+		$folder = EEH_File::remove_filename_from_filepath($full_file_path);
355
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
356
+			if (defined('WP_DEBUG') && WP_DEBUG) {
357
+				$msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path);
358
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path);
359
+				throw new EE_Error($msg);
360 360
 			}
361 361
 			return FALSE;
362 362
 		}
363 363
 		// load WP_Filesystem and set file permissions
364
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
364
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
365 365
 		// write the file
366
-		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ), $file_contents )) {
367
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
368
-				$msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path );
369
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' );
370
-				throw new EE_Error( $msg );
366
+		if ( ! $wp_filesystem->put_contents(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path), $file_contents)) {
367
+			if (defined('WP_DEBUG') && WP_DEBUG) {
368
+				$msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path);
369
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f');
370
+				throw new EE_Error($msg);
371 371
 			}
372 372
 			return FALSE;
373 373
 		}
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 	 * @param boolean|string $type 'd' for directory, 'f' for file
383 383
 	 * @return boolean
384 384
 	 */
385
-	public static function delete( $filepath, $recursive = false, $type = false ) {
385
+	public static function delete($filepath, $recursive = false, $type = false) {
386 386
 		$wp_filesystem = EEH_File::_get_wp_filesystem();
387
-		return $wp_filesystem->delete( $filepath, $recursive, $type ) ? TRUE : FALSE;
387
+		return $wp_filesystem->delete($filepath, $recursive, $type) ? TRUE : FALSE;
388 388
 	}
389 389
 
390 390
 
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
 	 * @param string $full_file_path
397 397
 	 * @return bool
398 398
 	 */
399
-	public static function exists( $full_file_path = '' ) {
400
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
401
-		return $wp_filesystem->exists( EEH_File::convert_local_filepath_to_remote_filepath( $full_file_path ) ) ? TRUE : FALSE;
399
+	public static function exists($full_file_path = '') {
400
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
401
+		return $wp_filesystem->exists(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path)) ? TRUE : FALSE;
402 402
 	}
403 403
 
404 404
 
@@ -410,9 +410,9 @@  discard block
 block discarded – undo
410 410
 	 * @param string $full_file_path
411 411
 	 * @return bool
412 412
 	 */
413
-	public static function is_readable( $full_file_path = '' ) {
414
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $full_file_path );
415
-		if( $wp_filesystem->is_readable( EEH_File::convert_local_filepath_to_remote_filepath(  $full_file_path ) ) ) {
413
+	public static function is_readable($full_file_path = '') {
414
+		$wp_filesystem = EEH_File::_get_wp_filesystem($full_file_path);
415
+		if ($wp_filesystem->is_readable(EEH_File::convert_local_filepath_to_remote_filepath($full_file_path))) {
416 416
 			return true;
417 417
 		} else {
418 418
 			return false;
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 	 * @param string $full_file_path
429 429
 	 * @return string
430 430
 	 */
431
-	public static function remove_filename_from_filepath( $full_file_path = '' ) {
432
-		return pathinfo( $full_file_path, PATHINFO_DIRNAME );
431
+	public static function remove_filename_from_filepath($full_file_path = '') {
432
+		return pathinfo($full_file_path, PATHINFO_DIRNAME);
433 433
 	}
434 434
 
435 435
 
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
 	 * @param string $full_file_path
440 440
 	 * @return string
441 441
 	 */
442
-	public static function get_filename_from_filepath( $full_file_path = '' ) {
443
-		return pathinfo( $full_file_path, PATHINFO_BASENAME );
442
+	public static function get_filename_from_filepath($full_file_path = '') {
443
+		return pathinfo($full_file_path, PATHINFO_BASENAME);
444 444
 	}
445 445
 
446 446
 
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
 	 * @param string $full_file_path
451 451
 	 * @return string
452 452
 	 */
453
-	public static function get_file_extension( $full_file_path = '' ) {
454
-		return pathinfo( $full_file_path, PATHINFO_EXTENSION );
453
+	public static function get_file_extension($full_file_path = '') {
454
+		return pathinfo($full_file_path, PATHINFO_EXTENSION);
455 455
 	}
456 456
 
457 457
 
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
 	 * @param string $folder
462 462
 	 * @return bool
463 463
 	 */
464
-	public static function add_htaccess_deny_from_all( $folder = '' ) {
465
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
466
-		if ( ! EEH_File::exists( $folder . '.htaccess' ) ) {
467
-			if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) {
464
+	public static function add_htaccess_deny_from_all($folder = '') {
465
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
466
+		if ( ! EEH_File::exists($folder.'.htaccess')) {
467
+			if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) {
468 468
 				return FALSE;
469 469
 			}
470 470
 		}
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
 	 * @param string $folder
478 478
 	 * @return boolean
479 479
 	 */
480
-	public static function add_index_file( $folder ) {
481
-		$folder = EEH_File::standardise_and_end_with_directory_separator( $folder );
482
-		if ( ! EEH_File::exists( $folder . 'index.php' ) ) {
483
-			if ( ! EEH_File::write_to_file( $folder . 'index.php', 'You are not permitted to read from this folder', '.php' )) {
480
+	public static function add_index_file($folder) {
481
+		$folder = EEH_File::standardise_and_end_with_directory_separator($folder);
482
+		if ( ! EEH_File::exists($folder.'index.php')) {
483
+			if ( ! EEH_File::write_to_file($folder.'index.php', 'You are not permitted to read from this folder', '.php')) {
484 484
 				return false;
485 485
 			}
486 486
 		}
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 	 * @param string $file_path
496 496
 	 * @return string
497 497
 	 */
498
-	public static function get_classname_from_filepath_with_standard_filename( $file_path ){
498
+	public static function get_classname_from_filepath_with_standard_filename($file_path) {
499 499
 		//extract file from path
500
-		$filename = basename( $file_path );
500
+		$filename = basename($file_path);
501 501
 		//now remove the first period and everything after
502
-		$pos_of_first_period = strpos( $filename,'.' );
502
+		$pos_of_first_period = strpos($filename, '.');
503 503
 		return substr($filename, 0, $pos_of_first_period);
504 504
 	}
505 505
 
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @param string $file_path
512 512
 	 * @return string
513 513
 	 */
514
-	public static function standardise_directory_separators( $file_path ){
515
-		return str_replace( array( '\\', '/' ), DS, $file_path );
514
+	public static function standardise_directory_separators($file_path) {
515
+		return str_replace(array('\\', '/'), DS, $file_path);
516 516
 	}
517 517
 
518 518
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	 * @param string $file_path
524 524
 	 * @return string
525 525
 	 */
526
-	public static function end_with_directory_separator( $file_path ){
527
-		return rtrim( $file_path, '/\\' ) . DS;
526
+	public static function end_with_directory_separator($file_path) {
527
+		return rtrim($file_path, '/\\').DS;
528 528
 	}
529 529
 
530 530
 
@@ -534,8 +534,8 @@  discard block
 block discarded – undo
534 534
 	 * @param $file_path
535 535
 	 * @return string
536 536
 	 */
537
-	public static function standardise_and_end_with_directory_separator( $file_path ){
538
-		return self::end_with_directory_separator( self::standardise_directory_separators( $file_path ));
537
+	public static function standardise_and_end_with_directory_separator($file_path) {
538
+		return self::end_with_directory_separator(self::standardise_directory_separators($file_path));
539 539
 	}
540 540
 
541 541
 
@@ -552,21 +552,21 @@  discard block
 block discarded – undo
552 552
 	 *		if $index_numerically == FALSE (Default) keys are what the class names SHOULD be;
553 553
 	 *		 and values are their filepaths
554 554
 	 */
555
-	public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){
555
+	public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) {
556 556
 		$class_to_folder_path = array();
557
-		foreach( $folder_paths as $folder_path ){
558
-			$folder_path = self::standardise_and_end_with_directory_separator( $folder_path );
557
+		foreach ($folder_paths as $folder_path) {
558
+			$folder_path = self::standardise_and_end_with_directory_separator($folder_path);
559 559
 			// load WP_Filesystem and set file permissions
560
-			$files_in_folder = glob( $folder_path . '*' );
560
+			$files_in_folder = glob($folder_path.'*');
561 561
 			$class_to_folder_path = array();
562
-			if ( $files_in_folder ) {
563
-				foreach( $files_in_folder as $file_path ){
562
+			if ($files_in_folder) {
563
+				foreach ($files_in_folder as $file_path) {
564 564
 					//only add files, not folders
565
-					if ( ! is_dir( $file_path )) {
566
-						if ( $index_numerically ) {
565
+					if ( ! is_dir($file_path)) {
566
+						if ($index_numerically) {
567 567
 							$class_to_folder_path[] = $file_path;
568 568
 						} else {
569
-							$classname = self::get_classname_from_filepath_with_standard_filename( $file_path );
569
+							$classname = self::get_classname_from_filepath_with_standard_filename($file_path);
570 570
 							$class_to_folder_path[$classname] = $file_path;
571 571
 						}
572 572
 					}
@@ -586,39 +586,39 @@  discard block
 block discarded – undo
586 586
 	 * @return boolean success
587 587
 	 * @throws EE_Error
588 588
 	 */
589
-	public static function copy( $source_file, $destination_file, $overwrite = FALSE ){
590
-		$full_source_path = EEH_File::standardise_directory_separators( $source_file );
591
-		if( ! EEH_File::exists( $full_source_path ) ){
592
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
593
-				$msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path );
594
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path );
595
-				throw new EE_Error( $msg );
589
+	public static function copy($source_file, $destination_file, $overwrite = FALSE) {
590
+		$full_source_path = EEH_File::standardise_directory_separators($source_file);
591
+		if ( ! EEH_File::exists($full_source_path)) {
592
+			if (defined('WP_DEBUG') && WP_DEBUG) {
593
+				$msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path);
594
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path);
595
+				throw new EE_Error($msg);
596 596
 			}
597 597
 			return FALSE;
598 598
 		}
599 599
 
600
-		$full_dest_path = EEH_File::standardise_directory_separators( $destination_file );
601
-		$folder = EEH_File::remove_filename_from_filepath( $full_dest_path );
602
-		if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) {
603
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
604
-				$msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path );
605
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path );
606
-				throw new EE_Error( $msg );
600
+		$full_dest_path = EEH_File::standardise_directory_separators($destination_file);
601
+		$folder = EEH_File::remove_filename_from_filepath($full_dest_path);
602
+		if ( ! EEH_File::verify_is_writable($folder, 'folder')) {
603
+			if (defined('WP_DEBUG') && WP_DEBUG) {
604
+				$msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path);
605
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path);
606
+				throw new EE_Error($msg);
607 607
 			}
608 608
 			return FALSE;
609 609
 		}
610 610
 
611 611
 		// load WP_Filesystem and set file permissions
612
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $destination_file );
612
+		$wp_filesystem = EEH_File::_get_wp_filesystem($destination_file);
613 613
 		// write the file
614 614
 		if ( ! $wp_filesystem->copy( 
615
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_source_path ), 
616
-						EEH_File::convert_local_filepath_to_remote_filepath( $full_dest_path ), 
615
+						EEH_File::convert_local_filepath_to_remote_filepath($full_source_path), 
616
+						EEH_File::convert_local_filepath_to_remote_filepath($full_dest_path), 
617 617
 						$overwrite )) {
618
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
619
-				$msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path );
620
-				$msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' );
621
-				throw new EE_Error( $msg );
618
+			if (defined('WP_DEBUG') && WP_DEBUG) {
619
+				$msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path);
620
+				$msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f');
621
+				throw new EE_Error($msg);
622 622
 			}
623 623
 			return FALSE;
624 624
 		}
@@ -630,9 +630,9 @@  discard block
 block discarded – undo
630 630
 	 * @param string $filepath
631 631
 	 * @return boolean
632 632
 	 */
633
-	public static function is_in_uploads_folder( $filepath ) {
633
+	public static function is_in_uploads_folder($filepath) {
634 634
 		$uploads = wp_upload_dir();
635
-		return strpos( $filepath, $uploads[ 'basedir' ] ) === 0 ? true : false;
635
+		return strpos($filepath, $uploads['basedir']) === 0 ? true : false;
636 636
 	}
637 637
 	
638 638
 	/**
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 	 * @return string the remote filepath (eg the filepath the filesystem method, eg 
647 647
 	 * ftp or ssh, will use to access the folder
648 648
 	 */
649
-	public static function convert_local_filepath_to_remote_filepath( $local_filepath ) {
650
-		$wp_filesystem = EEH_File::_get_wp_filesystem( $local_filepath );
651
-		return str_replace( WP_CONTENT_DIR . DS, $wp_filesystem->wp_content_dir(), $local_filepath );
649
+	public static function convert_local_filepath_to_remote_filepath($local_filepath) {
650
+		$wp_filesystem = EEH_File::_get_wp_filesystem($local_filepath);
651
+		return str_replace(WP_CONTENT_DIR.DS, $wp_filesystem->wp_content_dir(), $local_filepath);
652 652
 	}
653 653
 }
654 654
 // End of file EEH_File.helper.php
Please login to merge, or discard this patch.
core/helpers/EEH_Line_Item.helper.php 4 patches
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.
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
 	 * Deletes ALL children of the passed line item
611 611
 	 *
612 612
 	 * @param EE_Line_Item $parent_line_item
613
-	 * @return bool
613
+	 * @return integer
614 614
 	 */
615 615
 	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
616 616
 		$deleted = 0;
@@ -848,6 +848,7 @@  discard block
 block discarded – undo
848 848
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
849 849
 	 * @param string $line_item_type one of the EEM_Line_Item constants
850 850
 	 * @param string | NULL $obj_type object model class name (minus prefix) or NULL to ignore object type when searching
851
+	 * @param string $obj_type
851 852
 	 * @return EE_Line_Item[]
852 853
 	 */
853 854
 	protected static function _get_descendants_by_type_and_object_type( EE_Line_Item $parent_line_item, $line_item_type, $obj_type = NULL ) {
@@ -873,7 +874,7 @@  discard block
 block discarded – undo
873 874
 	 * @uses  EEH_Line_Item::_get_descendants_by_type_and_object_type()
874 875
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
875 876
 	 * @param string $OBJ_type object type (like Event)
876
-	 * @param array $OBJ_IDs array of OBJ_IDs
877
+	 * @param string[] $OBJ_IDs array of OBJ_IDs
877 878
 	 * @return EE_Line_Item[]
878 879
 	 */
879 880
 	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   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -551,15 +551,15 @@  discard block
 block discarded – undo
551 551
 	}
552 552
 
553 553
 	/**
554
-	  * Given the grand total line item and a ticket, finds the event sub-total
555
-	  * line item the ticket's purchase should be added onto
556
-	  *
557
-	  * @access public
558
-	  * @param EE_Line_Item $grand_total the grand total line item
559
-	  * @param EE_Ticket $ticket
560
-	  * @throws \EE_Error
561
-	  * @return EE_Line_Item
562
-	  */
554
+	 * Given the grand total line item and a ticket, finds the event sub-total
555
+	 * line item the ticket's purchase should be added onto
556
+	 *
557
+	 * @access public
558
+	 * @param EE_Line_Item $grand_total the grand total line item
559
+	 * @param EE_Ticket $ticket
560
+	 * @throws \EE_Error
561
+	 * @return EE_Line_Item
562
+	 */
563 563
 	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
564 564
 		$first_datetime = $ticket->first_datetime();
565 565
 		if ( ! $first_datetime instanceof EE_Datetime ) {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 		$add_to_existing_line_item = false
808 808
 	) {
809 809
 		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
810
-            $taxable_total = $total_line_item->taxable_total();
811
-
812
-            if( $add_to_existing_line_item ) {
813
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
814
-	            EEM_Line_Item::instance()->delete(
815
-		            array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
816
-	            );
817
-            } else {
818
-                $new_tax = null;
819
-                $tax_subtotal->delete_children_line_items();
820
-            }
821
-            if( $new_tax ) {
822
-                $new_tax->set_total( $new_tax->total() + $amount );
823
-                $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
824
-            } else {
825
-                //no existing tax item. Create it
810
+			$taxable_total = $total_line_item->taxable_total();
811
+
812
+			if( $add_to_existing_line_item ) {
813
+				$new_tax = $tax_subtotal->get_child_line_item( $code );
814
+				EEM_Line_Item::instance()->delete(
815
+					array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
816
+				);
817
+			} else {
818
+				$new_tax = null;
819
+				$tax_subtotal->delete_children_line_items();
820
+			}
821
+			if( $new_tax ) {
822
+				$new_tax->set_total( $new_tax->total() + $amount );
823
+				$new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
824
+			} else {
825
+				//no existing tax item. Create it
826 826
 				$new_tax = EE_Line_Item::new_instance( array(
827 827
 					'TXN_ID'      => $total_line_item->TXN_ID(),
828 828
 					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
@@ -835,16 +835,16 @@  discard block
 block discarded – undo
835 835
 				) );
836 836
 			}
837 837
 
838
-            $new_tax = apply_filters(
838
+			$new_tax = apply_filters(
839 839
 				'FHEE__EEH_Line_Item__set_total_tax_to__new_tax_subtotal',
840 840
 				$new_tax,
841 841
 				$total_line_item
842
-            );
843
-            $new_tax->save();
844
-            $tax_subtotal->set_total( $new_tax->total() );
845
-            $tax_subtotal->save();
846
-            $total_line_item->recalculate_total_including_taxes();
847
-            return $new_tax;
842
+			);
843
+			$new_tax->save();
844
+			$tax_subtotal->set_total( $new_tax->total() );
845
+			$tax_subtotal->save();
846
+			$total_line_item->recalculate_total_including_taxes();
847
+			return $new_tax;
848 848
 	}
849 849
 
850 850
 
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 			if ( $child_line_item instanceof EE_Line_Item ) {
991 991
 				if (
992 992
 					$child_line_item->type() === $line_item_type
993
-				    && (
993
+					&& (
994 994
 						$child_line_item->OBJ_type() === $obj_type || $obj_type === null
995 995
 					)
996 996
 				) {
Please login to merge, or discard this patch.
Spacing   +294 added lines, -294 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
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return boolean success
43 43
 	 * @throws \EE_Error
44 44
 	 */
45
-	public static function add_unrelated_item( EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL  ){
46
-		$items_subtotal = self::get_pre_tax_subtotal( $parent_line_item );
45
+	public static function add_unrelated_item(EE_Line_Item $parent_line_item, $name, $unit_price, $description = '', $quantity = 1, $taxable = FALSE, $code = NULL) {
46
+		$items_subtotal = self::get_pre_tax_subtotal($parent_line_item);
47 47
 		$line_item = EE_Line_Item::new_instance(array(
48 48
 			'LIN_name' => $name,
49 49
 			'LIN_desc' => $description,
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			'LIN_quantity' => $quantity,
52 52
 			'LIN_percent' => null,
53 53
 			'LIN_is_taxable' => $taxable,
54
-			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count( $items_subtotal->children() ) : 0,
54
+			'LIN_order' => $items_subtotal instanceof EE_Line_Item ? count($items_subtotal->children()) : 0,
55 55
 			'LIN_total' => (float) $unit_price * (int) $quantity,
56 56
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
57 57
 			'LIN_code' => $code,
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			$line_item,
62 62
 			$parent_line_item
63 63
 		);
64
-		return self::add_item( $parent_line_item, $line_item );
64
+		return self::add_item($parent_line_item, $line_item);
65 65
 	}
66 66
 
67 67
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return boolean success
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public static function add_percentage_based_item( EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE ){
86
+	public static function add_percentage_based_item(EE_Line_Item $parent_line_item, $name, $percentage_amount, $description = '', $taxable = FALSE) {
87 87
 		$line_item = EE_Line_Item::new_instance(array(
88 88
 			'LIN_name' => $name,
89 89
 			'LIN_desc' => $description,
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			'LIN_percent' => $percentage_amount,
92 92
 			'LIN_quantity' => NULL,
93 93
 			'LIN_is_taxable' => $taxable,
94
-			'LIN_total' => (float) ( $percentage_amount * ( $parent_line_item->total() / 100 ) ),
94
+			'LIN_total' => (float) ($percentage_amount * ($parent_line_item->total() / 100)),
95 95
 			'LIN_type'=>  EEM_Line_Item::type_line_item,
96 96
 			'LIN_parent' => $parent_line_item->ID()
97 97
 		));
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 			'FHEE__EEH_Line_Item__add_percentage_based_item__line_item',
100 100
 			$line_item
101 101
 		);
102
-		return self::add_item( $parent_line_item, $line_item );
102
+		return self::add_item($parent_line_item, $line_item);
103 103
 	}
104 104
 
105 105
 
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
 	 * @return \EE_Line_Item
121 121
 	 * @throws \EE_Error
122 122
 	 */
123
-	public static function add_ticket_purchase( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ){
124
-		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total() ) {
125
-			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() ) );
123
+	public static function add_ticket_purchase(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
124
+		if ( ! $total_line_item instanceof EE_Line_Item || ! $total_line_item->is_total()) {
125
+			throw new EE_Error(sprintf(__('A valid line item total is required in order to add tickets. A line item of type "%s" was passed.', 'event_espresso'), $ticket->ID(), $total_line_item->ID()));
126 126
 		}
127 127
 		// either increment the qty for an existing ticket
128
-		$line_item = self::increment_ticket_qty_if_already_in_cart( $total_line_item, $ticket, $qty );
128
+		$line_item = self::increment_ticket_qty_if_already_in_cart($total_line_item, $ticket, $qty);
129 129
 		// or add a new one
130
-		if ( ! $line_item instanceof EE_Line_Item ) {
131
-			$line_item = self::create_ticket_line_item( $total_line_item, $ticket, $qty );
130
+		if ( ! $line_item instanceof EE_Line_Item) {
131
+			$line_item = self::create_ticket_line_item($total_line_item, $ticket, $qty);
132 132
 		}
133 133
 		$total_line_item->recalculate_total_including_taxes();
134 134
 		return $line_item;
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	 * @return \EE_Line_Item
145 145
 	 * @throws \EE_Error
146 146
 	 */
147
-	public static function increment_ticket_qty_if_already_in_cart( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
147
+	public static function increment_ticket_qty_if_already_in_cart(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
148 148
 		$line_item = null;
149
-		if ( $total_line_item instanceof EE_Line_Item && $total_line_item->is_total() ) {
150
-			$ticket_line_items = EEH_Line_Item::get_ticket_line_items( $total_line_item );
151
-			foreach ( (array)$ticket_line_items as $ticket_line_item ) {
149
+		if ($total_line_item instanceof EE_Line_Item && $total_line_item->is_total()) {
150
+			$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
151
+			foreach ((array) $ticket_line_items as $ticket_line_item) {
152 152
 				if (
153 153
 					$ticket_line_item instanceof EE_Line_Item
154 154
 					&& (int) $ticket_line_item->OBJ_ID() === (int) $ticket->ID()
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 				}
159 159
 			}
160 160
 		}
161
-		if ( $line_item instanceof EE_Line_Item ) {
162
-			EEH_Line_Item::increment_quantity( $line_item, $qty );
161
+		if ($line_item instanceof EE_Line_Item) {
162
+			EEH_Line_Item::increment_quantity($line_item, $qty);
163 163
 			return $line_item;
164 164
 		}
165 165
 		return null;
@@ -176,16 +176,16 @@  discard block
 block discarded – undo
176 176
 	 * @return void
177 177
 	 * @throws \EE_Error
178 178
 	 */
179
-	public static function increment_quantity( EE_Line_Item $line_item, $qty = 1 ) {
180
-		if( ! $line_item->is_percent() ) {
179
+	public static function increment_quantity(EE_Line_Item $line_item, $qty = 1) {
180
+		if ( ! $line_item->is_percent()) {
181 181
 			$qty += $line_item->quantity();
182
-			$line_item->set_quantity( $qty );
183
-			$line_item->set_total( $line_item->unit_price() * $qty );
182
+			$line_item->set_quantity($qty);
183
+			$line_item->set_total($line_item->unit_price() * $qty);
184 184
 			$line_item->save();
185 185
 		}
186
-		foreach( $line_item->children() as $child ) {
187
-			if( $child->is_sub_line_item() ) {
188
-				EEH_Line_Item::update_quantity( $child, $qty );
186
+		foreach ($line_item->children() as $child) {
187
+			if ($child->is_sub_line_item()) {
188
+				EEH_Line_Item::update_quantity($child, $qty);
189 189
 			}
190 190
 		}
191 191
 	}
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 * @return void
202 202
 	 * @throws \EE_Error
203 203
 	 */
204
-	public static function decrement_quantity( EE_Line_Item $line_item, $qty = 1 ) {
205
-		if( ! $line_item->is_percent() ) {
204
+	public static function decrement_quantity(EE_Line_Item $line_item, $qty = 1) {
205
+		if ( ! $line_item->is_percent()) {
206 206
 			$qty = $line_item->quantity() - $qty;
207
-			$qty = max( $qty, 0 );
208
-			$line_item->set_quantity( $qty );
209
-			$line_item->set_total( $line_item->unit_price() * $qty );
207
+			$qty = max($qty, 0);
208
+			$line_item->set_quantity($qty);
209
+			$line_item->set_total($line_item->unit_price() * $qty);
210 210
 			$line_item->save();
211 211
 		}
212
-		foreach( $line_item->children() as $child ) {
213
-			if( $child->is_sub_line_item() ) {
214
-				EEH_Line_Item::update_quantity( $child, $qty );
212
+		foreach ($line_item->children() as $child) {
213
+			if ($child->is_sub_line_item()) {
214
+				EEH_Line_Item::update_quantity($child, $qty);
215 215
 			}
216 216
 		}
217 217
 	}
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
 	 * @param int          $new_quantity
227 227
 	 * @throws \EE_Error
228 228
 	 */
229
-	public static function update_quantity( EE_Line_Item $line_item, $new_quantity ) {
230
-		if( ! $line_item->is_percent() ) {
231
-			$line_item->set_quantity( $new_quantity );
232
-			$line_item->set_total( $line_item->unit_price() * $new_quantity );
229
+	public static function update_quantity(EE_Line_Item $line_item, $new_quantity) {
230
+		if ( ! $line_item->is_percent()) {
231
+			$line_item->set_quantity($new_quantity);
232
+			$line_item->set_total($line_item->unit_price() * $new_quantity);
233 233
 			$line_item->save();
234 234
 		}
235
-		foreach( $line_item->children() as $child ) {
236
-			if( $child->is_sub_line_item() ) {
237
-				EEH_Line_Item::update_quantity( $child, $new_quantity );
235
+		foreach ($line_item->children() as $child) {
236
+			if ($child->is_sub_line_item()) {
237
+				EEH_Line_Item::update_quantity($child, $new_quantity);
238 238
 			}
239 239
 		}
240 240
 	}
@@ -249,44 +249,44 @@  discard block
 block discarded – undo
249 249
 	 * @return \EE_Line_Item
250 250
 	 * @throws \EE_Error
251 251
 	 */
252
-	public static function create_ticket_line_item( EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1 ) {
252
+	public static function create_ticket_line_item(EE_Line_Item $total_line_item, EE_Ticket $ticket, $qty = 1) {
253 253
 		$datetimes = $ticket->datetimes();
254
-		$first_datetime = reset( $datetimes );
255
-		if( $first_datetime instanceof EE_Datetime &&
256
-				$first_datetime->event() instanceof EE_Event ) {
254
+		$first_datetime = reset($datetimes);
255
+		if ($first_datetime instanceof EE_Datetime &&
256
+				$first_datetime->event() instanceof EE_Event) {
257 257
 			$first_datetime_name = $first_datetime->event()->name();
258 258
 		} else {
259
-			$first_datetime_name = __( 'Event', 'event_espresso' );
259
+			$first_datetime_name = __('Event', 'event_espresso');
260 260
 		}
261
-		$event = sprintf( _x( '(For %1$s)', '(For Event Name)', 'event_espresso' ), $first_datetime_name );
261
+		$event = sprintf(_x('(For %1$s)', '(For Event Name)', 'event_espresso'), $first_datetime_name);
262 262
 		// get event subtotal line
263
-		$events_sub_total = self::get_event_line_item_for_ticket( $total_line_item, $ticket );
263
+		$events_sub_total = self::get_event_line_item_for_ticket($total_line_item, $ticket);
264 264
 		// add $ticket to cart
265
-		$line_item = EE_Line_Item::new_instance( array(
265
+		$line_item = EE_Line_Item::new_instance(array(
266 266
 			'LIN_name'       	=> $ticket->name(),
267
-			'LIN_desc'       		=> $ticket->description() !== '' ? $ticket->description() . ' ' . $event : $event,
267
+			'LIN_desc'       		=> $ticket->description() !== '' ? $ticket->description().' '.$event : $event,
268 268
 			'LIN_unit_price' 	=> $ticket->price(),
269 269
 			'LIN_quantity'   	=> $qty,
270 270
 			'LIN_is_taxable' 	=> $ticket->taxable(),
271
-			'LIN_order'      	=> count( $events_sub_total->children() ),
271
+			'LIN_order'      	=> count($events_sub_total->children()),
272 272
 			'LIN_total'      		=> $ticket->price() * $qty,
273 273
 			'LIN_type'       		=> EEM_Line_Item::type_line_item,
274 274
 			'OBJ_ID'         		=> $ticket->ID(),
275 275
 			'OBJ_type'       	=> 'Ticket'
276
-		) );
276
+		));
277 277
 		$line_item = apply_filters(
278 278
 			'FHEE__EEH_Line_Item__create_ticket_line_item__line_item',
279 279
 			$line_item
280 280
 		);
281
-		$events_sub_total->add_child_line_item( $line_item );
281
+		$events_sub_total->add_child_line_item($line_item);
282 282
 		//now add the sub-line items
283 283
 		$running_total_for_ticket = 0;
284
-		foreach ( $ticket->prices( array( 'order_by' => array( 'PRC_order' => 'ASC' ) ) ) as $price ) {
284
+		foreach ($ticket->prices(array('order_by' => array('PRC_order' => 'ASC'))) as $price) {
285 285
 			$sign = $price->is_discount() ? -1 : 1;
286 286
 			$price_total = $price->is_percent()
287 287
 				? $running_total_for_ticket * $price->amount() / 100
288 288
 				: $price->amount() * $qty;
289
-			$sub_line_item = EE_Line_Item::new_instance( array(
289
+			$sub_line_item = EE_Line_Item::new_instance(array(
290 290
 				'LIN_name'       	=> $price->name(),
291 291
 				'LIN_desc'       		=> $price->desc(),
292 292
 				'LIN_quantity'   	=> $price->is_percent() ? null : $qty,
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 				'LIN_type'       		=> EEM_Line_Item::type_sub_line_item,
297 297
 				'OBJ_ID'         		=> $price->ID(),
298 298
 				'OBJ_type'       	=> 'Price'
299
-			) );
299
+			));
300 300
 			$sub_line_item = apply_filters(
301 301
 				'FHEE__EEH_Line_Item__create_ticket_line_item__sub_line_item',
302 302
 				$sub_line_item
303 303
 			);
304
-			if ( $price->is_percent() ) {
305
-				$sub_line_item->set_percent( $sign * $price->amount() );
304
+			if ($price->is_percent()) {
305
+				$sub_line_item->set_percent($sign * $price->amount());
306 306
 			} else {
307
-				$sub_line_item->set_unit_price( $sign * $price->amount() );
307
+				$sub_line_item->set_unit_price($sign * $price->amount());
308 308
 			}
309 309
 			$running_total_for_ticket += $price_total;
310
-			$line_item->add_child_line_item( $sub_line_item );
310
+			$line_item->add_child_line_item($sub_line_item);
311 311
 		}
312 312
 		return $line_item;
313 313
 	}
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	 * @return boolean
328 328
 	 * @throws \EE_Error
329 329
 	 */
330
-	public static function add_item( EE_Line_Item $total_line_item, EE_Line_Item $item ){
331
-		$pre_tax_subtotal = self::get_pre_tax_subtotal( $total_line_item );
332
-		if ( $pre_tax_subtotal instanceof EE_Line_Item ){
330
+	public static function add_item(EE_Line_Item $total_line_item, EE_Line_Item $item) {
331
+		$pre_tax_subtotal = self::get_pre_tax_subtotal($total_line_item);
332
+		if ($pre_tax_subtotal instanceof EE_Line_Item) {
333 333
 			$success = $pre_tax_subtotal->add_child_line_item($item);
334
-		}else{
334
+		} else {
335 335
 			return FALSE;
336 336
 		}
337 337
 		$total_line_item->recalculate_total_including_taxes();
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 	 * @return \EE_Line_Item
348 348
 	 * @throws \EE_Error
349 349
 	 */
350
-	public static function get_pre_tax_subtotal( EE_Line_Item $total_line_item ){
351
-		$pre_tax_subtotal = $total_line_item->get_child_line_item( 'pre-tax-subtotal' );
350
+	public static function get_pre_tax_subtotal(EE_Line_Item $total_line_item) {
351
+		$pre_tax_subtotal = $total_line_item->get_child_line_item('pre-tax-subtotal');
352 352
 		return $pre_tax_subtotal instanceof EE_Line_Item
353 353
 			? $pre_tax_subtotal
354
-			: self::create_pre_tax_subtotal( $total_line_item );
354
+			: self::create_pre_tax_subtotal($total_line_item);
355 355
 	}
356 356
 
357 357
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 * @return \EE_Line_Item
364 364
 	 * @throws \EE_Error
365 365
 	 */
366
-	public static function get_taxes_subtotal( EE_Line_Item $total_line_item ){
367
-		$taxes = $total_line_item->get_child_line_item( 'taxes' );
368
-		return $taxes ? $taxes : self::create_taxes_subtotal( $total_line_item );
366
+	public static function get_taxes_subtotal(EE_Line_Item $total_line_item) {
367
+		$taxes = $total_line_item->get_child_line_item('taxes');
368
+		return $taxes ? $taxes : self::create_taxes_subtotal($total_line_item);
369 369
 	}
370 370
 
371 371
 
@@ -378,12 +378,12 @@  discard block
 block discarded – undo
378 378
 	 * @return void
379 379
 	 * @throws \EE_Error
380 380
 	 */
381
-	public static function set_TXN_ID( EE_Line_Item $line_item, $transaction = NULL ){
382
-		if( $transaction ){
381
+	public static function set_TXN_ID(EE_Line_Item $line_item, $transaction = NULL) {
382
+		if ($transaction) {
383 383
 			/** @type EEM_Transaction $EEM_Transaction */
384
-			$EEM_Transaction = EE_Registry::instance()->load_model( 'Transaction' );
385
-			$TXN_ID = $EEM_Transaction->ensure_is_ID( $transaction );
386
-			$line_item->set_TXN_ID( $TXN_ID );
384
+			$EEM_Transaction = EE_Registry::instance()->load_model('Transaction');
385
+			$TXN_ID = $EEM_Transaction->ensure_is_ID($transaction);
386
+			$line_item->set_TXN_ID($TXN_ID);
387 387
 		}
388 388
 	}
389 389
 
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @return \EE_Line_Item of type total
399 399
 	 * @throws \EE_Error
400 400
 	 */
401
-	public static function create_total_line_item( $transaction = NULL ){
402
-		$total_line_item = EE_Line_Item::new_instance( array(
401
+	public static function create_total_line_item($transaction = NULL) {
402
+		$total_line_item = EE_Line_Item::new_instance(array(
403 403
 			'LIN_code'	=> 'total',
404 404
 			'LIN_name'	=> __('Grand Total', 'event_espresso'),
405 405
 			'LIN_type'	=> EEM_Line_Item::type_total,
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 			'FHEE__EEH_Line_Item__create_total_line_item__total_line_item',
410 410
 			$total_line_item
411 411
 		);
412
-		self::set_TXN_ID( $total_line_item, $transaction );
413
-		self::create_pre_tax_subtotal( $total_line_item, $transaction );
414
-		self::create_taxes_subtotal( $total_line_item, $transaction );
412
+		self::set_TXN_ID($total_line_item, $transaction);
413
+		self::create_pre_tax_subtotal($total_line_item, $transaction);
414
+		self::create_taxes_subtotal($total_line_item, $transaction);
415 415
 		return $total_line_item;
416 416
 	}
417 417
 
@@ -425,19 +425,19 @@  discard block
 block discarded – undo
425 425
 	 * @return EE_Line_Item
426 426
 	 * @throws \EE_Error
427 427
 	 */
428
-	protected static function create_pre_tax_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
429
-		$pre_tax_line_item = EE_Line_Item::new_instance( array(
428
+	protected static function create_pre_tax_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
429
+		$pre_tax_line_item = EE_Line_Item::new_instance(array(
430 430
 			'LIN_code' 	=> 'pre-tax-subtotal',
431
-			'LIN_name' 	=> __( 'Pre-Tax Subtotal', 'event_espresso' ),
431
+			'LIN_name' 	=> __('Pre-Tax Subtotal', 'event_espresso'),
432 432
 			'LIN_type' 	=> EEM_Line_Item::type_sub_total
433
-		) );
433
+		));
434 434
 		$pre_tax_line_item = apply_filters(
435 435
 			'FHEE__EEH_Line_Item__create_pre_tax_subtotal__pre_tax_line_item',
436 436
 			$pre_tax_line_item
437 437
 		);
438
-		self::set_TXN_ID( $pre_tax_line_item, $transaction );
439
-		$total_line_item->add_child_line_item( $pre_tax_line_item );
440
-		self::create_event_subtotal( $pre_tax_line_item, $transaction );
438
+		self::set_TXN_ID($pre_tax_line_item, $transaction);
439
+		$total_line_item->add_child_line_item($pre_tax_line_item);
440
+		self::create_event_subtotal($pre_tax_line_item, $transaction);
441 441
 		return $pre_tax_line_item;
442 442
 	}
443 443
 
@@ -452,21 +452,21 @@  discard block
 block discarded – undo
452 452
 	 * @return EE_Line_Item
453 453
 	 * @throws \EE_Error
454 454
 	 */
455
-	protected static function create_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL ){
455
+	protected static function create_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
456 456
 		$tax_line_item = EE_Line_Item::new_instance(array(
457 457
 			'LIN_code'	=> 'taxes',
458 458
 			'LIN_name' 	=> __('Taxes', 'event_espresso'),
459 459
 			'LIN_type'	=> EEM_Line_Item::type_tax_sub_total,
460
-			'LIN_order' => 1000,//this should always come last
460
+			'LIN_order' => 1000, //this should always come last
461 461
 		));
462 462
 		$tax_line_item = apply_filters(
463 463
 			'FHEE__EEH_Line_Item__create_taxes_subtotal__tax_line_item',
464 464
 			$tax_line_item
465 465
 		);
466
-		self::set_TXN_ID( $tax_line_item, $transaction );
467
-		$total_line_item->add_child_line_item( $tax_line_item );
466
+		self::set_TXN_ID($tax_line_item, $transaction);
467
+		$total_line_item->add_child_line_item($tax_line_item);
468 468
 		//and lastly, add the actual taxes
469
-		self::apply_taxes( $total_line_item );
469
+		self::apply_taxes($total_line_item);
470 470
 		return $tax_line_item;
471 471
 	}
472 472
 
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
 	 * @return EE_Line_Item
482 482
 	 * @throws \EE_Error
483 483
 	 */
484
-	public static function create_event_subtotal( EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL ){
484
+	public static function create_event_subtotal(EE_Line_Item $pre_tax_line_item, $transaction = NULL, $event = NULL) {
485 485
 		$event_line_item = EE_Line_Item::new_instance(array(
486
-			'LIN_code'	=> self::get_event_code( $event ),
487
-			'LIN_name' 	=> self::get_event_name( $event ),
488
-			'LIN_desc' 	=> self::get_event_desc( $event ),
486
+			'LIN_code'	=> self::get_event_code($event),
487
+			'LIN_name' 	=> self::get_event_name($event),
488
+			'LIN_desc' 	=> self::get_event_desc($event),
489 489
 			'LIN_type'	=> EEM_Line_Item::type_sub_total,
490 490
 			'OBJ_type' 	=> 'Event',
491 491
 			'OBJ_ID' 		=>  $event instanceof EE_Event ? $event->ID() : 0
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 			'FHEE__EEH_Line_Item__create_event_subtotal__event_line_item',
495 495
 			$event_line_item
496 496
 		);
497
-		self::set_TXN_ID( $event_line_item, $transaction );
498
-		$pre_tax_line_item->add_child_line_item( $event_line_item );
497
+		self::set_TXN_ID($event_line_item, $transaction);
498
+		$pre_tax_line_item->add_child_line_item($event_line_item);
499 499
 		return $event_line_item;
500 500
 	}
501 501
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	 * @return string
509 509
 	 * @throws \EE_Error
510 510
 	 */
511
-	public static function get_event_code( $event ) {
512
-		return 'event-' . ( $event instanceof EE_Event ? $event->ID() : '0' );
511
+	public static function get_event_code($event) {
512
+		return 'event-'.($event instanceof EE_Event ? $event->ID() : '0');
513 513
 	}
514 514
 
515 515
 	/**
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @param EE_Event $event
518 518
 	 * @return string
519 519
 	 */
520
-	public static function get_event_name( $event ) {
521
-		return $event instanceof EE_Event ? $event->name() : __( 'Event', 'event_espresso' );
520
+	public static function get_event_name($event) {
521
+		return $event instanceof EE_Event ? $event->name() : __('Event', 'event_espresso');
522 522
 	}
523 523
 
524 524
 	/**
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	 * @param EE_Event $event
527 527
 	 * @return string
528 528
 	 */
529
-	public static function get_event_desc( $event ) {
529
+	public static function get_event_desc($event) {
530 530
 		return $event instanceof EE_Event ? $event->short_description() : '';
531 531
 	}
532 532
 
@@ -540,27 +540,27 @@  discard block
 block discarded – undo
540 540
 	  * @throws \EE_Error
541 541
 	  * @return EE_Line_Item
542 542
 	  */
543
-	public static function get_event_line_item_for_ticket( EE_Line_Item $grand_total, EE_Ticket $ticket ) {
543
+	public static function get_event_line_item_for_ticket(EE_Line_Item $grand_total, EE_Ticket $ticket) {
544 544
 		$first_datetime = $ticket->first_datetime();
545
-		if ( ! $first_datetime instanceof EE_Datetime ) {
545
+		if ( ! $first_datetime instanceof EE_Datetime) {
546 546
 			throw new EE_Error(
547
-				sprintf( __( 'The supplied ticket (ID %d) has no datetimes', 'event_espresso' ), $ticket->ID() )
547
+				sprintf(__('The supplied ticket (ID %d) has no datetimes', 'event_espresso'), $ticket->ID())
548 548
 			);
549 549
 		}
550 550
 		$event = $first_datetime->event();
551
-		if ( ! $event instanceof EE_Event ) {
551
+		if ( ! $event instanceof EE_Event) {
552 552
 			throw new EE_Error(
553 553
 				sprintf(
554
-					__( 'The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso' ),
554
+					__('The supplied ticket (ID %d) has no event data associated with it.', 'event_espresso'),
555 555
 					$ticket->ID()
556 556
 				)
557 557
 			);
558 558
 		}
559
-		$events_sub_total = EEH_Line_Item::get_event_line_item( $grand_total, $event );
560
-		if ( ! $events_sub_total instanceof EE_Line_Item ) {
559
+		$events_sub_total = EEH_Line_Item::get_event_line_item($grand_total, $event);
560
+		if ( ! $events_sub_total instanceof EE_Line_Item) {
561 561
 			throw new EE_Error(
562 562
 				sprintf(
563
-					__( 'There is no events sub-total for ticket %s on total line item %d', 'event_espresso' ),
563
+					__('There is no events sub-total for ticket %s on total line item %d', 'event_espresso'),
564 564
 					$ticket->ID(),
565 565
 					$grand_total->ID()
566 566
 				)
@@ -579,31 +579,31 @@  discard block
 block discarded – undo
579 579
 	 * @return EE_Line_Item for the event subtotal which is a child of $grand_total
580 580
 	 * @throws \EE_Error
581 581
 	 */
582
-	public static function get_event_line_item( EE_Line_Item $grand_total, $event ) {
582
+	public static function get_event_line_item(EE_Line_Item $grand_total, $event) {
583 583
 		/** @type EE_Event $event */
584
-		$event = EEM_Event::instance()->ensure_is_obj( $event, true );
584
+		$event = EEM_Event::instance()->ensure_is_obj($event, true);
585 585
 		$event_line_item = NULL;
586 586
 		$found = false;
587
-		foreach ( EEH_Line_Item::get_event_subtotals( $grand_total ) as $event_line_item ) {
587
+		foreach (EEH_Line_Item::get_event_subtotals($grand_total) as $event_line_item) {
588 588
 			// default event subtotal, we should only ever find this the first time this method is called
589
-			if ( ! $event_line_item->OBJ_ID() ) {
589
+			if ( ! $event_line_item->OBJ_ID()) {
590 590
 				// let's use this! but first... set the event details
591
-				EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
591
+				EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
592 592
 				$found = true;
593 593
 				break;
594
-			} else if ( $event_line_item->OBJ_ID() === $event->ID() ) {
594
+			} else if ($event_line_item->OBJ_ID() === $event->ID()) {
595 595
 				// found existing line item for this event in the cart, so break out of loop and use this one
596 596
 				$found = true;
597 597
 				break;
598 598
 			}
599 599
 		}
600
-		if ( ! $found ) {
600
+		if ( ! $found) {
601 601
 			//there is no event sub-total yet, so add it
602
-			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal( $grand_total );
602
+			$pre_tax_subtotal = EEH_Line_Item::get_pre_tax_subtotal($grand_total);
603 603
 			// create a new "event" subtotal below that
604
-			$event_line_item = EEH_Line_Item::create_event_subtotal( $pre_tax_subtotal, null, $event );
604
+			$event_line_item = EEH_Line_Item::create_event_subtotal($pre_tax_subtotal, null, $event);
605 605
 			// and set the event details
606
-			EEH_Line_Item::set_event_subtotal_details( $event_line_item, $event );
606
+			EEH_Line_Item::set_event_subtotal_details($event_line_item, $event);
607 607
 		}
608 608
 		return $event_line_item;
609 609
 	}
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 		EE_Event $event,
625 625
 		$transaction = null
626 626
 	) {
627
-		if ( $event instanceof EE_Event ) {
628
-			$event_line_item->set_code( self::get_event_code( $event ) );
629
-			$event_line_item->set_name( self::get_event_name( $event ) );
630
-			$event_line_item->set_desc( self::get_event_desc( $event ) );
631
-			$event_line_item->set_OBJ_ID( $event->ID() );
627
+		if ($event instanceof EE_Event) {
628
+			$event_line_item->set_code(self::get_event_code($event));
629
+			$event_line_item->set_name(self::get_event_name($event));
630
+			$event_line_item->set_desc(self::get_event_desc($event));
631
+			$event_line_item->set_OBJ_ID($event->ID());
632 632
 		}
633
-		self::set_TXN_ID( $event_line_item, $transaction );
633
+		self::set_TXN_ID($event_line_item, $transaction);
634 634
 	}
635 635
 
636 636
 
@@ -643,19 +643,19 @@  discard block
 block discarded – undo
643 643
 	 * @param EE_Line_Item $total_line_item of type EEM_Line_Item::type_total
644 644
 	 * @throws \EE_Error
645 645
 	 */
646
-	public static function apply_taxes( EE_Line_Item $total_line_item ){
646
+	public static function apply_taxes(EE_Line_Item $total_line_item) {
647 647
 		/** @type EEM_Price $EEM_Price */
648
-		$EEM_Price = EE_Registry::instance()->load_model( 'Price' );
648
+		$EEM_Price = EE_Registry::instance()->load_model('Price');
649 649
 		// get array of taxes via Price Model
650 650
 		$ordered_taxes = $EEM_Price->get_all_prices_that_are_taxes();
651
-		ksort( $ordered_taxes );
652
-		$taxes_line_item = self::get_taxes_subtotal( $total_line_item );
651
+		ksort($ordered_taxes);
652
+		$taxes_line_item = self::get_taxes_subtotal($total_line_item);
653 653
 		//just to be safe, remove its old tax line items
654 654
 		$taxes_line_item->delete_children_line_items();
655 655
 		//loop thru taxes
656
-		foreach ( $ordered_taxes as $order => $taxes ) {
657
-			foreach ( $taxes as $tax ) {
658
-				if ( $tax instanceof EE_Price ) {
656
+		foreach ($ordered_taxes as $order => $taxes) {
657
+			foreach ($taxes as $tax) {
658
+				if ($tax instanceof EE_Price) {
659 659
 					$tax_line_item = EE_Line_Item::new_instance(
660 660
 						array(
661 661
 							'LIN_name'       => $tax->name(),
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 						'FHEE__EEH_Line_Item__apply_taxes__tax_line_item',
674 674
 						$tax_line_item
675 675
 					);
676
-					$taxes_line_item->add_child_line_item( $tax_line_item );
676
+					$taxes_line_item->add_child_line_item($tax_line_item);
677 677
 				}
678 678
 			}
679 679
 		}
@@ -690,10 +690,10 @@  discard block
 block discarded – undo
690 690
 	 * @return float
691 691
 	 * @throws \EE_Error
692 692
 	 */
693
-	public static function ensure_taxes_applied( $total_line_item ){
694
-		$taxes_subtotal = self::get_taxes_subtotal( $total_line_item );
695
-		if( ! $taxes_subtotal->children()){
696
-			self::apply_taxes( $total_line_item );
693
+	public static function ensure_taxes_applied($total_line_item) {
694
+		$taxes_subtotal = self::get_taxes_subtotal($total_line_item);
695
+		if ( ! $taxes_subtotal->children()) {
696
+			self::apply_taxes($total_line_item);
697 697
 		}
698 698
 		return $taxes_subtotal->total();
699 699
 	}
@@ -707,16 +707,16 @@  discard block
 block discarded – undo
707 707
 	 * @return bool
708 708
 	 * @throws \EE_Error
709 709
 	 */
710
-	public static function delete_all_child_items( EE_Line_Item $parent_line_item ) {
710
+	public static function delete_all_child_items(EE_Line_Item $parent_line_item) {
711 711
 		$deleted = 0;
712
-		foreach ( $parent_line_item->children() as $child_line_item ) {
713
-			if ( $child_line_item instanceof EE_Line_Item ) {
714
-				$deleted += EEH_Line_Item::delete_all_child_items( $child_line_item );
715
-				if ( $child_line_item->ID() ) {
712
+		foreach ($parent_line_item->children() as $child_line_item) {
713
+			if ($child_line_item instanceof EE_Line_Item) {
714
+				$deleted += EEH_Line_Item::delete_all_child_items($child_line_item);
715
+				if ($child_line_item->ID()) {
716 716
 					$child_line_item->delete();
717
-					unset( $child_line_item );
717
+					unset($child_line_item);
718 718
 				} else {
719
-					$parent_line_item->delete_child_line_item( $child_line_item->code() );
719
+					$parent_line_item->delete_child_line_item($child_line_item->code());
720 720
 				}
721 721
 				$deleted++;
722 722
 			}
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
 	 * @param array|bool|string $line_item_codes
739 739
 	 * @return int number of items successfully removed
740 740
 	 */
741
-	public static function delete_items( EE_Line_Item $total_line_item, $line_item_codes = FALSE ) {
741
+	public static function delete_items(EE_Line_Item $total_line_item, $line_item_codes = FALSE) {
742 742
 
743
-		if( $total_line_item->type() !== EEM_Line_Item::type_total ){
743
+		if ($total_line_item->type() !== EEM_Line_Item::type_total) {
744 744
 			EE_Error::doing_it_wrong(
745 745
 				'EEH_Line_Item::delete_items',
746 746
 				__(
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
 				'4.6.18'
751 751
 			);
752 752
 		}
753
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
753
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
754 754
 
755 755
 		// check if only a single line_item_id was passed
756
-		if ( ! empty( $line_item_codes ) && ! is_array( $line_item_codes )) {
756
+		if ( ! empty($line_item_codes) && ! is_array($line_item_codes)) {
757 757
 			// place single line_item_id in an array to appear as multiple line_item_ids
758
-			$line_item_codes = array ( $line_item_codes );
758
+			$line_item_codes = array($line_item_codes);
759 759
 		}
760 760
 		$removals = 0;
761 761
 		// cycle thru line_item_ids
762
-		foreach ( $line_item_codes as $line_item_id ) {
762
+		foreach ($line_item_codes as $line_item_id) {
763 763
 			$removals += $total_line_item->delete_child_line_item($line_item_id);
764 764
 		}
765 765
 
766
-		if ( $removals > 0 ) {
766
+		if ($removals > 0) {
767 767
 			$total_line_item->recalculate_taxes_and_tax_total();
768 768
 			return $removals;
769 769
 		} else {
@@ -796,33 +796,33 @@  discard block
 block discarded – undo
796 796
 		$code = null,
797 797
 		$add_to_existing_line_item = false
798 798
 	) {
799
-		$tax_subtotal = self::get_taxes_subtotal( $total_line_item );
799
+		$tax_subtotal = self::get_taxes_subtotal($total_line_item);
800 800
             $taxable_total = $total_line_item->taxable_total();
801 801
 
802
-            if( $add_to_existing_line_item ) {
803
-                $new_tax = $tax_subtotal->get_child_line_item( $code );
802
+            if ($add_to_existing_line_item) {
803
+                $new_tax = $tax_subtotal->get_child_line_item($code);
804 804
 	            EEM_Line_Item::instance()->delete(
805
-		            array( array( 'LIN_code' => array( '!=', $code ), 'LIN_parent' => $tax_subtotal->ID() ) )
805
+		            array(array('LIN_code' => array('!=', $code), 'LIN_parent' => $tax_subtotal->ID()))
806 806
 	            );
807 807
             } else {
808 808
                 $new_tax = null;
809 809
                 $tax_subtotal->delete_children_line_items();
810 810
             }
811
-            if( $new_tax ) {
812
-                $new_tax->set_total( $new_tax->total() + $amount );
813
-                $new_tax->set_percent( $taxable_total ? $new_tax->total() / $taxable_total * 100 : 0 );
811
+            if ($new_tax) {
812
+                $new_tax->set_total($new_tax->total() + $amount);
813
+                $new_tax->set_percent($taxable_total ? $new_tax->total() / $taxable_total * 100 : 0);
814 814
             } else {
815 815
                 //no existing tax item. Create it
816
-				$new_tax = EE_Line_Item::new_instance( array(
816
+				$new_tax = EE_Line_Item::new_instance(array(
817 817
 					'TXN_ID'      => $total_line_item->TXN_ID(),
818
-					'LIN_name'    => $name ? $name : __( 'Tax', 'event_espresso' ),
818
+					'LIN_name'    => $name ? $name : __('Tax', 'event_espresso'),
819 819
 					'LIN_desc'    => $description ? $description : '',
820
-					'LIN_percent' => $taxable_total ? ( $amount / $taxable_total * 100 ) : 0,
820
+					'LIN_percent' => $taxable_total ? ($amount / $taxable_total * 100) : 0,
821 821
 					'LIN_total'   => $amount,
822 822
 					'LIN_parent'  => $tax_subtotal->ID(),
823 823
 					'LIN_type'    => EEM_Line_Item::type_tax,
824 824
 					'LIN_code'    => $code
825
-				) );
825
+				));
826 826
 			}
827 827
 
828 828
             $new_tax = apply_filters(
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 				$total_line_item
832 832
             );
833 833
             $new_tax->save();
834
-            $tax_subtotal->set_total( $new_tax->total() );
834
+            $tax_subtotal->set_total($new_tax->total());
835 835
             $tax_subtotal->save();
836 836
             $total_line_item->recalculate_total_including_taxes();
837 837
             return $new_tax;
@@ -853,14 +853,14 @@  discard block
 block discarded – undo
853 853
 		$code_substring_for_whitelist = null
854 854
 	) {
855 855
 		$whitelisted = false;
856
-		if( $code_substring_for_whitelist !== null ) {
857
-			$whitelisted = strpos( $line_item->code(), $code_substring_for_whitelist ) !== false ? true : false;
856
+		if ($code_substring_for_whitelist !== null) {
857
+			$whitelisted = strpos($line_item->code(), $code_substring_for_whitelist) !== false ? true : false;
858 858
 		}
859
-		if( ! $whitelisted && $line_item->is_line_item() ) {
860
-			$line_item->set_is_taxable( $taxable );
859
+		if ( ! $whitelisted && $line_item->is_line_item()) {
860
+			$line_item->set_is_taxable($taxable);
861 861
 		}
862
-		foreach( $line_item->children() as $child_line_item ) {
863
-			EEH_Line_Item::set_line_items_taxable( $child_line_item, $taxable, $code_substring_for_whitelist );
862
+		foreach ($line_item->children() as $child_line_item) {
863
+			EEH_Line_Item::set_line_items_taxable($child_line_item, $taxable, $code_substring_for_whitelist);
864 864
 		}
865 865
 	}
866 866
 
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
874 874
 	 * @return EE_Line_Item[]
875 875
 	 */
876
-	public static function get_event_subtotals( EE_Line_Item $parent_line_item ) {
877
-		return self::get_subtotals_of_object_type( $parent_line_item, 'Event' );
876
+	public static function get_event_subtotals(EE_Line_Item $parent_line_item) {
877
+		return self::get_subtotals_of_object_type($parent_line_item, 'Event');
878 878
 	}
879 879
 
880 880
 
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @param string $obj_type
888 888
 	 * @return EE_Line_Item[]
889 889
 	 */
890
-	public static function get_subtotals_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
890
+	public static function get_subtotals_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
891 891
 		return self::_get_descendants_by_type_and_object_type(
892 892
 			$parent_line_item,
893 893
 			EEM_Line_Item::type_sub_total,
@@ -904,8 +904,8 @@  discard block
 block discarded – undo
904 904
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
905 905
 	 * @return EE_Line_Item[]
906 906
 	 */
907
-	public static function get_ticket_line_items( EE_Line_Item $parent_line_item ) {
908
-		return self::get_line_items_of_object_type( $parent_line_item, 'Ticket' );
907
+	public static function get_ticket_line_items(EE_Line_Item $parent_line_item) {
908
+		return self::get_line_items_of_object_type($parent_line_item, 'Ticket');
909 909
 	}
910 910
 
911 911
 
@@ -918,8 +918,8 @@  discard block
 block discarded – undo
918 918
 	 * @param string $obj_type
919 919
 	 * @return EE_Line_Item[]
920 920
 	 */
921
-	public static function get_line_items_of_object_type( EE_Line_Item $parent_line_item, $obj_type = '' ) {
922
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, EEM_Line_Item::type_line_item, $obj_type );
921
+	public static function get_line_items_of_object_type(EE_Line_Item $parent_line_item, $obj_type = '') {
922
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, EEM_Line_Item::type_line_item, $obj_type);
923 923
 	}
924 924
 
925 925
 
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
931 931
 	 * @return EE_Line_Item[]
932 932
 	 */
933
-	public static function get_tax_descendants( EE_Line_Item $parent_line_item ) {
934
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_tax );
933
+	public static function get_tax_descendants(EE_Line_Item $parent_line_item) {
934
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_tax);
935 935
 	}
936 936
 
937 937
 
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 * @param \EE_Line_Item $parent_line_item - the line item to find descendants of
943 943
 	 * @return EE_Line_Item[]
944 944
 	 */
945
-	public static function get_line_item_descendants( EE_Line_Item $parent_line_item ) {
946
-		return EEH_Line_Item::get_descendants_of_type( $parent_line_item, EEM_Line_Item::type_line_item );
945
+	public static function get_line_item_descendants(EE_Line_Item $parent_line_item) {
946
+		return EEH_Line_Item::get_descendants_of_type($parent_line_item, EEM_Line_Item::type_line_item);
947 947
 	}
948 948
 
949 949
 
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
 	 * @param string $line_item_type one of the EEM_Line_Item constants
957 957
 	 * @return EE_Line_Item[]
958 958
 	 */
959
-	public static function get_descendants_of_type( EE_Line_Item $parent_line_item, $line_item_type ) {
960
-		return self::_get_descendants_by_type_and_object_type( $parent_line_item, $line_item_type, NULL );
959
+	public static function get_descendants_of_type(EE_Line_Item $parent_line_item, $line_item_type) {
960
+		return self::_get_descendants_by_type_and_object_type($parent_line_item, $line_item_type, NULL);
961 961
 	}
962 962
 
963 963
 
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 		$obj_type = null
977 977
 	) {
978 978
 		$objects = array();
979
-		foreach ( $parent_line_item->children() as $child_line_item ) {
980
-			if ( $child_line_item instanceof EE_Line_Item ) {
979
+		foreach ($parent_line_item->children() as $child_line_item) {
980
+			if ($child_line_item instanceof EE_Line_Item) {
981 981
 				if (
982 982
 					$child_line_item->type() === $line_item_type
983 983
 				    && (
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 		$OBJ_type = '',
1018 1018
 		$OBJ_IDs = array()
1019 1019
 	) {
1020
-		return self::_get_descendants_by_object_type_and_object_ID( $parent_line_item, $OBJ_type, $OBJ_IDs );
1020
+		return self::_get_descendants_by_object_type_and_object_ID($parent_line_item, $OBJ_type, $OBJ_IDs);
1021 1021
 	}
1022 1022
 
1023 1023
 
@@ -1036,12 +1036,12 @@  discard block
 block discarded – undo
1036 1036
 		$OBJ_IDs
1037 1037
 	) {
1038 1038
 		$objects = array();
1039
-		foreach ( $parent_line_item->children() as $child_line_item ) {
1040
-			if ( $child_line_item instanceof EE_Line_Item ) {
1039
+		foreach ($parent_line_item->children() as $child_line_item) {
1040
+			if ($child_line_item instanceof EE_Line_Item) {
1041 1041
 				if (
1042
-					is_array( $OBJ_IDs )
1042
+					is_array($OBJ_IDs)
1043 1043
 					&& $child_line_item->OBJ_type() === $OBJ_type
1044
-					&& in_array( $child_line_item->OBJ_ID(), $OBJ_IDs )
1044
+					&& in_array($child_line_item->OBJ_ID(), $OBJ_IDs)
1045 1045
 				) {
1046 1046
 					$objects[] = $child_line_item;
1047 1047
 				} else {
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 	 * @param string $type like one of the EEM_Line_Item::type_*
1072 1072
 	 * @return EE_Line_Item
1073 1073
 	 */
1074
-	public static function get_nearest_descendant_of_type( EE_Line_Item $parent_line_item, $type ) {
1075
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_type' , $type );
1074
+	public static function get_nearest_descendant_of_type(EE_Line_Item $parent_line_item, $type) {
1075
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_type', $type);
1076 1076
 	}
1077 1077
 
1078 1078
 
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
 	 * @param string $code any value used for LIN_code
1087 1087
 	 * @return EE_Line_Item
1088 1088
 	 */
1089
-	public static function get_nearest_descendant_having_code( EE_Line_Item $parent_line_item, $code ) {
1090
-		return self::_get_nearest_descendant( $parent_line_item, 'LIN_code' , $code );
1089
+	public static function get_nearest_descendant_having_code(EE_Line_Item $parent_line_item, $code) {
1090
+		return self::_get_nearest_descendant($parent_line_item, 'LIN_code', $code);
1091 1091
 	}
1092 1092
 
1093 1093
 
@@ -1101,15 +1101,15 @@  discard block
 block discarded – undo
1101 1101
 	 * @param string $value any value stored in $search_field
1102 1102
 	 * @return EE_Line_Item
1103 1103
 	 */
1104
-	protected static function _get_nearest_descendant( EE_Line_Item $parent_line_item, $search_field, $value ) {
1105
-		foreach( $parent_line_item->children() as $child ){
1106
-			if ( $child->get( $search_field ) == $value ){
1104
+	protected static function _get_nearest_descendant(EE_Line_Item $parent_line_item, $search_field, $value) {
1105
+		foreach ($parent_line_item->children() as $child) {
1106
+			if ($child->get($search_field) == $value) {
1107 1107
 				return $child;
1108 1108
 			}
1109 1109
 		}
1110
-		foreach( $parent_line_item->children() as $child ){
1111
-			$descendant_found = self::_get_nearest_descendant( $child, $search_field, $value );
1112
-			if ( $descendant_found ){
1110
+		foreach ($parent_line_item->children() as $child) {
1111
+			$descendant_found = self::_get_nearest_descendant($child, $search_field, $value);
1112
+			if ($descendant_found) {
1113 1113
 				return $descendant_found;
1114 1114
 			}
1115 1115
 		}
@@ -1126,22 +1126,22 @@  discard block
 block discarded – undo
1126 1126
 	 * @return void
1127 1127
 	 * @throws \EE_Error
1128 1128
 	 */
1129
-	public static function visualize( EE_Line_Item $line_item, $indentation = 0 ){
1129
+	public static function visualize(EE_Line_Item $line_item, $indentation = 0) {
1130 1130
 		echo "\n<br />";
1131
-		for( $i = 0; $i < $indentation; $i++ ){
1131
+		for ($i = 0; $i < $indentation; $i++) {
1132 1132
 			echo " - ";
1133 1133
 		}
1134
-		if( $line_item->is_percent() ) {
1135
-			$breakdown = $line_item->percent() . '%';
1134
+		if ($line_item->is_percent()) {
1135
+			$breakdown = $line_item->percent().'%';
1136 1136
 		} else {
1137
-			$breakdown = '$' . $line_item->unit_price() . "x" . $line_item->quantity();
1137
+			$breakdown = '$'.$line_item->unit_price()."x".$line_item->quantity();
1138 1138
 		}
1139
-		echo $line_item->name() . "( " . $line_item->ID() . " ) : " . $line_item->type() . " $" . $line_item->total() . "(" . $breakdown . ")";
1140
-		if( $line_item->is_taxable() ){
1139
+		echo $line_item->name()."( ".$line_item->ID()." ) : ".$line_item->type()." $".$line_item->total()."(".$breakdown.")";
1140
+		if ($line_item->is_taxable()) {
1141 1141
 			echo "  * taxable";
1142 1142
 		}
1143
-		if( $line_item->children() ){
1144
-			foreach($line_item->children() as $child){
1143
+		if ($line_item->children()) {
1144
+			foreach ($line_item->children() as $child) {
1145 1145
 				self::visualize($child, $indentation + 1);
1146 1146
 			}
1147 1147
 		}
@@ -1182,97 +1182,97 @@  discard block
 block discarded – undo
1182 1182
 	 *                                          is theirs, which can be done with
1183 1183
 	 *                                          `EEM_Line_Item::instance()->get_line_item_for_registration( $registration );`
1184 1184
 	 */
1185
-	public static function calculate_reg_final_prices_per_line_item( EE_Line_Item $line_item, $billable_ticket_quantities = array() ) {
1185
+	public static function calculate_reg_final_prices_per_line_item(EE_Line_Item $line_item, $billable_ticket_quantities = array()) {
1186 1186
 		//init running grand total if not already
1187
-		if ( ! isset( $running_totals[ 'total' ] ) ) {
1188
-			$running_totals[ 'total' ] = 0;
1187
+		if ( ! isset($running_totals['total'])) {
1188
+			$running_totals['total'] = 0;
1189 1189
 		}
1190
-		if( ! isset( $running_totals[ 'taxable' ] ) ) {
1191
-			$running_totals[ 'taxable' ] = array( 'total' => 0 );
1190
+		if ( ! isset($running_totals['taxable'])) {
1191
+			$running_totals['taxable'] = array('total' => 0);
1192 1192
 		}
1193
-		foreach ( $line_item->children() as $child_line_item ) {
1194
-			switch ( $child_line_item->type() ) {
1193
+		foreach ($line_item->children() as $child_line_item) {
1194
+			switch ($child_line_item->type()) {
1195 1195
 
1196 1196
 				case EEM_Line_Item::type_sub_total :
1197
-					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $child_line_item, $billable_ticket_quantities );
1197
+					$running_totals_from_subtotal = EEH_Line_Item::calculate_reg_final_prices_per_line_item($child_line_item, $billable_ticket_quantities);
1198 1198
 					//combine arrays but preserve numeric keys
1199
-					$running_totals = array_replace_recursive( $running_totals_from_subtotal, $running_totals );
1200
-					$running_totals[ 'total' ] += $running_totals_from_subtotal[ 'total' ];
1201
-					$running_totals[ 'taxable'][ 'total' ] += $running_totals_from_subtotal[ 'taxable' ][ 'total' ];
1199
+					$running_totals = array_replace_recursive($running_totals_from_subtotal, $running_totals);
1200
+					$running_totals['total'] += $running_totals_from_subtotal['total'];
1201
+					$running_totals['taxable']['total'] += $running_totals_from_subtotal['taxable']['total'];
1202 1202
 					break;
1203 1203
 
1204 1204
 				case EEM_Line_Item::type_tax_sub_total :
1205 1205
 
1206 1206
 					//find how much the taxes percentage is
1207
-					if ( $child_line_item->percent() !== 0 ) {
1207
+					if ($child_line_item->percent() !== 0) {
1208 1208
 						$tax_percent_decimal = $child_line_item->percent() / 100;
1209 1209
 					} else {
1210 1210
 						$tax_percent_decimal = EE_Taxes::get_total_taxes_percentage() / 100;
1211 1211
 					}
1212 1212
 					//and apply to all the taxable totals, and add to the pretax totals
1213
-					foreach ( $running_totals as $line_item_id => $this_running_total ) {
1213
+					foreach ($running_totals as $line_item_id => $this_running_total) {
1214 1214
 						//"total" and "taxable" array key is an exception
1215
-						if ( $line_item_id === 'taxable' ) {
1215
+						if ($line_item_id === 'taxable') {
1216 1216
 							continue;
1217 1217
 						}
1218
-						$taxable_total = $running_totals[ 'taxable' ][ $line_item_id ];
1219
-						$running_totals[ $line_item_id ] += ( $taxable_total * $tax_percent_decimal );
1218
+						$taxable_total = $running_totals['taxable'][$line_item_id];
1219
+						$running_totals[$line_item_id] += ($taxable_total * $tax_percent_decimal);
1220 1220
 					}
1221 1221
 					break;
1222 1222
 
1223 1223
 				case EEM_Line_Item::type_line_item :
1224 1224
 
1225 1225
 					// ticket line items or ????
1226
-					if ( $child_line_item->OBJ_type() === 'Ticket' ) {
1226
+					if ($child_line_item->OBJ_type() === 'Ticket') {
1227 1227
 						// kk it's a ticket
1228
-						if ( isset( $running_totals[ $child_line_item->ID() ] ) ) {
1228
+						if (isset($running_totals[$child_line_item->ID()])) {
1229 1229
 							//huh? that shouldn't happen.
1230
-							$running_totals[ 'total' ] += $child_line_item->total();
1230
+							$running_totals['total'] += $child_line_item->total();
1231 1231
 						} else {
1232 1232
 							//its not in our running totals yet. great.
1233
-							if ( $child_line_item->is_taxable() ) {
1233
+							if ($child_line_item->is_taxable()) {
1234 1234
 								$taxable_amount = $child_line_item->unit_price();
1235 1235
 							} else {
1236 1236
 								$taxable_amount = 0;
1237 1237
 							}
1238 1238
 							// are we only calculating totals for some tickets?
1239
-							if ( isset( $billable_ticket_quantities[ $child_line_item->OBJ_ID() ] ) ) {
1240
-								$quantity = $billable_ticket_quantities[ $child_line_item->OBJ_ID() ];
1241
-								$running_totals[ $child_line_item->ID() ] = $quantity
1239
+							if (isset($billable_ticket_quantities[$child_line_item->OBJ_ID()])) {
1240
+								$quantity = $billable_ticket_quantities[$child_line_item->OBJ_ID()];
1241
+								$running_totals[$child_line_item->ID()] = $quantity
1242 1242
 									? $child_line_item->unit_price()
1243 1243
 									: 0;
1244
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $quantity
1244
+								$running_totals['taxable'][$child_line_item->ID()] = $quantity
1245 1245
 									? $taxable_amount
1246 1246
 									: 0;
1247 1247
 							} else {
1248 1248
 								$quantity = $child_line_item->quantity();
1249
-								$running_totals[ $child_line_item->ID() ] = $child_line_item->unit_price();
1250
-								$running_totals[ 'taxable' ][ $child_line_item->ID() ] = $taxable_amount;
1249
+								$running_totals[$child_line_item->ID()] = $child_line_item->unit_price();
1250
+								$running_totals['taxable'][$child_line_item->ID()] = $taxable_amount;
1251 1251
 							}
1252
-							$running_totals[ 'taxable' ][ 'total' ] += $taxable_amount * $quantity;
1253
-							$running_totals[ 'total' ] += $child_line_item->unit_price() * $quantity;
1252
+							$running_totals['taxable']['total'] += $taxable_amount * $quantity;
1253
+							$running_totals['total'] += $child_line_item->unit_price() * $quantity;
1254 1254
 						}
1255 1255
 					} else {
1256 1256
 						// it's some other type of item added to the cart
1257 1257
 						// it should affect the running totals
1258 1258
 						// basically we want to convert it into a PERCENT modifier. Because
1259 1259
 						// more clearly affect all registration's final price equally
1260
-						$line_items_percent_of_running_total = $running_totals[ 'total' ] > 0
1261
-							? ( $child_line_item->total() / $running_totals[ 'total' ] ) + 1
1260
+						$line_items_percent_of_running_total = $running_totals['total'] > 0
1261
+							? ($child_line_item->total() / $running_totals['total']) + 1
1262 1262
 							: 1;
1263
-						foreach ( $running_totals as $line_item_id => $this_running_total ) {
1263
+						foreach ($running_totals as $line_item_id => $this_running_total) {
1264 1264
 							//the "taxable" array key is an exception
1265
-							if ( $line_item_id === 'taxable' ) {
1265
+							if ($line_item_id === 'taxable') {
1266 1266
 								continue;
1267 1267
 							}
1268 1268
 							// update the running totals
1269 1269
 							// yes this actually even works for the running grand total!
1270
-							$running_totals[ $line_item_id ] =
1270
+							$running_totals[$line_item_id] =
1271 1271
 								$line_items_percent_of_running_total * $this_running_total;
1272 1272
 
1273
-							if ( $child_line_item->is_taxable() ) {
1274
-								$running_totals[ 'taxable' ][ $line_item_id ] =
1275
-									$line_items_percent_of_running_total * $running_totals[ 'taxable' ][ $line_item_id ];
1273
+							if ($child_line_item->is_taxable()) {
1274
+								$running_totals['taxable'][$line_item_id] =
1275
+									$line_items_percent_of_running_total * $running_totals['taxable'][$line_item_id];
1276 1276
 							}
1277 1277
 						}
1278 1278
 					}
@@ -1290,16 +1290,16 @@  discard block
 block discarded – undo
1290 1290
 	 * @return float | null
1291 1291
 	 * @throws \OutOfRangeException
1292 1292
 	 */
1293
-	public static function calculate_final_price_for_ticket_line_item( \EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item ) {
1293
+	public static function calculate_final_price_for_ticket_line_item(\EE_Line_Item $total_line_item, \EE_Line_Item $ticket_line_item) {
1294 1294
 		static $final_prices_per_ticket_line_item = array();
1295
-		if ( empty( $final_prices_per_ticket_line_item ) ) {
1295
+		if (empty($final_prices_per_ticket_line_item)) {
1296 1296
 			$final_prices_per_ticket_line_item = \EEH_Line_Item::calculate_reg_final_prices_per_line_item(
1297 1297
 				$total_line_item
1298 1298
 			);
1299 1299
 		}
1300 1300
 		//ok now find this new registration's final price
1301
-		if ( isset( $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ] ) ) {
1302
-			return $final_prices_per_ticket_line_item[ $ticket_line_item->ID() ];
1301
+		if (isset($final_prices_per_ticket_line_item[$ticket_line_item->ID()])) {
1302
+			return $final_prices_per_ticket_line_item[$ticket_line_item->ID()];
1303 1303
 		}
1304 1304
 		$message = sprintf(
1305 1305
 			__(
@@ -1308,10 +1308,10 @@  discard block
 block discarded – undo
1308 1308
 			),
1309 1309
 			$ticket_line_item->ID()
1310 1310
 		);
1311
-		if ( WP_DEBUG ) {
1312
-			throw new \OutOfRangeException( $message );
1311
+		if (WP_DEBUG) {
1312
+			throw new \OutOfRangeException($message);
1313 1313
 		} else {
1314
-			EE_Log::instance()->log( __CLASS__, __FUNCTION__, $message );
1314
+			EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message);
1315 1315
 		}
1316 1316
 		return null;
1317 1317
 	}
@@ -1327,15 +1327,15 @@  discard block
 block discarded – undo
1327 1327
 	 * @return \EE_Line_Item
1328 1328
 	 * @throws \EE_Error
1329 1329
 	 */
1330
-	public static function billable_line_item_tree( EE_Line_Item $line_item, $registrations ) {
1331
-		$copy_li = EEH_Line_Item::billable_line_item( $line_item, $registrations );
1332
-		foreach ( $line_item->children() as $child_li ) {
1333
-			$copy_li->add_child_line_item( EEH_Line_Item::billable_line_item_tree( $child_li, $registrations ) );
1330
+	public static function billable_line_item_tree(EE_Line_Item $line_item, $registrations) {
1331
+		$copy_li = EEH_Line_Item::billable_line_item($line_item, $registrations);
1332
+		foreach ($line_item->children() as $child_li) {
1333
+			$copy_li->add_child_line_item(EEH_Line_Item::billable_line_item_tree($child_li, $registrations));
1334 1334
 		}
1335 1335
 		//if this is the grand total line item, make sure the totals all add up
1336 1336
 		//(we could have duplicated this logic AS we copied the line items, but
1337 1337
 		//it seems DRYer this way)
1338
-		if ( $copy_li->type() === EEM_Line_Item::type_total ) {
1338
+		if ($copy_li->type() === EEM_Line_Item::type_total) {
1339 1339
 			$copy_li->recalculate_total_including_taxes();
1340 1340
 		}
1341 1341
 		return $copy_li;
@@ -1352,24 +1352,24 @@  discard block
 block discarded – undo
1352 1352
 	 * @throws \EE_Error
1353 1353
 	 * @param EE_Registration[] $registrations
1354 1354
 	 */
1355
-	public static function billable_line_item( EE_Line_Item $line_item, $registrations ) {
1355
+	public static function billable_line_item(EE_Line_Item $line_item, $registrations) {
1356 1356
 		$new_li_fields = $line_item->model_field_array();
1357
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1357
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1358 1358
 			$line_item->OBJ_type() === 'Ticket'
1359 1359
 		) {
1360 1360
 			$count = 0;
1361
-			foreach ( $registrations as $registration ) {
1362
-				if ( $line_item->OBJ_ID() === $registration->ticket_ID() &&
1363
-					in_array( $registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment() )
1361
+			foreach ($registrations as $registration) {
1362
+				if ($line_item->OBJ_ID() === $registration->ticket_ID() &&
1363
+					in_array($registration->status_ID(), EEM_Registration::reg_statuses_that_allow_payment())
1364 1364
 				) {
1365 1365
 					$count++;
1366 1366
 				}
1367 1367
 			}
1368
-			$new_li_fields[ 'LIN_quantity' ] = $count;
1368
+			$new_li_fields['LIN_quantity'] = $count;
1369 1369
 		}
1370 1370
 		//don't set the total. We'll leave that up to the code that calculates it
1371
-		unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ], $new_li_fields[ 'LIN_total' ] );
1372
-		return EE_Line_Item::new_instance( $new_li_fields );
1371
+		unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent'], $new_li_fields['LIN_total']);
1372
+		return EE_Line_Item::new_instance($new_li_fields);
1373 1373
 	}
1374 1374
 
1375 1375
 
@@ -1382,19 +1382,19 @@  discard block
 block discarded – undo
1382 1382
 	 * @return \EE_Line_Item|null
1383 1383
 	 * @throws \EE_Error
1384 1384
 	 */
1385
-	public static function non_empty_line_items( EE_Line_Item $line_item ) {
1386
-		$copied_li = EEH_Line_Item::non_empty_line_item( $line_item );
1387
-		if ( $copied_li === null ) {
1385
+	public static function non_empty_line_items(EE_Line_Item $line_item) {
1386
+		$copied_li = EEH_Line_Item::non_empty_line_item($line_item);
1387
+		if ($copied_li === null) {
1388 1388
 			return null;
1389 1389
 		}
1390 1390
 		//if this is an event subtotal, we want to only include it if it
1391 1391
 		//has a non-zero total and at least one ticket line item child
1392 1392
 		$ticket_children = 0;
1393
-		foreach ( $line_item->children() as $child_li ) {
1394
-			$child_li_copy = EEH_Line_Item::non_empty_line_items( $child_li );
1395
-			if ( $child_li_copy !== null ) {
1396
-				$copied_li->add_child_line_item( $child_li_copy );
1397
-				if ( $child_li_copy->type() === EEM_Line_Item::type_line_item &&
1393
+		foreach ($line_item->children() as $child_li) {
1394
+			$child_li_copy = EEH_Line_Item::non_empty_line_items($child_li);
1395
+			if ($child_li_copy !== null) {
1396
+				$copied_li->add_child_line_item($child_li_copy);
1397
+				if ($child_li_copy->type() === EEM_Line_Item::type_line_item &&
1398 1398
 					$child_li_copy->OBJ_type() === 'Ticket'
1399 1399
 				) {
1400 1400
 					$ticket_children++;
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 * @return EE_Line_Item
1425 1425
 	 * @throws \EE_Error
1426 1426
 	 */
1427
-	public static function non_empty_line_item( EE_Line_Item $line_item ) {
1428
-		if ( $line_item->type() === EEM_Line_Item::type_line_item &&
1427
+	public static function non_empty_line_item(EE_Line_Item $line_item) {
1428
+		if ($line_item->type() === EEM_Line_Item::type_line_item &&
1429 1429
 			$line_item->OBJ_type() === 'Ticket' &&
1430 1430
 			$line_item->quantity() === 0
1431 1431
 		) {
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
 		}
1434 1434
 		$new_li_fields = $line_item->model_field_array();
1435 1435
 		//don't set the total. We'll leave that up to the code that calculates it
1436
-		unset( $new_li_fields[ 'LIN_ID' ], $new_li_fields[ 'LIN_parent' ] );
1437
-		return EE_Line_Item::new_instance( $new_li_fields );
1436
+		unset($new_li_fields['LIN_ID'], $new_li_fields['LIN_parent']);
1437
+		return EE_Line_Item::new_instance($new_li_fields);
1438 1438
 	}
1439 1439
 
1440 1440
 
@@ -1446,9 +1446,9 @@  discard block
 block discarded – undo
1446 1446
 	 * @return \EE_Line_Item
1447 1447
 	 * @throws \EE_Error
1448 1448
 	 */
1449
-	public static function get_items_subtotal( EE_Line_Item $total_line_item ){
1450
-		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' );
1451
-		return self::get_pre_tax_subtotal( $total_line_item );
1449
+	public static function get_items_subtotal(EE_Line_Item $total_line_item) {
1450
+		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');
1451
+		return self::get_pre_tax_subtotal($total_line_item);
1452 1452
 	}
1453 1453
 
1454 1454
 
@@ -1459,9 +1459,9 @@  discard block
 block discarded – undo
1459 1459
 	 * @return \EE_Line_Item
1460 1460
 	 * @throws \EE_Error
1461 1461
 	 */
1462
-	public static function create_default_total_line_item( $transaction = NULL) {
1463
-		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' );
1464
-		return self::create_total_line_item( $transaction );
1462
+	public static function create_default_total_line_item($transaction = NULL) {
1463
+		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');
1464
+		return self::create_total_line_item($transaction);
1465 1465
 	}
1466 1466
 
1467 1467
 
@@ -1473,9 +1473,9 @@  discard block
 block discarded – undo
1473 1473
 	 * @return \EE_Line_Item
1474 1474
 	 * @throws \EE_Error
1475 1475
 	 */
1476
-	public static function create_default_tickets_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1477
-		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' );
1478
-		return self::create_pre_tax_subtotal( $total_line_item, $transaction );
1476
+	public static function create_default_tickets_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1477
+		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');
1478
+		return self::create_pre_tax_subtotal($total_line_item, $transaction);
1479 1479
 	}
1480 1480
 
1481 1481
 
@@ -1487,9 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 	 * @return \EE_Line_Item
1488 1488
 	 * @throws \EE_Error
1489 1489
 	 */
1490
-	public static function create_default_taxes_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1491
-		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' );
1492
-		return self::create_taxes_subtotal( $total_line_item, $transaction );
1490
+	public static function create_default_taxes_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1491
+		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');
1492
+		return self::create_taxes_subtotal($total_line_item, $transaction);
1493 1493
 	}
1494 1494
 
1495 1495
 
@@ -1501,9 +1501,9 @@  discard block
 block discarded – undo
1501 1501
 	 * @return \EE_Line_Item
1502 1502
 	 * @throws \EE_Error
1503 1503
 	 */
1504
-	public static function create_default_event_subtotal( EE_Line_Item $total_line_item, $transaction = NULL) {
1505
-		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' );
1506
-		return self::create_event_subtotal( $total_line_item, $transaction );
1504
+	public static function create_default_event_subtotal(EE_Line_Item $total_line_item, $transaction = NULL) {
1505
+		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');
1506
+		return self::create_event_subtotal($total_line_item, $transaction);
1507 1507
 	}
1508 1508
 
1509 1509
 
Please login to merge, or discard this patch.
core/helpers/EEH_Parse_Shortcodes.helper.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
10 10
 	exit('NO direct script access allowed');
11
+}
11 12
 
12 13
 /**
13 14
  *
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 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
 /**
@@ -97,67 +97,67 @@  discard block
 block discarded – undo
97 97
 			'message_type' => $message_type,
98 98
 			'message' => $message
99 99
 			);
100
-		$this->_init_data( $template, $data, $valid_shortcodes, $extra_data );
100
+		$this->_init_data($template, $data, $valid_shortcodes, $extra_data);
101 101
 		$this->_template = is_array($template) ? $template['main'] : $template;
102 102
 		return $this->_parse_message_template();
103 103
 	}
104 104
 
105 105
 
106
-	public function parse_attendee_list_template( $template, EE_Registration $registration, $valid_shortcodes, $extra_data = array() ) {
107
-		$this->_init_data( $template, $registration, $valid_shortcodes, $extra_data );
106
+	public function parse_attendee_list_template($template, EE_Registration $registration, $valid_shortcodes, $extra_data = array()) {
107
+		$this->_init_data($template, $registration, $valid_shortcodes, $extra_data);
108 108
 		$this->_template = is_array($template) ? $template['attendee_list'] : $template;
109 109
 		return $this->_parse_message_template();
110 110
 	}
111 111
 
112
-	public function parse_event_list_template( $template, EE_Event $event, $valid_shortcodes, $extra_data = array() ) {
113
-		$this->_init_data( $template, $event, $valid_shortcodes, $extra_data );
112
+	public function parse_event_list_template($template, EE_Event $event, $valid_shortcodes, $extra_data = array()) {
113
+		$this->_init_data($template, $event, $valid_shortcodes, $extra_data);
114 114
 		$this->_template = is_array($template) ? $template['event_list'] : $template;
115 115
 		return $this->_parse_message_template();
116 116
 	}
117 117
 
118 118
 
119
-	public function parse_ticket_list_template( $template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array() ) {
120
-		$this->_init_data( $template, $ticket, $valid_shortcodes, $extra_data );
119
+	public function parse_ticket_list_template($template, EE_Ticket $ticket, $valid_shortcodes, $extra_data = array()) {
120
+		$this->_init_data($template, $ticket, $valid_shortcodes, $extra_data);
121 121
 		$this->_template = is_array($template) ? $template['ticket_list'] : $template;
122 122
 		return $this->_parse_message_template();
123 123
 	}
124 124
 
125 125
 
126 126
 
127
-	public function parse_line_item_list_template( $template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array() ) {
128
-		$this->_init_data( $template, $line_item, $valid_shortcodes, $extra_data );
129
-		$this->_template = is_array( $template ) ? $template['ticket_line_item_no_pms'] : $template;
127
+	public function parse_line_item_list_template($template, EE_Line_Item $line_item, $valid_shortcodes, $extra_data = array()) {
128
+		$this->_init_data($template, $line_item, $valid_shortcodes, $extra_data);
129
+		$this->_template = is_array($template) ? $template['ticket_line_item_no_pms'] : $template;
130 130
 		return $this->_parse_message_template();
131 131
 	}
132 132
 
133 133
 
134
-	public function parse_payment_list_template( $template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array() ) {
135
-		$this->_init_data( $template, $payment_item, $valid_shortcodes, $extra_data );
136
-		$this->_template = is_array( $template ) ? $template['payment_list'] : $template;
134
+	public function parse_payment_list_template($template, EE_Payment $payment_item, $valid_shortcodes, $extra_data = array()) {
135
+		$this->_init_data($template, $payment_item, $valid_shortcodes, $extra_data);
136
+		$this->_template = is_array($template) ? $template['payment_list'] : $template;
137 137
 		return $this->_parse_message_template();
138 138
 	}
139 139
 
140 140
 
141
-	public function parse_datetime_list_template( $template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array() ) {
142
-		$this->_init_data( $template, $datetime, $valid_shortcodes, $extra_data );
141
+	public function parse_datetime_list_template($template, EE_Datetime $datetime, $valid_shortcodes, $extra_data = array()) {
142
+		$this->_init_data($template, $datetime, $valid_shortcodes, $extra_data);
143 143
 		$this->_template = is_array($template) ? $template['datetime_list'] : $template;
144 144
 		return $this->_parse_message_template();
145 145
 	}
146 146
 
147 147
 
148
-	public function parse_question_list_template( $template, EE_Answer $answer, $valid_shortcodes, $extra_data = array() ) {
149
-		$this->_init_data( $template, $answer, $valid_shortcodes, $extra_data );
148
+	public function parse_question_list_template($template, EE_Answer $answer, $valid_shortcodes, $extra_data = array()) {
149
+		$this->_init_data($template, $answer, $valid_shortcodes, $extra_data);
150 150
 		$this->_template = is_array($template) ? $template['question_list'] : $template;
151 151
 		return $this->_parse_message_template();
152 152
 	}
153 153
 
154 154
 
155
-	private function _init_data( $template, $data, $valid_shortcodes, $extra_data = array() ) {
155
+	private function _init_data($template, $data, $valid_shortcodes, $extra_data = array()) {
156 156
 		$this->_reset_props();
157 157
 		$this->_data['template'] = $template;
158 158
 		$this->_data['data'] = $data;
159 159
 		$this->_data['extra_data'] = $extra_data;
160
-		$this->_set_shortcodes( $valid_shortcodes );
160
+		$this->_set_shortcodes($valid_shortcodes);
161 161
 	}
162 162
 
163 163
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	private function _parse_message_template() {
177 177
 		//now let's get a list of shortcodes that are found in the given template
178
-		preg_match_all( '/(\[.+?\])/', $this->_template, $matches );
178
+		preg_match_all('/(\[.+?\])/', $this->_template, $matches);
179 179
 		$shortcodes = (array) $matches[0]; //this should be an array of shortcodes in the template string.
180 180
 
181 181
 		$matched_code = array();
@@ -200,30 +200,30 @@  discard block
 block discarded – undo
200 200
 			'[PAYMENT_LIST_*]'
201 201
 			);
202 202
 
203
-		$list_type_shortcodes = apply_filters( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes );
203
+		$list_type_shortcodes = apply_filters('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', $list_type_shortcodes);
204 204
 
205 205
 		//now lets go ahead and loop through our parsers for each shortcode and setup the values
206
-		foreach ( $shortcodes as $shortcode ) {
206
+		foreach ($shortcodes as $shortcode) {
207 207
 
208
-			foreach ( $this->_shortcode_objs as $sc_obj ) {
209
-				if ( $sc_obj instanceof EE_Shortcodes ){
208
+			foreach ($this->_shortcode_objs as $sc_obj) {
209
+				if ($sc_obj instanceof EE_Shortcodes) {
210 210
 					//we need to setup any dynamic shortcodes so that they work with the array_key_exists
211
-					preg_match_all( '/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches );
212
-					$sc_to_verify = !empty($matches[0] ) ? $matches[0][0] . ']' : $shortcode;
211
+					preg_match_all('/(\[[A-Za-z0-9\_]+_\*)/', $shortcode, $matches);
212
+					$sc_to_verify = ! empty($matches[0]) ? $matches[0][0].']' : $shortcode;
213 213
 
214
-					if ( !array_key_exists( $sc_to_verify, $sc_obj->get_shortcodes() ) ) {
214
+					if ( ! array_key_exists($sc_to_verify, $sc_obj->get_shortcodes())) {
215 215
 						continue; //the given shortcode isn't in this object
216 216
 					}
217 217
 
218 218
 					//if this isn't  a "list" type shortcode then we'll send along the data vanilla instead of in an array.
219
-					if ( ! in_array( $sc_to_verify, $list_type_shortcodes ) ) {
220
-						$data_send = !is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
219
+					if ( ! in_array($sc_to_verify, $list_type_shortcodes)) {
220
+						$data_send = ! is_object($this->_data) && isset($this->_data['data']) ? $this->_data['data'] : $this->_data;
221 221
 					} else {
222 222
 						$data_send = $this->_data;
223 223
 					}
224 224
 
225 225
 
226
-					$parsed = $sc_obj->parser( $shortcode, $data_send, $this->_data['extra_data'] );
226
+					$parsed = $sc_obj->parser($shortcode, $data_send, $this->_data['extra_data']);
227 227
 
228 228
 					$matched_code[] = $shortcode;
229 229
 					$sc_values[] = $parsed;
@@ -246,12 +246,12 @@  discard block
 block discarded – undo
246 246
 	 * @param array $valid_shortcodes an array of strings corresponding to EE_Shortcode Library objects
247 247
 	 * @return void
248 248
 	 */
249
-	private function _set_shortcodes( $valid_shortcodes ) {
250
-		foreach ( $valid_shortcodes as $shortcode_ref ) {
251
-			$ref = ucwords( str_replace('_', ' ', $shortcode_ref ) );
252
-			$ref = str_replace( ' ', '_', $ref );
253
-			$classname = 'EE_' . $ref . '_Shortcodes';
254
-			if ( class_exists( $classname ) ) {
249
+	private function _set_shortcodes($valid_shortcodes) {
250
+		foreach ($valid_shortcodes as $shortcode_ref) {
251
+			$ref = ucwords(str_replace('_', ' ', $shortcode_ref));
252
+			$ref = str_replace(' ', '_', $ref);
253
+			$classname = 'EE_'.$ref.'_Shortcodes';
254
+			if (class_exists($classname)) {
255 255
 				$this->_shortcode_objs[] = new $classname;
256 256
 			}
257 257
 		}
Please login to merge, or discard this patch.
core/helpers/EEH_Venue_View.helper.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -799,7 +799,6 @@
 block discarded – undo
799 799
 
800 800
 
801 801
 	/**
802
-
803 802
 	 *
804 803
 	 * 	 If the the first date starts at midnight on one day, and the next date ends at midnight on the
805 804
 	 * 	 very next day then this method will return true.
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	 * @param bool $password_check
46 46
 	 * @return \EE_Venue|null
47 47
 	 */
48
-	public static function get_venue( $VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true ) {
49
-		$VNU_ID = absint( $VNU_ID );
48
+	public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true, $password_check = true) {
49
+		$VNU_ID = absint($VNU_ID);
50 50
 		// do we already have the Venue you are looking for?
51
-		if ( EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID ) {
52
-			return EEH_Venue_View::_get_venue( $privacy_check );
51
+		if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID) {
52
+			return EEH_Venue_View::_get_venue($privacy_check);
53 53
 		}
54 54
 		// international newspaper?
55 55
 		global $post;
56
-		if ( $post instanceof WP_Post ) {
57
-			switch ( $post->post_type ) {
56
+		if ($post instanceof WP_Post) {
57
+			switch ($post->post_type) {
58 58
 				// if this is being called from an EE_Venue post,
59 59
 				// and the EE_Venue post corresponds to the EE_Venue that is being asked for,
60 60
 				// then we can try to just grab the attached EE_Venue object
@@ -62,31 +62,31 @@  discard block
 block discarded – undo
62 62
 					// the post already contains the related EE_Venue object AND one of the following is TRUE:
63 63
 					// the requested Venue ID matches the post ID OR...
64 64
 					// there was no specific Venue ID requested
65
-					if ( isset( $post->EE_Venue ) && ( $VNU_ID == $post->ID || ! $VNU_ID )) {
65
+					if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || ! $VNU_ID)) {
66 66
 						// use existing related EE_Venue object
67
-						EEH_Venue_View::$_venue =  $post->EE_Venue;
68
-					} else if ( $VNU_ID ) {
67
+						EEH_Venue_View::$_venue = $post->EE_Venue;
68
+					} else if ($VNU_ID) {
69 69
 						// there WAS a specific Venue ID requested, but it's NOT the current post object
70
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
70
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
71 71
 					} else {
72 72
 						// no specific Venue ID requested, so use post ID to generate EE_Venue object
73
-						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $post->ID );
73
+						EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID);
74 74
 					}
75 75
 				break;
76 76
 
77 77
 				case 'espresso_events':
78
-					if ( $look_in_event ) {
78
+					if ($look_in_event) {
79 79
 						// grab the events related venues
80 80
 						$venues = EEH_Venue_View::get_event_venues();
81 81
 						// make sure the result is an array
82
-						$venues = is_array( $venues ) ? $venues : array();
82
+						$venues = is_array($venues) ? $venues : array();
83 83
 						// do we have an ID for a specific venue?
84
-						if ( $VNU_ID ) {
84
+						if ($VNU_ID) {
85 85
 							// loop thru the related venues
86
-							foreach( $venues as $venue ) {
87
-								if ( $venue instanceof EE_Venue ) {
86
+							foreach ($venues as $venue) {
87
+								if ($venue instanceof EE_Venue) {
88 88
 									// until we find the venue we're looking for
89
-									if ( $venue->ID() == $VNU_ID ) {
89
+									if ($venue->ID() == $VNU_ID) {
90 90
 										EEH_Venue_View::$_venue = $venue;
91 91
 										break;
92 92
 									}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 							// then the global post is an events post and this function was called with no argument
99 99
 						} else {
100 100
 							// just grab the first related event venue
101
-							EEH_Venue_View::$_venue = reset( $venues );
101
+							EEH_Venue_View::$_venue = reset($venues);
102 102
 						}
103 103
 					}
104 104
 				break;
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 		}
108 108
 		// now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID...
109
-		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID ) {
109
+		if ( ! EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) {
110 110
 			// sigh... pull it from the db
111
-			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID( $VNU_ID );
111
+			EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
112 112
 		}
113
-		return EEH_Venue_View::_get_venue( $privacy_check, $password_check );
113
+		return EEH_Venue_View::_get_venue($privacy_check, $password_check);
114 114
 	}
115 115
 
116 116
 
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
 	 * @param bool $password_check
124 124
 	 * @return 	EE_Venue
125 125
 	 */
126
-	protected static function _get_venue( $privacy_check = true, $password_check = true ) {
126
+	protected static function _get_venue($privacy_check = true, $password_check = true) {
127 127
 		// check for private venues.
128 128
 		if (
129 129
 			EEH_Venue_View::$_venue instanceof EE_Venue
130 130
 			&& EEH_Venue_View::$_venue->status() == 'private'
131 131
 			&& $privacy_check
132
-			&& ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_venues', 'get_venues' )
132
+			&& ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')
133 133
 		) {
134 134
 			return null;
135 135
 		}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		if (
138 138
 			EEH_Venue_View::$_venue instanceof EE_Venue
139 139
 			&& $password_check
140
-			&& post_password_required( EEH_Venue_View::$_venue->ID() )
140
+			&& post_password_required(EEH_Venue_View::$_venue->ID())
141 141
 		) {
142 142
 			return null;
143 143
 		}
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public static function get_event_venues() {
156 156
 		global $post;
157
-		if ( $post->post_type == 'espresso_events' ) {
158
-			if ( isset( $post->EE_Event ) && $post->EE_Event instanceof EE_Event ) {
157
+		if ($post->post_type == 'espresso_events') {
158
+			if (isset($post->EE_Event) && $post->EE_Event instanceof EE_Event) {
159 159
 				return $post->EE_Event->venues();
160 160
 			}
161 161
 		}
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @return bool|null
177 177
 	 */
178
-	public static function is_venue_private( $VNU_ID = false ) {
179
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true );
180
-		if ( ! $venue instanceof EE_Venue ) {
178
+	public static function is_venue_private($VNU_ID = false) {
179
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true);
180
+		if ( ! $venue instanceof EE_Venue) {
181 181
 			return null;
182 182
 		}
183 183
 
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	 * @param bool $VNU_ID venue to check (optional). If not included will use internally derived venue object.
193 193
 	 * @return bool
194 194
 	 */
195
-	public static function is_venue_password_protected( $VNU_ID = false ) {
196
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
195
+	public static function is_venue_password_protected($VNU_ID = false) {
196
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
197 197
 		if (
198 198
 			$venue instanceof EE_Venue
199
-			&& post_password_required( $venue->ID() )
199
+			&& post_password_required($venue->ID())
200 200
 		) {
201 201
 			return true;
202 202
 		}
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return string
215 215
 	 */
216
-	public static function password_protected_venue_form( $VNU_ID = false ) {
217
-		$venue = EEH_Venue_View::get_venue( $VNU_ID, true, true, false );
216
+	public static function password_protected_venue_form($VNU_ID = false) {
217
+		$venue = EEH_Venue_View::get_venue($VNU_ID, true, true, false);
218 218
 		if (
219 219
 			$venue instanceof EE_Venue
220
-			&& post_password_required( $venue->ID() )
220
+			&& post_password_required($venue->ID())
221 221
 		) {
222
-			return get_the_password_form( $venue->ID() );
222
+			return get_the_password_form($venue->ID());
223 223
 		}
224 224
 		return '';
225 225
 	}
@@ -233,9 +233,9 @@  discard block
 block discarded – undo
233 233
 	 * @param int $VNU_ID
234 234
 	 * @return string
235 235
 	 */
236
-	public static function venue_description( $VNU_ID = 0 ) {
237
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
238
-		if ( $venue instanceof EE_Venue ) {
236
+	public static function venue_description($VNU_ID = 0) {
237
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
238
+		if ($venue instanceof EE_Venue) {
239 239
 			return$venue->description();
240 240
 		}
241 241
 		return '';
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 	 * @param int $VNU_ID
251 251
 	 * @return string
252 252
 	 */
253
-	public static function venue_excerpt( $VNU_ID = 0 ) {
254
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
255
-		if ( $venue instanceof EE_Venue ) {
253
+	public static function venue_excerpt($VNU_ID = 0) {
254
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
255
+		if ($venue instanceof EE_Venue) {
256 256
 			$excerpt = $venue->excerpt() != NULL && $venue->excerpt() ? $venue->excerpt() : $venue->description();
257
-			$venue_link = ' ' . EEH_Venue_View::venue_details_link( $venue->ID(), __( 'more', 'event_espresso' ) . '&hellip;' );
258
-			return ! empty( $excerpt ) ? wp_trim_words( $excerpt, 25, '' ) . $venue_link : '';
257
+			$venue_link = ' '.EEH_Venue_View::venue_details_link($venue->ID(), __('more', 'event_espresso').'&hellip;');
258
+			return ! empty($excerpt) ? wp_trim_words($excerpt, 25, '').$venue_link : '';
259 259
 		}
260 260
 		return '';
261 261
 	}
@@ -270,22 +270,22 @@  discard block
 block discarded – undo
270 270
 	 * @param bool $hide_uncategorized
271 271
 	 * @return string
272 272
 	 */
273
-	public static function venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE ) {
273
+	public static function venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE) {
274 274
 		$category_links = array();
275
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
276
-		if ( $venue instanceof EE_Venue ) {
275
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
276
+		if ($venue instanceof EE_Venue) {
277 277
 			// get category terms
278
-			if ( $venue_categories = get_the_terms( $venue->ID(), 'espresso_venue_categories' )) {
278
+			if ($venue_categories = get_the_terms($venue->ID(), 'espresso_venue_categories')) {
279 279
 				// loop thru terms and create links
280
-				foreach ( $venue_categories as $term ) {
281
-					$url = get_term_link( $term, 'espresso_venue_categories' );
282
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
283
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a> ';
280
+				foreach ($venue_categories as $term) {
281
+					$url = get_term_link($term, 'espresso_venue_categories');
282
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
283
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a> ';
284 284
 					}
285 285
 				}
286 286
 			}
287 287
 		}
288
-		return implode( ', ', $category_links );
288
+		return implode(', ', $category_links);
289 289
 	}
290 290
 
291 291
 
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
 	 * @param bool $add_wrapper
301 301
 	 * @return string
302 302
 	 */
303
-	public static function venue_address( $type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true ) {
304
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
305
-		if ( $venue instanceof EE_Venue ) {
306
-			return EEH_Address::format( $venue, $type, $use_schema, $add_wrapper );
303
+	public static function venue_address($type = 'multiline', $VNU_ID = 0, $use_schema = true, $add_wrapper = true) {
304
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
305
+		if ($venue instanceof EE_Venue) {
306
+			return EEH_Address::format($venue, $type, $use_schema, $add_wrapper);
307 307
 		}
308 308
 		return '';
309 309
 	}
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
 	 * @param int $VNU_ID
318 318
 	 * @return bool|string
319 319
 	 */
320
-	public static function venue_has_address( $VNU_ID = 0 ) {
321
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
322
-		if ( $venue instanceof EE_Venue ) {
323
-			return EEH_Address::format( $venue, 'inline', FALSE, FALSE );
320
+	public static function venue_has_address($VNU_ID = 0) {
321
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
322
+		if ($venue instanceof EE_Venue) {
323
+			return EEH_Address::format($venue, 'inline', FALSE, FALSE);
324 324
 		}
325 325
 		return false;
326 326
 	}
@@ -335,30 +335,30 @@  discard block
 block discarded – undo
335 335
 	 * @param int $VNU_ID
336 336
 	 * @return string
337 337
 	 */
338
-	public static function venue_name( $link_to = 'details', $VNU_ID = 0 ) {
339
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
340
-		if ( $venue instanceof EE_Venue ) {
338
+	public static function venue_name($link_to = 'details', $VNU_ID = 0) {
339
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
340
+		if ($venue instanceof EE_Venue) {
341 341
 			$venue_name = apply_filters(
342 342
 				'FHEE__EEH_Venue__venue_name__append_private_venue_name',
343 343
 				EEH_Venue_View::is_venue_private()
344
-					? EEH_Venue_View::$_venue->name() . "&nbsp;" . __( '(Private)', 'event_espresso' )
344
+					? EEH_Venue_View::$_venue->name()."&nbsp;".__('(Private)', 'event_espresso')
345 345
 					: EEH_Venue_View::$_venue->name(),
346 346
 				EEH_Venue_View::$_venue
347 347
 			);
348
-			$venue_name = EEH_Schema::name( $venue_name );
348
+			$venue_name = EEH_Schema::name($venue_name);
349 349
 
350 350
 			//if venue is trashed then ignore the "link to" setting because the venue is trashed.
351
-			if ( $venue->get('status') == 'trash' ) {
351
+			if ($venue->get('status') == 'trash') {
352 352
 				$link_to = '';
353 353
 			}
354
-			switch( $link_to ) {
354
+			switch ($link_to) {
355 355
 
356 356
 				case 'details' :
357
-					return EEH_Venue_View::venue_details_link( $venue->ID(), $venue_name );
357
+					return EEH_Venue_View::venue_details_link($venue->ID(), $venue_name);
358 358
 				break;
359 359
 
360 360
 				case 'website' :
361
-					return EEH_Venue_View::venue_website_link( $venue->ID(), $venue_name );
361
+					return EEH_Venue_View::venue_website_link($venue->ID(), $venue_name);
362 362
 				break;
363 363
 
364 364
 				default :
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 	 * @param    string $text
379 379
 	 * @return string
380 380
 	 */
381
-	public static function venue_details_link( $VNU_ID = 0, $text = '' ) {
382
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
383
-		if ( $venue instanceof EE_Venue ) {
384
-			return EEH_Schema::url( get_permalink( $venue->ID() ), $text );
381
+	public static function venue_details_link($VNU_ID = 0, $text = '') {
382
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
383
+		if ($venue instanceof EE_Venue) {
384
+			return EEH_Schema::url(get_permalink($venue->ID()), $text);
385 385
 		}
386 386
 		return '';
387 387
 	}
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 	 * @param    string $text
397 397
 	 * @return string
398 398
 	 */
399
-	public static function venue_website_link( $VNU_ID = 0, $text = '' ) {
400
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
401
-		if ( $venue instanceof EE_Venue ) {
399
+	public static function venue_website_link($VNU_ID = 0, $text = '') {
400
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
401
+		if ($venue instanceof EE_Venue) {
402 402
 			$url = $venue->venue_url();
403
-			$text = ! empty( $text ) ? $text : $url;
404
-			return ! empty( $url ) ? EEH_Schema::url( $url, $text ) : '';
403
+			$text = ! empty($text) ? $text : $url;
404
+			return ! empty($url) ? EEH_Schema::url($url, $text) : '';
405 405
 		}
406 406
 		return '';
407 407
 	}
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 	 * @param int $VNU_ID
416 416
 	 * @return string
417 417
 	 */
418
-	public static function venue_phone( $VNU_ID = 0) {
419
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
420
-		if ( $venue instanceof EE_Venue ) {
421
-			return EEH_Schema::telephone( $venue->phone() );
418
+	public static function venue_phone($VNU_ID = 0) {
419
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
420
+		if ($venue instanceof EE_Venue) {
421
+			return EEH_Schema::telephone($venue->phone());
422 422
 		}
423 423
 		return '';
424 424
 	}
@@ -434,48 +434,48 @@  discard block
 block discarded – undo
434 434
 	 * @param    array $gmap map options
435 435
 	 * @return string
436 436
 	 */
437
-	public static function venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array() ) {
437
+	public static function venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array()) {
438 438
 
439
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
440
-		if ( $venue instanceof EE_Venue ) {
439
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
440
+		if ($venue instanceof EE_Venue) {
441 441
 			// check for global espresso_events post and use it's ID if no map_ID is set
442 442
 			global $post;
443
-			$map_ID = empty( $map_ID ) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
443
+			$map_ID = empty($map_ID) && $post->post_type == 'espresso_events' ? $post->ID : $map_ID;
444 444
 			// grab map settings
445 445
 			$map_cfg = EE_Registry::instance()->CFG->map_settings;
446 446
 			// are maps enabled ?
447
-			if ( $map_cfg->use_google_maps && $venue->enable_for_gmap() ) {
447
+			if ($map_cfg->use_google_maps && $venue->enable_for_gmap()) {
448 448
 
449 449
 				$details_page = is_single();
450 450
 				$options = array();
451
-				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID . '-' . $venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
451
+				$options['map_ID'] = $map_ID && $map_ID != $venue->ID() ? $map_ID.'-'.$venue->ID()/* . '-' . $static_map_id*/ : $venue->ID()/* . '-' . $static_map_id*/;
452 452
 
453
-				$options['location'] = EEH_Address::format( $venue, 'inline', FALSE, FALSE );
453
+				$options['location'] = EEH_Address::format($venue, 'inline', FALSE, FALSE);
454 454
 
455 455
 				$options['ee_map_width'] = $details_page ? $map_cfg->event_details_map_width : $map_cfg->event_list_map_width;
456
-				$options['ee_map_width'] = isset( $gmap['ee_map_width'] ) && ! empty( $gmap['ee_map_width'] ) ? $gmap['ee_map_width'] : $options['ee_map_width'];
456
+				$options['ee_map_width'] = isset($gmap['ee_map_width']) && ! empty($gmap['ee_map_width']) ? $gmap['ee_map_width'] : $options['ee_map_width'];
457 457
 
458 458
 				$options['ee_map_height'] = $details_page ? $map_cfg->event_details_map_height : $map_cfg->event_list_map_height;
459
-				$options['ee_map_height'] = isset( $gmap['ee_map_height'] ) && ! empty( $gmap['ee_map_height'] ) ? $gmap['ee_map_height'] : $options['ee_map_height'];
459
+				$options['ee_map_height'] = isset($gmap['ee_map_height']) && ! empty($gmap['ee_map_height']) ? $gmap['ee_map_height'] : $options['ee_map_height'];
460 460
 
461 461
 				$options['ee_map_zoom'] = $details_page ? $map_cfg->event_details_map_zoom : $map_cfg->event_list_map_zoom;
462
-				$options['ee_map_zoom'] = isset( $gmap['ee_map_zoom'] ) && ! empty( $gmap['ee_map_zoom'] ) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
462
+				$options['ee_map_zoom'] = isset($gmap['ee_map_zoom']) && ! empty($gmap['ee_map_zoom']) ? $gmap['ee_map_zoom'] : $options['ee_map_zoom'];
463 463
 
464 464
 				$options['ee_map_nav_display'] = $details_page ? $map_cfg->event_details_display_nav : $map_cfg->event_list_display_nav;
465
-				$options['ee_map_nav_display'] = isset( $gmap['ee_map_nav_display'] ) && ! empty( $gmap['ee_map_nav_display'] ) ? 'true' : $options['ee_map_nav_display'];;
465
+				$options['ee_map_nav_display'] = isset($gmap['ee_map_nav_display']) && ! empty($gmap['ee_map_nav_display']) ? 'true' : $options['ee_map_nav_display']; ;
466 466
 
467 467
 				$options['ee_map_nav_size'] = $details_page ? $map_cfg->event_details_nav_size : $map_cfg->event_list_nav_size;
468
-				$options['ee_map_nav_size'] =  isset( $gmap['ee_map_nav_size'] ) && ! empty( $gmap['ee_map_nav_size'] )? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
468
+				$options['ee_map_nav_size'] = isset($gmap['ee_map_nav_size']) && ! empty($gmap['ee_map_nav_size']) ? $gmap['ee_map_nav_size'] : $options['ee_map_nav_size'];
469 469
 
470 470
 				$options['ee_map_type_control'] = $details_page ? $map_cfg->event_details_control_type : $map_cfg->event_list_control_type;
471
-				$options['ee_map_type_control'] =  isset( $gmap['ee_map_type_control'] ) && ! empty( $gmap['ee_map_type_control'] )? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
471
+				$options['ee_map_type_control'] = isset($gmap['ee_map_type_control']) && ! empty($gmap['ee_map_type_control']) ? $gmap['ee_map_type_control'] : $options['ee_map_type_control'];
472 472
 
473 473
 				$options['ee_map_align'] = $details_page ? $map_cfg->event_details_map_align : $map_cfg->event_list_map_align;
474
-				$options['ee_map_align'] =  isset( $gmap['ee_map_align'] ) && ! empty( $gmap['ee_map_align'] )? $gmap['ee_map_align'] : $options['ee_map_align'];
474
+				$options['ee_map_align'] = isset($gmap['ee_map_align']) && ! empty($gmap['ee_map_align']) ? $gmap['ee_map_align'] : $options['ee_map_align'];
475 475
 
476
-				$options['ee_static_url'] =  isset( $gmap['ee_static_url'] ) && ! empty( $gmap['ee_static_url'] ) ? (bool)absint( $gmap['ee_static_url'] ) : $venue->google_map_link();
476
+				$options['ee_static_url'] = isset($gmap['ee_static_url']) && ! empty($gmap['ee_static_url']) ? (bool) absint($gmap['ee_static_url']) : $venue->google_map_link();
477 477
 
478
-				return EEH_Maps::google_map( $options );
478
+				return EEH_Maps::google_map($options);
479 479
 
480 480
 			}
481 481
 		}
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 * @param array $atts like EEH_Maps::google_map_link
491 491
 	 * @return string
492 492
 	 */
493
-	public static function espresso_google_static_map( EE_Venue $venue, $atts = array() ){
493
+	public static function espresso_google_static_map(EE_Venue $venue, $atts = array()) {
494 494
 		$state = $venue->state_obj();
495 495
 		$country = $venue->country_obj();
496 496
 		$atts = shortcode_atts(
@@ -521,23 +521,23 @@  discard block
 block discarded – undo
521 521
 	 * @param string $after
522 522
 	 * @return string
523 523
 	 */
524
-	public static function edit_venue_link( $VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>' ) {
525
-		$venue = EEH_Venue_View::get_venue( $VNU_ID );
526
-		if ( $venue instanceof EE_Venue ) {
524
+	public static function edit_venue_link($VNU_ID = 0, $link = '', $before = '<p class="edit-venue-lnk small-txt">', $after = '</p>') {
525
+		$venue = EEH_Venue_View::get_venue($VNU_ID);
526
+		if ($venue instanceof EE_Venue) {
527 527
 			// can the user edit this post ?
528
-			if ( current_user_can( 'edit_post', $venue->ID() )) {
528
+			if (current_user_can('edit_post', $venue->ID())) {
529 529
 				// set link text
530
-				$link = ! empty( $link ) ? $link : __('edit this venue');
530
+				$link = ! empty($link) ? $link : __('edit this venue');
531 531
 				// generate nonce
532
-				$nonce = wp_create_nonce( 'edit_nonce' );
532
+				$nonce = wp_create_nonce('edit_nonce');
533 533
 				// generate url to venue editor for this venue
534
-				$url = add_query_arg( array( 'page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce ), admin_url( 'admin.php' ) );
534
+				$url = add_query_arg(array('page' => 'espresso_venues', 'action' => 'edit', 'post' => $venue->ID(), 'edit_nonce' => $nonce), admin_url('admin.php'));
535 535
 				// get edit CPT text
536
-				$post_type_obj = get_post_type_object( 'espresso_venues' );
536
+				$post_type_obj = get_post_type_object('espresso_venues');
537 537
 				// build final link html
538
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
538
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
539 539
 				// put it all together
540
-				return $before . apply_filters( 'edit_post_link', $link, $venue->ID() ) . $after;
540
+				return $before.apply_filters('edit_post_link', $link, $venue->ID()).$after;
541 541
 			}
542 542
 		}
543 543
 		return '';
Please login to merge, or discard this patch.