Completed
Branch BUG-9715-shortcode-resources (0cf20f)
by
unknown
695:33 queued 678:11
created
core/db_models/relations/EE_HABTM_Any_Relation.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @subpackage    core
9 9
  * @author        Michael Nelson
10 10
  */
11
-class EE_HABTM_Any_Relation extends EE_HABTM_Relation{
11
+class EE_HABTM_Any_Relation extends EE_HABTM_Relation {
12 12
 	/**
13 13
 	 *
14 14
 	 * @var string
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	 * @param boolean $block_deletes for this type of relation, we block by default for now. if there are related models across this relation, block (prevent and add an error) the deletion of this model
23 23
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
24 24
 	 */
25
-	public function __construct( $block_deletes = true, $blocking_delete_error_message =''){
26
-		parent::__construct( 'Extra_Join', $block_deletes, $blocking_delete_error_message);
25
+	public function __construct($block_deletes = true, $blocking_delete_error_message = '') {
26
+		parent::__construct('Extra_Join', $block_deletes, $blocking_delete_error_message);
27 27
 	}
28 28
 
29 29
 
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 	 * @param $other_model_name
34 34
 	 * @throws EE_Error
35 35
 	 */
36
-	public function _construct_finalize_set_models( $this_model_name, $other_model_name){
37
-		if( $this_model_name < $other_model_name ) {
36
+	public function _construct_finalize_set_models($this_model_name, $other_model_name) {
37
+		if ($this_model_name < $other_model_name) {
38 38
 			$this->_alphabetically_first_model_name = $this_model_name;
39
-		} else{
39
+		} else {
40 40
 			$this->_alphabetically_first_model_name = $other_model_name;
41 41
 		}
42
-		parent::_construct_finalize_set_models( $this_model_name, $other_model_name );
42
+		parent::_construct_finalize_set_models($this_model_name, $other_model_name);
43 43
 	}
44 44
 
45 45
 
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 	 * @return EE_Model_Field_Base
51 51
 	 * @throws \EE_Error
52 52
 	 */
53
-	public function get_join_table_fk_field_to( $model_name, $id_or_name_field ) {
53
+	public function get_join_table_fk_field_to($model_name, $id_or_name_field) {
54 54
 		$order = null;
55
-		if( $model_name === $this->_alphabetically_first_model_name ) {
55
+		if ($model_name === $this->_alphabetically_first_model_name) {
56 56
 			$order = 'first';
57 57
 		} else {
58 58
 			$order = 'second';
59 59
 		}
60
-		return $this->get_join_model()->field_settings_for( 'EXJ_' . $order . '_model_' . $id_or_name_field );
60
+		return $this->get_join_model()->field_settings_for('EXJ_'.$order.'_model_'.$id_or_name_field);
61 61
 	}
62 62
 
63 63
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @return string of SQL
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	public function get_join_to_intermediate_model_statement($model_relation_chain){
72
+	public function get_join_to_intermediate_model_statement($model_relation_chain) {
73 73
 		//create sql like
74 74
 		//LEFT JOIN join_table AS join_table_alias ON this_table_alias.this_table_pk = join_table_alias.join_table_fk_to_this
75 75
 		//LEFT JOIN other_table AS other_table_alias ON join_table_alias.join_table_fk_to_other = other_table_alias.other_table_pk
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$field_with_model_name = $this->get_join_table_fk_field_to(
84 84
 				$this->get_this_model()->get_this_model_name(),
85 85
 				'name' );
86
-		$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_pk_field->get_table_alias();
87
-		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
86
+		$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_pk_field->get_table_alias();
87
+		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
88 88
 		$join_table = $this->get_join_model()->get_table_for_alias($join_table_alias);
89 89
 		//phew! ok, we have all the info we need, now we can create the SQL join string
90 90
 		$SQL = $this->_left_join(
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 					$join_table_fk_field_to_this_table->get_table_column(),
94 94
 					$this_table_alias,
95 95
 					$this_table_pk_field->get_table_column(),
96
-					$field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ) .
96
+					$field_with_model_name->get_qualified_column()."='".$this->get_this_model()->get_this_model_name()."'" ).
97 97
 				$this->get_join_model()->_construct_internal_join_to_table_with_alias($join_table_alias);
98 98
 
99 99
 		return $SQL;
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 	 * @return string of SQL
112 112
 	 * @throws \EE_Error
113 113
 	 */
114
-	public function get_join_statement($model_relation_chain){
115
-		if( $this->_model_relation_chain_to_join_model === NULL ){
116
-			throw new EE_Error( sprintf( __( 'When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso' )));
114
+	public function get_join_statement($model_relation_chain) {
115
+		if ($this->_model_relation_chain_to_join_model === NULL) {
116
+			throw new EE_Error(sprintf(__('When using EE_HABTM_Relation to create a join, you must call get_join_to_intermediate_model_statement BEFORE get_join_statement', 'event_espresso')));
117 117
 		}
118 118
 		$join_table_fk_field_to_this_table = $this->get_join_table_fk_field_to(
119 119
 				$this->get_this_model()->get_this_model_name(),
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 				$this->get_other_model()->get_this_model_name(),
126 126
 				'name' );
127 127
 
128
-		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()) . $join_table_fk_field_to_this_table->get_table_alias();
128
+		$join_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($this->_model_relation_chain_to_join_model, $this->get_join_model()->get_this_model_name()).$join_table_fk_field_to_this_table->get_table_alias();
129 129
 
130 130
 		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
131
-		$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();
131
+		$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();
132 132
 		$other_table = $this->get_other_model()->get_table_for_alias($other_table_alias);
133 133
 
134 134
 		$SQL = $this->_left_join(
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 					$join_table_alias,
139 139
 					$join_table_fk_field_to_other_table->get_table_column(),
140 140
 					$field_with_other_model_name->get_qualified_column()."='".$this->get_other_model()->get_this_model_name()."'"
141
-				) .
141
+				).
142 142
 				$this->get_other_model()->_construct_internal_join_to_table_with_alias($other_table_alias);
143 143
 		return $SQL;
144 144
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 * @return EE_Base_Class
155 155
 	 * @throws \EE_Error
156 156
 	 */
157
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
157
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
158 158
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
159 159
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
160 160
 		//check if such a relationship already exists
@@ -171,32 +171,32 @@  discard block
 block discarded – undo
171 171
 				$this->get_other_model()->get_this_model_name(),
172 172
 				'name' );
173 173
 
174
-		$cols_n_values =  array(
174
+		$cols_n_values = array(
175 175
 				$join_model_fk_to_this_model->get_name() => $this_model_obj->ID(),
176 176
 				$join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(),
177 177
 				$join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
178 178
 				$join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() );
179 179
 
180 180
 		//if $where_query exists lets add them to the query_params.
181
-		if ( !empty( $extra_join_model_fields_n_values ) ) {
181
+		if ( ! empty($extra_join_model_fields_n_values)) {
182 182
 		   //make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
183 183
 		   //make sure we strip THIS models name from the query param
184 184
 			$parsed_query = array();
185
-		   foreach ( $extra_join_model_fields_n_values as $query_param => $val ) {
186
-			   $query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param);
185
+		   foreach ($extra_join_model_fields_n_values as $query_param => $val) {
186
+			   $query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param);
187 187
 			   $parsed_query[$query_param] = $val;
188 188
 		   }
189
-		   $cols_n_values = array_merge( $cols_n_values, $parsed_query );
189
+		   $cols_n_values = array_merge($cols_n_values, $parsed_query);
190 190
 		}
191 191
 
192
-		$query_params = array( $cols_n_values );
192
+		$query_params = array($cols_n_values);
193 193
 
194 194
 
195 195
 		$existing_entry_in_join_table = $this->get_join_model()->get_one($query_params);
196 196
 		//if there is already an entry in the join table, indicating a relationship, we're done
197 197
 		 //again, if you want more sophisticated logic or insertions (handling more columns than just 2 foreign keys to
198 198
 		 //the other tables, use the joining model directly!
199
-		if( ! $existing_entry_in_join_table ){
199
+		if ( ! $existing_entry_in_join_table) {
200 200
 			$this->get_join_model()->insert($cols_n_values);
201 201
 		}
202 202
 		return $other_model_obj;
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @return EE_Base_Class
215 215
 	 * @throws \EE_Error
216 216
 	 */
217
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array() ){
217
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
218 218
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
219 219
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
220 220
 		//check if such a relationship already exists
@@ -231,25 +231,25 @@  discard block
 block discarded – undo
231 231
 				$this->get_other_model()->get_this_model_name(),
232 232
 				'name' );
233 233
 
234
-		$cols_n_values =  array(
234
+		$cols_n_values = array(
235 235
 				$join_model_fk_to_this_model->get_name() => $this_model_obj->ID(),
236 236
 				$join_model_name_field_to_this_model->get_name() => $this_model_obj->get_model()->get_this_model_name(),
237 237
 				$join_model_fk_to_other_model->get_name() => $other_model_obj->ID(),
238 238
 				$join_model_name_field_to_other_model->get_name() => $other_model_obj->get_model()->get_this_model_name() );
239 239
 
240 240
 		//if $where_query exists lets add them to the query_params.
241
-		if ( !empty( $where_query ) ) {
241
+		if ( ! empty($where_query)) {
242 242
 		 	//make sure we strip any of the join model names from the $where_query cause we don't need that in here (why? because client code may have used the same conditionals for get_all_related which DOES need the join model name)
243 243
 		 	//make sure we strip THIS models name from the query param
244 244
 			$parsed_query = array();
245
-			foreach ( $where_query as $query_param => $val ) {
246
-				$query_param = str_replace($this->get_join_model()->get_this_model_name().".","", $query_param);
245
+			foreach ($where_query as $query_param => $val) {
246
+				$query_param = str_replace($this->get_join_model()->get_this_model_name().".", "", $query_param);
247 247
 				$parsed_query[$query_param] = $val;
248 248
 			}
249
-		 	$cols_n_values = array_merge( $cols_n_values, $parsed_query );
249
+		 	$cols_n_values = array_merge($cols_n_values, $parsed_query);
250 250
 		}
251 251
 
252
-		$this->get_join_model()->delete( array($cols_n_values) );
252
+		$this->get_join_model()->delete(array($cols_n_values));
253 253
 		return $other_model_obj;
254 254
 	 }
255 255
 }
Please login to merge, or discard this patch.
core/db_models/relations/EE_Has_Many_Relation.php 1 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
 
5 5
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage    core
12 12
  * @author        Michael Nelson
13 13
  */
14
-class EE_Has_Many_Relation extends EE_Model_Relation_Base{
14
+class EE_Has_Many_Relation extends EE_Model_Relation_Base {
15 15
 
16 16
 	/**
17 17
 	 * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the foreign key
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model
22 22
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
23 23
 	 */
24
-	public function __construct($block_deletes = true, $blocking_delete_error_message = null){
24
+	public function __construct($block_deletes = true, $blocking_delete_error_message = null) {
25 25
 		parent::__construct($block_deletes, $blocking_delete_error_message);
26 26
 	}
27 27
 
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
 	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc
35 35
 	 * @throws \EE_Error
36 36
 	 */
37
-	public function get_join_statement( $model_relation_chain){
37
+	public function get_join_statement($model_relation_chain) {
38 38
 		//create the sql string like
39 39
 		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
40 40
 		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();
41 41
 		$other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
42
-		$pk_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_pk_field->get_table_alias();
43
-		$fk_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_fk_field->get_table_alias();
42
+		$pk_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_pk_field->get_table_alias();
43
+		$fk_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_fk_field->get_table_alias();
44 44
 		$fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
45 45
 
46 46
 		return $this->_left_join($fk_table, $fk_table_alias, $other_table_fk_field->get_table_column(), $pk_table_alias, $this_table_pk_field->get_table_column()).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @return \EE_Base_Class
58 58
 	 * @throws \EE_Error
59 59
 	 */
60
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
60
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
61 61
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
62 62
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
63 63
 
64 64
 		 //find the field on the other model which is a foreign key to this model
65 65
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
66
-		 if($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()){
66
+		 if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) {
67 67
 			//set that field on the other model to this model's ID
68 68
 			$other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID());
69 69
 			$other_model_obj->save();
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 	 * @return \EE_Base_Class
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
86
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
87 87
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
88 88
 		 //find the field on the other model which is a foreign key to this model
89 89
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
90 90
 		 //set that field on the other model to this model's ID
91
-		 $other_model_obj->set($fk_field_on_other_model->get_name(),null, true);
91
+		 $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
92 92
 		 $other_model_obj->save();
93 93
 		 return $other_model_obj;
94 94
 	 }
Please login to merge, or discard this patch.
core/db_models/relations/EE_Has_Many_Revision_Relation.php 1 patch
Spacing   +48 added lines, -48 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_Has_Many_Relation.php');
2
+require_once(EE_MODELS.'relations/EE_Has_Many_Relation.php');
3 3
 
4 4
 
5 5
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @subpackage    core
12 12
  * @author        Michael Nelson
13 13
  */
14
-class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation{
14
+class EE_Has_Many_Revision_Relation extends EE_Has_Many_Relation {
15 15
 
16 16
 
17 17
 	/**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param boolean $block_deletes For this type of relation, we block by default. If there are related models across this relation, block (prevent and add an error) the deletion of this model
45 45
 	 * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default
46 46
 	 */
47
-	public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null){
47
+	public function __construct($primary_cpt_field, $parent_pk_relation_field, $block_deletes = true, $blocking_delete_error_message = null) {
48 48
 		$this->_primary_cpt_field = $primary_cpt_field;
49 49
 		$this->_parent_pk_relation_field = $parent_pk_relation_field;
50 50
 		parent::__construct($block_deletes, $blocking_delete_error_message);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @return \EE_Base_Class
62 62
 	 * @throws \EE_Error
63 63
 	 */
64
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
64
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
65 65
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
66 66
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
67 67
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		 $other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj);
70 70
 
71 71
 		 //if is array, then we've already done the add_relation so let's get out
72
-		if ( is_array( $other_model_obj ) ){
72
+		if (is_array($other_model_obj)) {
73 73
 			return $other_model_obj[0];
74 74
 		}
75 75
 		 //find the field on the other model which is a foreign key to this model
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 	 * @return \EE_Base_Class
92 92
 	 * @throws \EE_Error
93 93
 	 */
94
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
94
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
95 95
 	 	$this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id);
96 96
 		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
97 97
 		//handle possible revisions
98
-		$other_model_obj = $this->_check_for_revision( $this_model_obj, $other_model_obj, TRUE );
98
+		$other_model_obj = $this->_check_for_revision($this_model_obj, $other_model_obj, TRUE);
99 99
 
100 100
 
101 101
 		//if is array, then we've already done the add_relation so let's get out
102
-		if ( is_array( $other_model_obj ) ){
102
+		if (is_array($other_model_obj)) {
103 103
 			return $other_model_obj[0];
104 104
 		}
105 105
 
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 
109 109
 
110 110
 		 //set that field on the other model to this model's ID
111
-		 if ( $this->_blocking_delete ) {
112
-		 	$other_model_obj->set($fk_field_on_other_model->get_name(),null,true);
111
+		 if ($this->_blocking_delete) {
112
+		 	$other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
113 113
 		 	$other_model_obj->save();
114 114
 		 } else {
115 115
 		 	$other_model_obj->delete();
116
-		 	$other_model_obj->set($fk_field_on_other_model->get_name(),null,true);
116
+		 	$other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
117 117
 		 	return $other_model_obj;
118 118
 		 }
119 119
 		 return $other_model_obj;
@@ -130,17 +130,17 @@  discard block
 block discarded – undo
130 130
 	 * @return EE_Base_Class[]
131 131
 	 * @throws \EE_Error
132 132
 	 */
133
-	 public function get_all_related( $model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false ) {
134
-		if( $values_already_prepared_by_model_object !== false ) {
135
-			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' );
133
+	 public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) {
134
+		if ($values_already_prepared_by_model_object !== false) {
135
+			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');
136 136
 		}
137 137
 
138 138
 	 	//if this is an autosave then we're going to get things differently
139
-	 	if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
140
-	 		return $this->_do_autosave_get_all($model_object_or_id, $query_params );
139
+	 	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
140
+	 		return $this->_do_autosave_get_all($model_object_or_id, $query_params);
141 141
 	 	}
142 142
 
143
-	 	return parent::get_all_related( $model_object_or_id, $query_params );
143
+	 	return parent::get_all_related($model_object_or_id, $query_params);
144 144
 	 }
145 145
 
146 146
 
@@ -156,22 +156,22 @@  discard block
 block discarded – undo
156 156
 	 * @return \EE_Base_Class[]
157 157
 	 * @throws \EE_Error
158 158
 	 */
159
-	 protected function _do_autosave_get_all( $model_object_or_id, $query_params, $deprecated = false ) {
159
+	 protected function _do_autosave_get_all($model_object_or_id, $query_params, $deprecated = false) {
160 160
 
161 161
 	 	//first we check if the post_id for the incoming query is for an autosave.  If it isn't that's what we want!
162
-	 	$model_object_id = $this->_get_model_object_id( $model_object_or_id );
162
+	 	$model_object_id = $this->_get_model_object_id($model_object_or_id);
163 163
 
164
-	 	$autosave = wp_get_post_autosave( $model_object_id );
164
+	 	$autosave = wp_get_post_autosave($model_object_id);
165 165
 	 	$id_to_use = $autosave ? $autosave->ID : $model_object_id;
166 166
 
167
-	 	$autosave_relations =  parent::get_all_related( $id_to_use, $query_params );
167
+	 	$autosave_relations = parent::get_all_related($id_to_use, $query_params);
168 168
 	 	$parent_ids = $parents = array();
169 169
 	 	$return_objs = array();
170 170
 
171 171
 		//k this is where things differ because NOW what we're going to do is get the PARENTS for the get all related (and we'll also start setting up the return_objs array containing related that DON'T have parent ids, for those that DON'T have parents to merge with our returned objects);
172
-		foreach ( $autosave_relations as $a_r ) {
172
+		foreach ($autosave_relations as $a_r) {
173 173
 			$pid = $a_r->parent();
174
-			if ( !empty( $pid ) ) {
174
+			if ( ! empty($pid)) {
175 175
 				$parent_ids[] = $pid;
176 176
 			} else {
177 177
 				$return_objs[] = $a_r;
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 		}
180 180
 
181 181
 		//we have to make sure we also include the ORIGINAL values
182
-		$originals = parent::get_all_related($model_object_or_id, $query_params );
182
+		$originals = parent::get_all_related($model_object_or_id, $query_params);
183 183
 
184 184
 		//merge $originals with $return_objs
185
-		if ( $originals ) {
185
+		if ($originals) {
186 186
 			$return_objs = array_merge($originals, $return_objs);
187 187
 		}
188 188
 
189 189
 		//now we setup the query to get all the parents
190
-		if ( !empty( $parent_ids ) ) {
190
+		if ( ! empty($parent_ids)) {
191 191
 			$query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name();
192
-			$query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids );
192
+			$query_param[0][$query_param_where_this_model_pk] = array('IN', $parent_ids);
193 193
 			$parents = $this->get_other_model()->get_all($query_params);
194 194
 		}
195 195
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
 
199 199
 		//now merge parents with our current $return_objs and send back
200
-		return array_merge( $parents, $return_objs );
200
+		return array_merge($parents, $return_objs);
201 201
 	 }
202 202
 
203 203
 
@@ -211,42 +211,42 @@  discard block
 block discarded – undo
211 211
 	 * @return EE_Base_Class. ($other_obj);
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	protected function _check_for_revision( $this_obj, $other_obj, $remove_relation = FALSE ) {
214
+	protected function _check_for_revision($this_obj, $other_obj, $remove_relation = FALSE) {
215 215
 		$pk_on_related_model = $this->get_other_model()->get_primary_key_field()->get_name();
216 216
 		//now we need to determine if we're in a WP revision save cause if we are we need to do some special handling
217
-		if (  $this_obj->post_type() === 'revision' ) {
217
+		if ($this_obj->post_type() === 'revision') {
218 218
 			//first if $other_obj fk = this_obj pk then we know that this is a pk object, let's make sure there is a matching set for the autosave if there is then we save over it, if there isn't then we need to create a new one.
219 219
 			$parent_evt_id = $this_obj->parent();
220 220
 			/*var_dump($parent_evt_id);
221 221
 			var_dump($this_obj);
222 222
 			var_dump($other_obj);/**/
223 223
 
224
-			if ( !empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field) ) {
224
+			if ( ! empty($parent_evt_id) && $parent_evt_id == $other_obj->get($this->_primary_cpt_field)) {
225 225
 				//let's do query on this objects model to see if the incoming pk value on the obj matches any parents in this objects table.
226
-				$has_parent_obj = $this->get_other_model()->get_one( array( array( $this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID() ) ) );
226
+				$has_parent_obj = $this->get_other_model()->get_one(array(array($this->_parent_pk_relation_field => $other_obj->ID(), $this->_primary_cpt_field => $this_obj->ID())));
227 227
 
228
-				if ( $has_parent_obj ) {
228
+				if ($has_parent_obj) {
229 229
 					//this makes sure the update on the current obj happens to the revision's row NOT the parent row.
230 230
 
231
-					$other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID());
232
-					$other_obj->set($pk_on_related_model, $has_parent_obj->ID() );
231
+					$other_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
232
+					$other_obj->set($pk_on_related_model, $has_parent_obj->ID());
233 233
 					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
234 234
 
235
-					if ( !$remove_relation ) {
235
+					if ( ! $remove_relation) {
236 236
 						$other_obj->save();
237
-						return array( $other_obj );
238
-					} elseif ( $remove_relation && !$this->_blocking_delete) {
237
+						return array($other_obj);
238
+					} elseif ($remove_relation && ! $this->_blocking_delete) {
239 239
 						$other_obj->delete();
240 240
 						$other_obj->set($this->_parent_pk_relation_field, NULL, true);
241 241
 						return array($other_obj);
242 242
 					}
243 243
 
244 244
 				} else {
245
-					$other_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() );
246
-					$other_obj->set( $this->_primary_cpt_field, $this_obj->ID() );
245
+					$other_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
246
+					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
247 247
 					$other_obj->set($pk_on_related_model, NULL, true); //ensure we create a new row for the autosave with parent id the same as the incoming ID.
248 248
 					$other_obj->save(); //make sure we insert.
249
-					return array( $other_obj );
249
+					return array($other_obj);
250 250
 				}
251 251
 			}
252 252
 
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
 		} else {
260 260
 
261 261
 			//we only need to do the below IF this is not a remove relation
262
-			if ( !$remove_relation ) {
262
+			if ( ! $remove_relation) {
263 263
 				//okay this is is a normal update/save/remove so, let's make sure the other object is not a revision of the current object.
264 264
 				//the other object will likely NOT have the correct fk on it (which is the primary_cpt_field_mame) so we must retrieve from the db to get that first.
265 265
 				$existing_other_obj = $this->get_other_model()->get_one_by_ID($other_obj->ID());
266 266
 				$potential_revision_id = is_object($existing_other_obj) ? $existing_other_obj->get($this->_primary_cpt_field) : NULL;
267 267
 
268
-				if ( $parent_this_obj_id = wp_is_post_revision($potential_revision_id) ) {
268
+				if ($parent_this_obj_id = wp_is_post_revision($potential_revision_id)) {
269 269
 					//yes the OTHER object is linked to the revision of the parent, not the parent itself. That means we need to make the other_object an attachment of this_obj and then duplicate other_obj for the revision.
270
-					$other_obj->set($this->_primary_cpt_field, $this_obj->ID() );
270
+					$other_obj->set($this->_primary_cpt_field, $this_obj->ID());
271 271
 					$other_obj->save();
272 272
 
273 273
 					//now create a new other_obj and fill with details from existing object
274 274
 					$new_obj = $other_obj;
275
-					$new_obj->set( $this->_primary_cpt_field, $potential_revision_id );
276
-					$new_obj->set( $this->_parent_pk_relation_field, $other_obj->ID() );
277
-					$new_obj->set( $pk_on_related_model, NULL );
275
+					$new_obj->set($this->_primary_cpt_field, $potential_revision_id);
276
+					$new_obj->set($this->_parent_pk_relation_field, $other_obj->ID());
277
+					$new_obj->set($pk_on_related_model, NULL);
278 278
 					$new_obj->save();
279
-					return array( $new_obj );
279
+					return array($new_obj);
280 280
 				}
281 281
 
282 282
 			}
Please login to merge, or discard this patch.
core/db_models/relations/EE_Belongs_To_Any_Relation.php 1 patch
Spacing   +6 added lines, -6 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_Belongs_To_Relation.php');
2
+require_once(EE_MODELS.'relations/EE_Belongs_To_Relation.php');
3 3
 
4 4
 
5 5
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @return string
24 24
 	 * @throws \EE_Error
25 25
 	 */
26
-	public function get_join_statement( $model_relation_chain) {
26
+	public function get_join_statement($model_relation_chain) {
27 27
 		//create the sql string like
28 28
 		$this_table_fk_field = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
29 29
 		//ALSO, need to get the field with the model name
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 		$other_table_pk_field = $this->get_other_model()->get_primary_key_field();
34
-		$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();
35
-		$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();
34
+		$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();
35
+		$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();
36 36
 		$other_table = $this->get_other_model()->get_table_for_alias($other_table_alias);
37 37
 		return $this->_left_join($other_table,
38 38
 				$other_table_alias,
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
82 82
 		$this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
83
-		$other_model_obj = $this->get_other_model()->ensure_is_obj( $other_obj_or_id );
83
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id);
84 84
 		//find the field on the other model which is a foreign key to this model
85 85
 		$fk_on_this_model = $this->get_this_model()->get_foreign_key_to($this->get_other_model()->get_this_model_name());
86 86
 		//set that field on the other model to this model's ID
87 87
 		$this_model_obj->set($fk_on_this_model->get_name(), null, true);
88
-		$this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(),null,true);
88
+		$this_model_obj->set($this->get_this_model()->get_field_containing_related_model_name()->get_name(), null, true);
89 89
 		$this_model_obj->save();
90 90
 		return $other_model_obj;
91 91
 	}
Please login to merge, or discard this patch.
core/db_models/relations/EE_Has_Many_Any_Relation.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 /*
5 5
  *
6 6
  */
7
-require_once( EE_MODELS . 'relations/EE_Model_Relation_Base.php');
7
+require_once(EE_MODELS.'relations/EE_Model_Relation_Base.php');
8 8
 
9 9
 
10 10
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @subpackage    core
20 20
  * @author        Michael Nelson
21 21
  */
22
-class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation{
22
+class EE_Has_Many_Any_Relation extends EE_Has_Many_Relation {
23 23
 
24 24
 	/**
25 25
 	 * Gets the SQL string for performing the join between this model and the other model.
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk = other_model_primary_table.fk" etc
29 29
 	 * @throws \EE_Error
30 30
 	 */
31
-	public function get_join_statement( $model_relation_chain){
31
+	public function get_join_statement($model_relation_chain) {
32 32
 		//create the sql string like
33 33
 		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
34 34
 		$this_table_pk_field = $this->get_this_model()->get_primary_key_field();
35 35
 		$other_table_fk_field = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
36
-		$pk_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_pk_field->get_table_alias();
37
-		$fk_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_fk_field->get_table_alias();
36
+		$pk_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_pk_field->get_table_alias();
37
+		$fk_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_fk_field->get_table_alias();
38 38
 		$fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
39 39
 		$field_with_model_name = $this->get_other_model()->get_field_containing_related_model_name();
40 40
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 				$other_table_fk_field->get_table_column(),
44 44
 				$pk_table_alias,
45 45
 				$this_table_pk_field->get_table_column(),
46
-				$fk_table_alias . '.' . $field_with_model_name->get_table_column() . "='" . $this->get_this_model()->get_this_model_name() . "'" )
46
+				$fk_table_alias.'.'.$field_with_model_name->get_table_column()."='".$this->get_this_model()->get_this_model_name()."'")
47 47
 				.$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
48 48
 	}
49 49
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return \EE_Base_Class
59 59
 	 * @throws \EE_Error
60 60
 	 */
61
-	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array() ){
61
+	public function add_relation_to($this_obj_or_id, $other_obj_or_id, $extra_join_model_fields_n_values = array()) {
62 62
 		 $this_model_obj = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
63 63
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
64 64
 
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 	 * @return \EE_Base_Class
84 84
 	 * @throws \EE_Error
85 85
 	 */
86
-	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()){
86
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, $where_query = array()) {
87 87
 		 $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
88 88
 		 //find the field on the other model which is a foreign key to this model
89 89
 		 $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
90 90
 		 //set that field on the other model to this model's ID
91
-		 $other_model_obj->set($fk_field_on_other_model->get_name(),null, true);
91
+		 $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
92 92
 		 $other_model_obj->set($this->get_other_model()->get_field_containing_related_model_name()->get_name(), null, true);
93 93
 		 $other_model_obj->save();
94 94
 		 return $other_model_obj;
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 3 patches
Braces   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -131,8 +131,7 @@  discard block
 block discarded – undo
131 131
 				return;
132 132
 			}
133 133
 			echo '<h5>For Tag: '. $tag .'</h5>';
134
-		}
135
-		else {
134
+		} else {
136 135
 			$hook=$wp_filter;
137 136
 			ksort( $hook );
138 137
 		}
@@ -200,7 +199,7 @@  discard block
 block discarded – undo
200 199
 		if( isset( $this->_start_times[ $timer_name ] ) ){
201 200
 			$start_time = $this->_start_times[ $timer_name ];
202 201
 			unset( $this->_start_times[ $timer_name ] );
203
-		}else{
202
+		} else{
204 203
 			$start_time = array_pop( $this->_start_times );
205 204
 		}
206 205
 		$total_time = microtime( TRUE ) - $start_time;
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 	/**
189 189
 	 * 	start_timer
190
-	 * @param null $timer_name
190
+	 * @param string $timer_name
191 191
 	 */
192 192
 	public function start_timer( $timer_name = NULL ){
193 193
 		$this->_start_times[$timer_name] = microtime( TRUE );
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 	/**
447
-	 * @param mixed  $var
447
+	 * @param string  $var
448 448
 	 * @param string $var_name
449 449
 	 * @param string $file
450 450
 	 * @param int    $line
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 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
  * Class EEH_Debug_Tools
4 4
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since 				4.0
9 9
  *
10 10
  */
11
-class EEH_Debug_Tools{
11
+class EEH_Debug_Tools {
12 12
 
13 13
 	/**
14 14
 	 * 	instance of the EEH_Autoloader object
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function instance() {
43 43
 		// check if class object is instantiated, and instantiated properly
44
-		if ( ! self::$_instance instanceof EEH_Debug_Tools ) {
44
+		if ( ! self::$_instance instanceof EEH_Debug_Tools) {
45 45
 			self::$_instance = new self();
46 46
 		}
47 47
 		return self::$_instance;
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	private function __construct() {
59 59
 		// load Kint PHP debugging library
60
-		if ( ! class_exists( 'Kint' ) &&  file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){
60
+		if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
61 61
 			// despite EE4 having a check for an existing copy of the Kint debugging class,
62 62
 			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
63 63
 			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
64 64
 			// so we've moved it to our test folder so that it is not included with production releases
65 65
 			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
66
-			require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' );
66
+			require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
67 67
 		}
68 68
 		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
69 69
 			//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
70 70
 		// }
71
-		$plugin = basename( EE_PLUGIN_DIR_PATH );
72
-		add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
73
-		add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
74
-		add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' ));
71
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
72
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
73
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
74
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
75 75
 	}
76 76
 
77 77
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * 	@return void
83 83
 	 */
84 84
 	public static function show_db_name() {
85
-		if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) {
86
-			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>';
85
+		if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
86
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>';
87 87
 		}
88
-		if ( EE_DEBUG ) {
88
+		if (EE_DEBUG) {
89 89
 			EEH_Debug_Tools::instance()->show_times();
90 90
 		}
91 91
 	}
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function espresso_session_footer_dump() {
101 101
 		if (
102
-			( defined( 'WP_DEBUG' ) && WP_DEBUG )
103
-			&& ! defined( 'DOING_AJAX' )
104
-			&& class_exists( 'Kint' )
105
-			&& function_exists( 'wp_get_current_user' )
106
-			&& current_user_can( 'update_core' )
107
-			&& class_exists( 'EE_Registry' )
102
+			(defined('WP_DEBUG') && WP_DEBUG)
103
+			&& ! defined('DOING_AJAX')
104
+			&& class_exists('Kint')
105
+			&& function_exists('wp_get_current_user')
106
+			&& current_user_can('update_core')
107
+			&& class_exists('EE_Registry')
108 108
 		) {
109
-			Kint::dump(  EE_Registry::instance()->SSN->id() );
110
-			Kint::dump( EE_Registry::instance()->SSN );
109
+			Kint::dump(EE_Registry::instance()->SSN->id());
110
+			Kint::dump(EE_Registry::instance()->SSN);
111 111
 			//			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
112 112
 			$this->espresso_list_hooked_functions();
113 113
 			$this->show_times();
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 	 * @param string $tag
125 125
 	 * @return void
126 126
 	 */
127
-	public function espresso_list_hooked_functions( $tag='' ){
127
+	public function espresso_list_hooked_functions($tag = '') {
128 128
 		global $wp_filter;
129 129
 		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
130
-		if ( $tag ) {
131
-			$hook[$tag]=$wp_filter[$tag];
132
-			if ( ! is_array( $hook[$tag] )) {
133
-				trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING );
130
+		if ($tag) {
131
+			$hook[$tag] = $wp_filter[$tag];
132
+			if ( ! is_array($hook[$tag])) {
133
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
134 134
 				return;
135 135
 			}
136
-			echo '<h5>For Tag: '. $tag .'</h5>';
136
+			echo '<h5>For Tag: '.$tag.'</h5>';
137 137
 		}
138 138
 		else {
139
-			$hook=$wp_filter;
140
-			ksort( $hook );
139
+			$hook = $wp_filter;
140
+			ksort($hook);
141 141
 		}
142
-		foreach( $hook as $tag_name => $priorities ) {
142
+		foreach ($hook as $tag_name => $priorities) {
143 143
 			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
144
-			ksort( $priorities );
145
-			foreach( $priorities as $priority => $function ){
144
+			ksort($priorities);
145
+			foreach ($priorities as $priority => $function) {
146 146
 				echo $priority;
147
-				foreach( $function as $name => $properties ) {
147
+				foreach ($function as $name => $properties) {
148 148
 					echo "\t$name<br />";
149 149
 				}
150 150
 			}
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 	 * @param string $hook_name
160 160
 	 * @return array
161 161
 	 */
162
-	public static function registered_filter_callbacks( $hook_name = '' ) {
162
+	public static function registered_filter_callbacks($hook_name = '') {
163 163
 		$filters = array();
164 164
 		global $wp_filter;
165
-		if ( isset( $wp_filter[ $hook_name ] ) ) {
166
-			$filters[ $hook_name ] = array();
167
-			foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) {
168
-				$filters[ $hook_name ][ $priority ] = array();
169
-				foreach ( $callbacks as $callback ) {
170
-					$filters[ $hook_name ][ $priority ][] = $callback['function'];
165
+		if (isset($wp_filter[$hook_name])) {
166
+			$filters[$hook_name] = array();
167
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
168
+				$filters[$hook_name][$priority] = array();
169
+				foreach ($callbacks as $callback) {
170
+					$filters[$hook_name][$priority][] = $callback['function'];
171 171
 				}
172 172
 			}
173 173
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * reset_times
181 181
 	 */
182
-	public function reset_times(){
182
+	public function reset_times() {
183 183
 		$this->_times = array();
184 184
 	}
185 185
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * 	start_timer
190 190
 	 * @param null $timer_name
191 191
 	 */
192
-	public function start_timer( $timer_name = NULL ){
193
-		$this->_start_times[$timer_name] = microtime( TRUE );
192
+	public function start_timer($timer_name = NULL) {
193
+		$this->_start_times[$timer_name] = microtime(TRUE);
194 194
 	}
195 195
 
196 196
 
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 	 * stop_timer
200 200
 	 * @param string $timer_name
201 201
 	 */
202
-	public function stop_timer( $timer_name = '' ){
202
+	public function stop_timer($timer_name = '') {
203 203
 		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
204
-		if( isset( $this->_start_times[ $timer_name ] ) ){
205
-			$start_time = $this->_start_times[ $timer_name ];
206
-			unset( $this->_start_times[ $timer_name ] );
207
-		}else{
208
-			$start_time = array_pop( $this->_start_times );
204
+		if (isset($this->_start_times[$timer_name])) {
205
+			$start_time = $this->_start_times[$timer_name];
206
+			unset($this->_start_times[$timer_name]);
207
+		} else {
208
+			$start_time = array_pop($this->_start_times);
209 209
 		}
210
-		$this->_times[ $timer_name ] =  number_format( microtime( true ) - $start_time, 8 );
210
+		$this->_times[$timer_name] = number_format(microtime(true) - $start_time, 8);
211 211
 	}
212 212
 
213 213
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
218 218
 	 * @return void
219 219
 	 */
220
-	public function measure_memory( $label, $output_now = false ) {
221
-		$memory_used = $this->convert( memory_get_peak_usage( true ) );
222
-		$this->_memory_usage_points[ $label ] = $memory_used;
223
-		if( $output_now ) {
220
+	public function measure_memory($label, $output_now = false) {
221
+		$memory_used = $this->convert(memory_get_peak_usage(true));
222
+		$this->_memory_usage_points[$label] = $memory_used;
223
+		if ($output_now) {
224 224
 			echo "\r\n<br>$label : $memory_used";
225 225
 		}
226 226
 	}
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	 * @param int $size
231 231
 	 * @return string
232 232
 	 */
233
-	public function convert( $size ) {
234
-		$unit=array('b','kb','mb','gb','tb','pb');
235
-		return @round( $size / pow( 1024, $i = floor( log( $size, 1024 ) ) ), 2 ) . ' ' . $unit[ absint( $i ) ];
233
+	public function convert($size) {
234
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
235
+		return @round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)];
236 236
 	}
237 237
 
238 238
 
@@ -242,25 +242,25 @@  discard block
 block discarded – undo
242 242
 	 * @param bool $output_now
243 243
 	 * @return string
244 244
 	 */
245
-	public function show_times($output_now=true){
245
+	public function show_times($output_now = true) {
246 246
 		$output = '';
247
-		if ( ! empty( $this->_times )) {
247
+		if ( ! empty($this->_times)) {
248 248
 			$total = 0;
249 249
 			$output .= '<h2 style="margin:1em .5em 0;">Times:</h2>';
250 250
 			$output .= '<span style="color:#9999CC; font-size:.8em; margin:0 1.5em 0;">( in milliseconds )</span><br />';
251
-			foreach( $this->_times as $timer_name => $total_time ) {
252
-				$output .= $this->format_time( $timer_name, $total_time );
251
+			foreach ($this->_times as $timer_name => $total_time) {
252
+				$output .= $this->format_time($timer_name, $total_time);
253 253
 				$total += $total_time;
254 254
 			}
255 255
 			$output .= '<br />';
256 256
 			$output .= '<h4 style="margin:1em .5em 0;">TOTAL TIME</h4>';
257
-			$output .= $this->format_time( '', $total );
257
+			$output .= $this->format_time('', $total);
258 258
 			$output .= '<br />';
259 259
 		}
260
-		if ( ! empty( $this->_memory_usage_points )) {
261
-			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>' . implode( '<br />', $this->_memory_usage_points );
260
+		if ( ! empty($this->_memory_usage_points)) {
261
+			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>'.implode('<br />', $this->_memory_usage_points);
262 262
 		}
263
-		if( $output_now ){
263
+		if ($output_now) {
264 264
 			echo $output;
265 265
 			return '';
266 266
 		}
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 * @param float $total_time
275 275
 	 * @return string
276 276
 	 */
277
-	public function format_time( $timer_name, $total_time ) {
277
+	public function format_time($timer_name, $total_time) {
278 278
 		$total_time = $total_time * 1000;
279
-		switch ( $total_time ) {
279
+		switch ($total_time) {
280 280
 			case $total_time < 0.01 :
281 281
 				$color = '#8A549A';
282 282
 				$bold = 'normal';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			. '; font-weight:'
308 308
 			. $bold
309 309
 			. '; font-size:1.2em;">'
310
-			. str_pad( number_format( $total_time, 5 ), 11, '0', STR_PAD_LEFT )
310
+			. str_pad(number_format($total_time, 5), 11, '0', STR_PAD_LEFT)
311 311
 			. '</span> '
312 312
 			. $timer_name
313 313
 			. '<br />';
@@ -321,25 +321,25 @@  discard block
 block discarded – undo
321 321
 	 * 	@return void
322 322
 	 */
323 323
 	public static function ee_plugin_activation_errors() {
324
-		if ( WP_DEBUG ) {
324
+		if (WP_DEBUG) {
325 325
 			$activation_errors = ob_get_contents();
326
-			if ( ! empty( $activation_errors ) ) {
327
-				$activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors;
326
+			if ( ! empty($activation_errors)) {
327
+				$activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
328 328
 			}
329
-			espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' );
330
-			if ( class_exists( 'EEH_File' )) {
329
+			espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
330
+			if (class_exists('EEH_File')) {
331 331
 				try {
332
-					EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' );
333
-					EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
334
-				} catch( EE_Error $e ){
335
-					EE_Error::add_error( sprintf( __(  'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
332
+					EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html');
333
+					EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
334
+				} catch (EE_Error $e) {
335
+					EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
336 336
 				}
337 337
 			} else {
338 338
 				// old school attempt
339
-				file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
339
+				file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
340 340
 			}
341
-			$activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors;
342
-			update_option( 'ee_plugin_activation_errors', $activation_errors );
341
+			$activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
342
+			update_option('ee_plugin_activation_errors', $activation_errors);
343 343
 		}
344 344
 	}
345 345
 
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
 	 * @param int     $error_type
356 356
 	 * @uses trigger_error()
357 357
 	 */
358
-	public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
359
-		do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
-		$version = $version === null ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version );
361
-		$error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version );
358
+	public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
359
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
+		$version = $version === null ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version);
361
+		$error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version);
362 362
 
363 363
 		//don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request.
364
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
365
-			$error_message .= ' ' . esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso' );
364
+		if (defined('DOING_AJAX') && DOING_AJAX) {
365
+			$error_message .= ' '.esc_html__('This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso');
366 366
 			$error_message .= '<ul><li>';
367
-			$error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() );
367
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
368 368
 			$error_message .= '</ul>';
369
-			EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' );
369
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
370 370
 			//now we set this on the transient so it shows up on the next request.
371
-			EE_Error::get_notices( false, true );
371
+			EE_Error::get_notices(false, true);
372 372
 		} else {
373
-			trigger_error( $error_message, $error_type );
373
+			trigger_error($error_message, $error_type);
374 374
 		}
375 375
 	}
376 376
 
@@ -392,22 +392,22 @@  discard block
 block discarded – undo
392 392
 	 * @param string $debug_index
393 393
 	 * @param string $debug_key
394 394
 	 */
395
-	public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false,  $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) {
396
-		if ( WP_DEBUG && false ) {
397
-			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
398
-			$debug_data = get_option( $debug_key, array() );
395
+	public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') {
396
+		if (WP_DEBUG && false) {
397
+			$debug_key = $debug_key.'_'.EE_Session::instance()->id();
398
+			$debug_data = get_option($debug_key, array());
399 399
 			$default_data = array(
400
-				$class => $func . '() : ' . $line,
400
+				$class => $func.'() : '.$line,
401 401
 				'REQ'  => $display_request ? $_REQUEST : '',
402 402
 			);
403 403
 			// don't serialize objects
404
-			$info = self::strip_objects( $info );
405
-			$index = ! empty( $debug_index ) ? $debug_index : 0;
406
-			if ( ! isset( $debug_data[$index] ) ) {
404
+			$info = self::strip_objects($info);
405
+			$index = ! empty($debug_index) ? $debug_index : 0;
406
+			if ( ! isset($debug_data[$index])) {
407 407
 				$debug_data[$index] = array();
408 408
 			}
409
-			$debug_data[$index][microtime()] = array_merge( $default_data, $info );
410
-			update_option( $debug_key, $debug_data );
409
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
410
+			update_option($debug_key, $debug_data);
411 411
 		}
412 412
 	}
413 413
 
@@ -419,26 +419,26 @@  discard block
 block discarded – undo
419 419
 	 * @param array $info
420 420
 	 * @return array
421 421
 	 */
422
-	public static function strip_objects( $info = array() ) {
423
-		foreach ( $info as $key => $value ) {
424
-			if ( is_array( $value ) ) {
425
-				$info[ $key ] = self::strip_objects( $value );
426
-			} else if ( is_object( $value ) ) {
427
-				$object_class = get_class( $value );
428
-				$info[ $object_class ] = array();
429
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value );
430
-				if ( method_exists( $value, 'ID' ) ) {
431
-					$info[ $object_class ][ 'ID' ] = $value->ID();
422
+	public static function strip_objects($info = array()) {
423
+		foreach ($info as $key => $value) {
424
+			if (is_array($value)) {
425
+				$info[$key] = self::strip_objects($value);
426
+			} else if (is_object($value)) {
427
+				$object_class = get_class($value);
428
+				$info[$object_class] = array();
429
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
430
+				if (method_exists($value, 'ID')) {
431
+					$info[$object_class]['ID'] = $value->ID();
432 432
 				}
433
-				if ( method_exists( $value, 'status' ) ) {
434
-					$info[ $object_class ][ 'status' ] = $value->status();
435
-				} else if ( method_exists( $value, 'status_ID' ) ) {
436
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
433
+				if (method_exists($value, 'status')) {
434
+					$info[$object_class]['status'] = $value->status();
435
+				} else if (method_exists($value, 'status_ID')) {
436
+					$info[$object_class]['status'] = $value->status_ID();
437 437
 				}
438
-				unset( $info[ $key ] );
438
+				unset($info[$key]);
439 439
 			}
440 440
 		}
441
-		return (array)$info;
441
+		return (array) $info;
442 442
 	}
443 443
 
444 444
 
@@ -451,23 +451,23 @@  discard block
 block discarded – undo
451 451
 	 * @param int    $header
452 452
 	 * @param bool   $die
453 453
 	 */
454
-	public static function printv( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
454
+	public static function printv($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
455 455
 		$var_name = ! $var_name ? 'string' : $var_name;
456 456
 		$heading_tag = 'h';
457
-		$heading_tag .= is_int( $header ) ? $header : 5;
458
-		$var_name = ucwords( str_replace( '$', '', $var_name ) );
459
-		$is_method = method_exists( $var_name, $var );
460
-		$var_name = ucwords( str_replace( '_', ' ', $var_name ) );
457
+		$heading_tag .= is_int($header) ? $header : 5;
458
+		$var_name = ucwords(str_replace('$', '', $var_name));
459
+		$is_method = method_exists($var_name, $var);
460
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
461 461
 		$margin = is_admin() ? ' 180px' : '0';
462
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0' . $margin . ';"><b>' . $var_name . '</b>';
462
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>';
463 463
 		$result .= $is_method
464
-			? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />'
465
-			: '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />';
466
-		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file;
467
-		$result .= '<br />line no: ' . $line . '</span>';
468
-		$result .= '</' . $heading_tag . '>';
469
-		if ( $die ) {
470
-			die( $result );
464
+			? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />'
465
+			: '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />';
466
+		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file;
467
+		$result .= '<br />line no: '.$line.'</span>';
468
+		$result .= '</'.$heading_tag.'>';
469
+		if ($die) {
470
+			die($result);
471 471
 		} else {
472 472
 			echo $result;
473 473
 		}
@@ -482,36 +482,36 @@  discard block
 block discarded – undo
482 482
 	 * @param int $header
483 483
 	 * @param bool $die
484 484
 	 */
485
-	public static function printr( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
485
+	public static function printr($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
486 486
 		// return;
487
-		$file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file );
487
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
488 488
 		//$print_r = false;
489
-		if ( is_string( $var ) ) {
490
-			EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die );
489
+		if (is_string($var)) {
490
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die);
491 491
 			return;
492
-		} else if ( is_object( $var ) ) {
492
+		} else if (is_object($var)) {
493 493
 			$var_name = ! $var_name ? 'object' : $var_name;
494 494
 			//$print_r = true;
495
-		} else if ( is_array( $var ) ) {
495
+		} else if (is_array($var)) {
496 496
 			$var_name = ! $var_name ? 'array' : $var_name;
497 497
 			//$print_r = true;
498
-		} else if ( is_numeric( $var ) ) {
498
+		} else if (is_numeric($var)) {
499 499
 			$var_name = ! $var_name ? 'numeric' : $var_name;
500
-		} else if ( is_null( $var ) ) {
500
+		} else if (is_null($var)) {
501 501
 			$var_name = ! $var_name ? 'null' : $var_name;
502 502
 		}
503 503
 		$heading_tag = 'h';
504
-		$heading_tag .= is_int( $header ) ? $header : 5;
505
-		$var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) );
504
+		$heading_tag .= is_int($header) ? $header : 5;
505
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
506 506
 		$margin = is_admin() ? ' 180px' : '0';
507
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>' . $var_name . '</b>';
507
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0'.$margin.';"><b>'.$var_name.'</b>';
508 508
 		$result .= '<span style="color:#999;"> : </span><span style="color:#E76700;">';
509 509
 		$result .= '<pre style="color:#999; padding:1em; background: #fff">';
510
-		$result .= var_export( $var, true );
511
-		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">' . $file;
512
-		$result .= '<br />line no: ' . $line . '</span></' . $heading_tag . '>';
513
-		if ( $die ) {
514
-			die( $result );
510
+		$result .= var_export($var, true);
511
+		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;'.$margin.'">'.$file;
512
+		$result .= '<br />line no: '.$line.'</span></'.$heading_tag.'>';
513
+		if ($die) {
514
+			die($result);
515 515
 		} else {
516 516
 			echo $result;
517 517
 		}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
  * borrowed from Kint Debugger
529 529
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
530 530
  */
531
-if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) {
532
-	function dump_wp_query(){
531
+if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
532
+	function dump_wp_query() {
533 533
 		global $wp_query;
534 534
 		d($wp_query);
535 535
 	}
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
  * borrowed from Kint Debugger
540 540
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
541 541
  */
542
-if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) {
543
-	function dump_wp(){
542
+if (class_exists('Kint') && ! function_exists('dump_wp')) {
543
+	function dump_wp() {
544 544
 		global $wp;
545 545
 		d($wp);
546 546
 	}
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
  * borrowed from Kint Debugger
551 551
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
552 552
  */
553
-if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) {
554
-	function dump_post(){
553
+if (class_exists('Kint') && ! function_exists('dump_post')) {
554
+	function dump_post() {
555 555
 		global $post;
556 556
 		d($post);
557 557
 	}
Please login to merge, or discard this patch.
core/EE_Cron_Tasks.core.php 2 patches
Indentation   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param int $PAY_ID
157 157
 	 */
158 158
 	public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) {
159
-            do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
159
+			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
160 160
 		if ( absint( $TXN_ID )) {
161 161
 			self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
162 162
 			add_action(
@@ -289,7 +289,6 @@  discard block
 block discarded – undo
289 289
 
290 290
 	/**
291 291
 	 * finalize_abandoned_transactions
292
-	 
293 292
 	 * loops through the self::$_abandoned_transactions array
294 293
 	 * and attempts to finalize any TXNs that have not been completed
295 294
 	 * but have had their sessions expired, most likely due to a user not
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return EE_Cron_Tasks
29 29
 	 */
30 30
 	public static function instance() {
31
-		if ( ! self::$_instance instanceof EE_Cron_Tasks ) {
31
+		if ( ! self::$_instance instanceof EE_Cron_Tasks) {
32 32
 			self::$_instance = new self();
33 33
 		}
34 34
 		return self::$_instance;
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 * @return EE_Cron_Tasks
42 42
 	 */
43 43
 	private function __construct() {
44
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
44
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
45 45
 		// verify that WP Cron is enabled
46
-		if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON && is_admin() ) {
46
+		if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON && is_admin()) {
47 47
 			EE_Error::add_persistent_admin_notice(
48 48
 				'wp_cron_disabled',
49 49
 				sprintf(
@@ -58,26 +58,26 @@  discard block
 block discarded – undo
58 58
 		// UPDATE TRANSACTION WITH PAYMENT
59 59
 		add_action(
60 60
 			'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
61
-			array( 'EE_Cron_Tasks', 'setup_update_for_transaction_with_payment' ),
61
+			array('EE_Cron_Tasks', 'setup_update_for_transaction_with_payment'),
62 62
 			10, 2
63 63
 		);
64 64
 		// FINALIZE ABANDONED TRANSACTIONS
65 65
 		add_action(
66 66
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
67
-			array( 'EE_Cron_Tasks', 'check_for_abandoned_transactions' ),
67
+			array('EE_Cron_Tasks', 'check_for_abandoned_transactions'),
68 68
 			10, 1
69 69
 		);
70 70
 		// CLEAN OUT JUNK TRANSACTIONS AND RELATED DATA
71 71
 		add_action(
72 72
 				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
73
-				array( 'EE_Cron_Tasks', 'clean_out_junk_transactions' )
73
+				array('EE_Cron_Tasks', 'clean_out_junk_transactions')
74 74
 		);
75 75
 		// logging
76 76
 		add_action(
77 77
 			'AHEE__EE_System__load_core_configuration__complete',
78
-			array( 'EE_Cron_Tasks', 'log_scheduled_ee_crons' )
78
+			array('EE_Cron_Tasks', 'log_scheduled_ee_crons')
79 79
 		);
80
-		EE_Registry::instance()->load_lib( 'Messages_Scheduler' );
80
+		EE_Registry::instance()->load_lib('Messages_Scheduler');
81 81
 	}
82 82
 
83 83
 
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
93 93
 			'AHEE__EE_Cron_Tasks__clean_up_junk_transactions',
94 94
 		);
95
-		$crons = get_option( 'cron' );
96
-		if ( ! is_array( $crons ) ) {
95
+		$crons = get_option('cron');
96
+		if ( ! is_array($crons)) {
97 97
 			return;
98 98
 		}
99
-		foreach ( $crons as $timestamp => $cron ) {
100
-			foreach ( $ee_crons as $ee_cron ) {
101
-				if ( isset( $cron[ $ee_cron ] ) ) {
102
-					do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron' );
103
-					foreach ( $cron[ $ee_cron ] as $ee_cron_details ) {
104
-						if ( ! empty( $ee_cron_details[ 'args' ] )) {
105
-							do_action( 'AHEE_log', __CLASS__, __FUNCTION__, print_r( $ee_cron_details[ 'args' ], true ), "$ee_cron args" );
99
+		foreach ($crons as $timestamp => $cron) {
100
+			foreach ($ee_crons as $ee_cron) {
101
+				if (isset($cron[$ee_cron])) {
102
+					do_action('AHEE_log', __CLASS__, __FUNCTION__, $ee_cron, 'scheduled EE cron');
103
+					foreach ($cron[$ee_cron] as $ee_cron_details) {
104
+						if ( ! empty($ee_cron_details['args'])) {
105
+							do_action('AHEE_log', __CLASS__, __FUNCTION__, print_r($ee_cron_details['args'], true), "$ee_cron args");
106 106
 						}
107 107
 					}
108 108
 				}
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 		$TXN_ID,
140 140
 		$PAY_ID
141 141
 	) {
142
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
142
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
143 143
 		// validate $TXN_ID and $timestamp
144
-		$TXN_ID = absint( $TXN_ID );
145
-		$timestamp = absint( $timestamp );
146
-		if ( $TXN_ID && $timestamp ) {
144
+		$TXN_ID = absint($TXN_ID);
145
+		$timestamp = absint($timestamp);
146
+		if ($TXN_ID && $timestamp) {
147 147
 			wp_schedule_single_event(
148 148
 				$timestamp,
149 149
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment_2',
150
-				array( $TXN_ID, $PAY_ID )
150
+				array($TXN_ID, $PAY_ID)
151 151
 			);
152 152
 		}
153 153
 	}
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	 * @param int  $TXN_ID
170 170
 	 * @param int $PAY_ID
171 171
 	 */
172
-	public static function setup_update_for_transaction_with_payment( $TXN_ID = 0, $PAY_ID = 0 ) {
173
-            do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
174
-		if ( absint( $TXN_ID )) {
175
-			self::$_update_transactions_with_payment[ $TXN_ID ] = $PAY_ID;
172
+	public static function setup_update_for_transaction_with_payment($TXN_ID = 0, $PAY_ID = 0) {
173
+            do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
174
+		if (absint($TXN_ID)) {
175
+			self::$_update_transactions_with_payment[$TXN_ID] = $PAY_ID;
176 176
 			add_action(
177 177
 				'shutdown',
178
-				array( 'EE_Cron_Tasks', 'update_transaction_with_payment' ),
178
+				array('EE_Cron_Tasks', 'update_transaction_with_payment'),
179 179
 				5
180 180
 			);
181 181
 		}
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
 	 * @throws \EE_Error
195 195
 	 */
196 196
 	public static function update_transaction_with_payment() {
197
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
197
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
198 198
 		// are there any TXNs that need cleaning up ?
199
-		if ( ! empty( self::$_update_transactions_with_payment ) ) {
199
+		if ( ! empty(self::$_update_transactions_with_payment)) {
200 200
 			/** @type EE_Payment_Processor $payment_processor */
201
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
201
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
202 202
 			// set revisit flag for payment processor
203
-			$payment_processor->set_revisit( false );
203
+			$payment_processor->set_revisit(false);
204 204
 			// load EEM_Transaction
205
-			EE_Registry::instance()->load_model( 'Transaction' );
206
-			foreach ( self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID ) {
205
+			EE_Registry::instance()->load_model('Transaction');
206
+			foreach (self::$_update_transactions_with_payment as $TXN_ID => $PAY_ID) {
207 207
 				// reschedule the cron if we can't hit the db right now
208
-				if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
208
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
209 209
 					// reset cron job for updating the TXN
210 210
 					EE_Cron_Tasks::schedule_update_transaction_with_payment(
211 211
 						time() + EE_Cron_Tasks::reschedule_timeout,
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 					);
215 215
 					continue;
216 216
 				}
217
-				$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
218
-				$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
217
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
218
+				$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
219 219
 				// verify transaction
220
-				if ( $transaction instanceof EE_Transaction && $payment instanceof EE_Payment ) {
220
+				if ($transaction instanceof EE_Transaction && $payment instanceof EE_Payment) {
221 221
 					// now try to update the TXN with any payments
222
-					$payment_processor->update_txn_based_on_payment( $transaction, $payment, true, true );
222
+					$payment_processor->update_txn_based_on_payment($transaction, $payment, true, true);
223 223
 				}
224
-				unset( self::$_update_transactions_with_payment[ $TXN_ID ] );
224
+				unset(self::$_update_transactions_with_payment[$TXN_ID]);
225 225
 			}
226 226
 		}
227 227
 	}
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		$TXN_ID
259 259
 	) {
260 260
 		// validate $TXN_ID and $timestamp
261
-		$TXN_ID = absint( $TXN_ID );
262
-		$timestamp = absint( $timestamp );
263
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
264
-		if ( $TXN_ID && $timestamp ) {
261
+		$TXN_ID = absint($TXN_ID);
262
+		$timestamp = absint($timestamp);
263
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
264
+		if ($TXN_ID && $timestamp) {
265 265
 			wp_schedule_single_event(
266 266
 				$timestamp,
267 267
 				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions',
268
-				array( $TXN_ID )
268
+				array($TXN_ID)
269 269
 			);
270 270
 		}
271 271
 	}
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @param int $TXN_ID
289 289
 	 */
290
-	public static function check_for_abandoned_transactions(	$TXN_ID = 0 ) {
291
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
292
-		if ( absint( $TXN_ID )) {
293
-			self::$_abandoned_transactions[]  = $TXN_ID;
290
+	public static function check_for_abandoned_transactions($TXN_ID = 0) {
291
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
292
+		if (absint($TXN_ID)) {
293
+			self::$_abandoned_transactions[] = $TXN_ID;
294 294
 			add_action(
295 295
 				'shutdown',
296
-				array( 'EE_Cron_Tasks', 'finalize_abandoned_transactions' ),
296
+				array('EE_Cron_Tasks', 'finalize_abandoned_transactions'),
297 297
 				5
298 298
 			);
299 299
 		}
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 	 * @throws \EE_Error
313 313
 	 */
314 314
 	public static function finalize_abandoned_transactions() {
315
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__ );
315
+		do_action('AHEE_log', __CLASS__, __FUNCTION__);
316 316
 		// are there any TXNs that need cleaning up ?
317
-		if ( ! empty( self::$_abandoned_transactions ) ) {
317
+		if ( ! empty(self::$_abandoned_transactions)) {
318 318
 			/** @type EE_Transaction_Processor $transaction_processor */
319
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
319
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
320 320
 			// set revisit flag for txn processor
321
-			$transaction_processor->set_revisit( false );
321
+			$transaction_processor->set_revisit(false);
322 322
 			/** @type EE_Payment_Processor $payment_processor */
323
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
323
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
324 324
 			// load EEM_Transaction
325
-			EE_Registry::instance()->load_model( 'Transaction' );
326
-			foreach ( self::$_abandoned_transactions as $TXN_ID ) {
327
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID' );
325
+			EE_Registry::instance()->load_model('Transaction');
326
+			foreach (self::$_abandoned_transactions as $TXN_ID) {
327
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $TXN_ID, '$TXN_ID');
328 328
 				// reschedule the cron if we can't hit the db right now
329
-				if ( ! EE_Maintenance_Mode::instance()->models_can_query() ) {
329
+				if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
330 330
 					// reset cron job for finalizing the TXN
331 331
 					EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
332 332
 						time() + EE_Cron_Tasks::reschedule_timeout,
@@ -334,17 +334,17 @@  discard block
 block discarded – undo
334 334
 					);
335 335
 					continue;
336 336
 				}
337
-				$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
337
+				$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
338 338
 				// verify transaction
339
-				if ( $transaction instanceof EE_Transaction ) {
339
+				if ($transaction instanceof EE_Transaction) {
340 340
 					// don't finalize the TXN if it has already been completed
341
-					if ( $transaction_processor->all_reg_steps_completed( $transaction ) === true ) {
341
+					if ($transaction_processor->all_reg_steps_completed($transaction) === true) {
342 342
 						continue;
343 343
 					}
344 344
 					// let's simulate an IPN here which will trigger any notifications that need to go out
345
-					$payment_processor->update_txn_based_on_payment( $transaction, $transaction->last_payment(), true, true );
345
+					$payment_processor->update_txn_based_on_payment($transaction, $transaction->last_payment(), true, true);
346 346
 				}
347
-				unset( self::$_abandoned_transactions[ $TXN_ID ] );
347
+				unset(self::$_abandoned_transactions[$TXN_ID]);
348 348
 			}
349 349
 		}
350 350
 	}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	//when a transaction is initially made, schedule this check.
361 361
 	//if it has NO REG data by the time it has expired, forget about it
362 362
 	public static function clean_out_junk_transactions() {
363
-		if( EE_Maintenance_Mode::instance()->models_can_query() ) {
363
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
364 364
 			EEM_Transaction::instance('')->delete_junk_transactions();
365 365
 			EEM_Registration::instance('')->delete_registrations_with_no_transaction();
366 366
 			EEM_Line_Item::instance('')->delete_line_items_with_no_transaction();
Please login to merge, or discard this patch.
core/libraries/rest_api/Calculated_Model_Fields.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * @since		 	   4.8.35.rc.001
16 16
  *
17 17
  */
18
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-	exit( 'No direct script access allowed' );
18
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
19
+	exit('No direct script access allowed');
20 20
 }
21 21
 
22 22
 class Calculated_Model_Fields {
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * the WP_Request object,
39 39
 	 * the controller object
40 40
 	 */
41
-	public function mapping( $refresh = false ) {
42
-		if( ! $this->_mapping || $refresh ) {
41
+	public function mapping($refresh = false) {
42
+		if ( ! $this->_mapping || $refresh) {
43 43
 			$this->_mapping = $this->_generate_new_mapping();
44 44
 		}
45 45
 		return $this->_mapping;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	protected function _generate_new_mapping() {
54 54
 		$rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\';
55
-		$event_calculations_class = $rest_api_calculations_namespace . 'Event';
56
-		$datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime';
57
-		$registration_class = $rest_api_calculations_namespace . 'Registration';
55
+		$event_calculations_class = $rest_api_calculations_namespace.'Event';
56
+		$datetime_calculations_class = $rest_api_calculations_namespace.'Datetime';
57
+		$registration_class = $rest_api_calculations_namespace.'Registration';
58 58
 		return apply_filters(
59 59
 			'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping',
60 60
 			array(
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 * @param \EEM_Base $model
92 92
 	 * @return array allowable values for this field
93 93
 	 */
94
-	public function retrieve_calculated_fields_for_model( \EEM_Base $model ) {
94
+	public function retrieve_calculated_fields_for_model(\EEM_Base $model) {
95 95
 		$mapping = $this->mapping();
96
-		if( isset( $mapping[ $model->get_this_model_name() ] ) ) {
97
-			return array_keys( $mapping[ $model->get_this_model_name() ] );
96
+		if (isset($mapping[$model->get_this_model_name()])) {
97
+			return array_keys($mapping[$model->get_this_model_name()]);
98 98
 		} else {
99 99
 			return array();
100 100
 		}
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	 * @return mixed|null
114 114
 	 * @throws \EE_Error
115 115
 	 */
116
-	public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) {
116
+	public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) {
117 117
 		$mapping = $this->mapping();
118
-		if( isset( $mapping[ $model->get_this_model_name() ] )
119
-			&& isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) {
120
-			$classname = $mapping[ $model->get_this_model_name() ][ $field_name ];
121
-			return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller );
118
+		if (isset($mapping[$model->get_this_model_name()])
119
+			&& isset($mapping[$model->get_this_model_name()][$field_name])) {
120
+			$classname = $mapping[$model->get_this_model_name()][$field_name];
121
+			return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller);
122 122
 		}
123 123
 		throw new Rest_Exception( 
124 124
 			'calculated_field_does_not_exist',
125 125
 			sprintf( 
126
-				__( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), 
126
+				__('There is no calculated field %1$s on resource %2$s', 'event_espresso'), 
127 127
 				$field_name, 
128 128
 				$model->get_this_model_name() 
129 129
 			) 
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Registration.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  * @since		 	   $VID:$
16 16
  *
17 17
  */
18
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
19
-	exit( 'No direct script access allowed' );
18
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
19
+	exit('No direct script access allowed');
20 20
 }
21 21
 
22 22
 class Registration extends Calculations_Base {
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 * @return int
31 31
 	 * @throws \EE_Error
32 32
 	 */
33
-	public static function datetime_checkin_stati( $wpdb_row, $request, $controller ){
34
-		if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Registration.REG_ID' ] ) ) {
35
-			$reg = \EEM_Registration::instance()->get_one_by_ID( $wpdb_row[ 'Registration.REG_ID' ] );
33
+	public static function datetime_checkin_stati($wpdb_row, $request, $controller) {
34
+		if (is_array($wpdb_row) && isset($wpdb_row['Registration.REG_ID'])) {
35
+			$reg = \EEM_Registration::instance()->get_one_by_ID($wpdb_row['Registration.REG_ID']);
36 36
 		} else {
37 37
 			$reg = null;
38 38
 		}
39
-		if( ! $reg instanceof \EE_Registration 
39
+		if ( ! $reg instanceof \EE_Registration 
40 40
 		) {
41 41
 			throw new \EE_Error(
42 42
 				sprintf(
43
-					__( 'Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso' ),
44
-					$wpdb_row[ 'Registration.REG_ID' ],
45
-					print_r( $wpdb_row, true )
43
+					__('Cannot calculate datetime_checkin_stati because the registration with ID %1$s (from database row %2$s) was not found', 'event_espresso'),
44
+					$wpdb_row['Registration.REG_ID'],
45
+					print_r($wpdb_row, true)
46 46
 				)
47 47
 			);
48 48
 		}
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 			)
55 55
 		);
56 56
 		$checkin_stati = array();
57
-		foreach( $datetime_ids as $datetime_id ) {
58
-			$status = $reg->check_in_status_for_datetime( $datetime_id );
59
-			switch( $status ) {
57
+		foreach ($datetime_ids as $datetime_id) {
58
+			$status = $reg->check_in_status_for_datetime($datetime_id);
59
+			switch ($status) {
60 60
 				case \EE_Registration::checkin_status_out:
61 61
 					$status_pretty = 'OUT';
62 62
 					break;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 					$status_pretty = 'NEVER';
69 69
 					break;
70 70
 			}
71
-			$checkin_stati[ $datetime_id ] = $status_pretty;
71
+			$checkin_stati[$datetime_id] = $status_pretty;
72 72
 		}
73 73
 		return $checkin_stati;
74 74
 	}
Please login to merge, or discard this patch.