@@ -8,7 +8,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -4,7 +4,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -131,8 +131,7 @@ discard block |
||
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 |
||
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; |
@@ -187,7 +187,7 @@ discard block |
||
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 |
||
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 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EEH_Debug_Tools |
4 | 4 | * |
@@ -8,7 +8,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 />>>>>>\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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -156,7 +156,7 @@ discard block |
||
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 |
||
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 |
@@ -28,7 +28,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_SPCO_Reg_Step_Attendee_Information |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_SPCO_Reg_Step_Attendee_Information |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step { |
15 | 15 | |
16 | 16 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | // generate hidden input |
172 | 172 | if ( |
173 | 173 | isset( $subsections[ $primary_registrant ] ) |
174 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
174 | + && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
175 | 175 | ) { |
176 | 176 | $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
177 | 177 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | if ( isset( $valid_data[ $reg_url_link ] ) ) { |
903 | 903 | // do we need to copy basic info from primary attendee ? |
904 | 904 | $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
905 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
905 | + && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
906 | 906 | ? true |
907 | 907 | : false; |
908 | 908 | // filter form input data for this registration |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | ? $form_input |
1080 | 1080 | : $form_input . '-' . $registration->reg_url_link(); |
1081 | 1081 | $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
1082 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1082 | + && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1083 | 1083 | ? true |
1084 | 1084 | : false; |
1085 | 1085 | //rename form_inputs if they are EE_Attendee properties |
@@ -1319,7 +1319,7 @@ discard block |
||
1319 | 1319 | } |
1320 | 1320 | foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
1321 | 1321 | if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
1322 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1322 | + || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1323 | 1323 | ) { |
1324 | 1324 | $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
1325 | 1325 | $critical_attendee_detail |
@@ -42,21 +42,21 @@ discard block |
||
42 | 42 | * @param EE_Checkout $checkout |
43 | 43 | * @return \EE_SPCO_Reg_Step_Attendee_Information |
44 | 44 | */ |
45 | - public function __construct( EE_Checkout $checkout ) { |
|
45 | + public function __construct(EE_Checkout $checkout) { |
|
46 | 46 | $this->_slug = 'attendee_information'; |
47 | 47 | $this->_name = __('Attendee Information', 'event_espresso'); |
48 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_main.template.php'; |
|
48 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_main.template.php'; |
|
49 | 49 | $this->checkout = $checkout; |
50 | 50 | $this->_reset_success_message(); |
51 | 51 | $this->set_instructions( |
52 | - __( 'Please answer the following registration questions before proceeding.', 'event_espresso' ) |
|
52 | + __('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | 58 | public function translate_js_strings() { |
59 | - EE_Registry::$i18n_js_strings['required_field'] = __( ' is a required question.', 'event_espresso' ); |
|
59 | + EE_Registry::$i18n_js_strings['required_field'] = __(' is a required question.', 'event_espresso'); |
|
60 | 60 | EE_Registry::$i18n_js_strings['required_multi_field'] = __( |
61 | 61 | ' is a required question. Please enter a value for at least one of the options.', |
62 | 62 | 'event_espresso' |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | // calculate taxes |
117 | 117 | $Line_Item_Display->display_line_item( |
118 | 118 | $this->checkout->cart->get_grand_total(), |
119 | - array( 'set_tax_rate' => true ) |
|
119 | + array('set_tax_rate' => true) |
|
120 | 120 | ); |
121 | 121 | /** @var $subsections EE_Form_Section_Proper[] */ |
122 | 122 | $subsections = array( |
@@ -128,51 +128,51 @@ discard block |
||
128 | 128 | 'ticket_count' => array() |
129 | 129 | ); |
130 | 130 | // grab the saved registrations from the transaction |
131 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
132 | - if ( $registrations ) { |
|
133 | - foreach ( $registrations as $registration ) { |
|
131 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
132 | + if ($registrations) { |
|
133 | + foreach ($registrations as $registration) { |
|
134 | 134 | // can this registration be processed during this visit ? |
135 | 135 | if ( |
136 | 136 | $registration instanceof EE_Registration |
137 | - && $this->checkout->visit_allows_processing_of_this_registration( $registration ) |
|
137 | + && $this->checkout->visit_allows_processing_of_this_registration($registration) |
|
138 | 138 | ) { |
139 | - $subsections[ $registration->reg_url_link() ] = $this->_registrations_reg_form( $registration ); |
|
140 | - if ( ! $this->checkout->admin_request ) { |
|
141 | - $template_args['registrations'][ $registration->reg_url_link() ] = $registration; |
|
142 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] = isset( |
|
143 | - $template_args['ticket_count'][ $registration->ticket()->ID() ] |
|
139 | + $subsections[$registration->reg_url_link()] = $this->_registrations_reg_form($registration); |
|
140 | + if ( ! $this->checkout->admin_request) { |
|
141 | + $template_args['registrations'][$registration->reg_url_link()] = $registration; |
|
142 | + $template_args['ticket_count'][$registration->ticket()->ID()] = isset( |
|
143 | + $template_args['ticket_count'][$registration->ticket()->ID()] |
|
144 | 144 | ) |
145 | - ? $template_args['ticket_count'][ $registration->ticket()->ID() ] + 1 |
|
145 | + ? $template_args['ticket_count'][$registration->ticket()->ID()] + 1 |
|
146 | 146 | : 1; |
147 | 147 | $ticket_line_item = EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
148 | 148 | $this->checkout->cart->get_grand_total(), |
149 | 149 | 'Ticket', |
150 | - array( $registration->ticket()->ID() ) |
|
150 | + array($registration->ticket()->ID()) |
|
151 | 151 | ); |
152 | - $ticket_line_item = is_array( $ticket_line_item ) |
|
153 | - ? reset( $ticket_line_item ) |
|
152 | + $ticket_line_item = is_array($ticket_line_item) |
|
153 | + ? reset($ticket_line_item) |
|
154 | 154 | : $ticket_line_item; |
155 | - $template_args['ticket_line_item'][ $registration->ticket()->ID() ] = $Line_Item_Display->display_line_item( |
|
155 | + $template_args['ticket_line_item'][$registration->ticket()->ID()] = $Line_Item_Display->display_line_item( |
|
156 | 156 | $ticket_line_item |
157 | 157 | ); |
158 | 158 | } |
159 | - if ( $registration->is_primary_registrant() ) { |
|
159 | + if ($registration->is_primary_registrant()) { |
|
160 | 160 | $primary_registrant = $registration->reg_url_link(); |
161 | 161 | } |
162 | 162 | } |
163 | 163 | } |
164 | 164 | // print_copy_info ? |
165 | - if ( $primary_registrant && ! $this->checkout->admin_request && count( $registrations ) > 1 ) { |
|
165 | + if ($primary_registrant && ! $this->checkout->admin_request && count($registrations) > 1) { |
|
166 | 166 | // TODO: add admin option for toggling copy attendee info, then use that value to change $this->_print_copy_info |
167 | 167 | $copy_options['spco_copy_attendee_chk'] = $this->_print_copy_info |
168 | 168 | ? $this->_copy_attendee_info_form() |
169 | 169 | : $this->_auto_copy_attendee_info(); |
170 | 170 | // generate hidden input |
171 | 171 | if ( |
172 | - isset( $subsections[ $primary_registrant ] ) |
|
173 | - && $subsections[ $primary_registrant ] instanceof EE_Form_Section_Proper |
|
172 | + isset($subsections[$primary_registrant]) |
|
173 | + && $subsections[$primary_registrant] instanceof EE_Form_Section_Proper |
|
174 | 174 | ) { |
175 | - $subsections[ $primary_registrant ]->add_subsections( $copy_options, 'primary_registrant', false ); |
|
175 | + $subsections[$primary_registrant]->add_subsections($copy_options, 'primary_registrant', false); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
@@ -184,8 +184,7 @@ discard block |
||
184 | 184 | 'html_id' => $this->reg_form_name(), |
185 | 185 | 'subsections' => $subsections, |
186 | 186 | 'layout_strategy' => $this->checkout->admin_request ? |
187 | - new EE_Div_Per_Section_Layout() : |
|
188 | - new EE_Template_Layout( |
|
187 | + new EE_Div_Per_Section_Layout() : new EE_Template_Layout( |
|
189 | 188 | array( |
190 | 189 | 'layout_template_file' => $this->_template, // layout_template |
191 | 190 | 'template_args' => $template_args |
@@ -203,11 +202,11 @@ discard block |
||
203 | 202 | * @return EE_Form_Section_Proper |
204 | 203 | * @throws \EE_Error |
205 | 204 | */ |
206 | - private function _registrations_reg_form( EE_Registration $registration ) { |
|
205 | + private function _registrations_reg_form(EE_Registration $registration) { |
|
207 | 206 | static $attendee_nmbr = 1; |
208 | 207 | // array of params to pass to parent constructor |
209 | 208 | $form_args = array( |
210 | - 'html_id' => 'ee-registration-' . $registration->reg_url_link(), |
|
209 | + 'html_id' => 'ee-registration-'.$registration->reg_url_link(), |
|
211 | 210 | 'html_class' => 'ee-reg-form-attendee-dv', |
212 | 211 | 'html_style' => $this->checkout->admin_request |
213 | 212 | ? 'padding:0em 2em 1em; margin:3em 0 0; border:1px solid #ddd;' |
@@ -216,24 +215,24 @@ discard block |
||
216 | 215 | 'layout_strategy' => new EE_Fieldset_Section_Layout( |
217 | 216 | array( |
218 | 217 | 'legend_class' => 'spco-attendee-lgnd smaller-text lt-grey-text', |
219 | - 'legend_text' => sprintf( __( 'Attendee %d', 'event_espresso' ), $attendee_nmbr ) |
|
218 | + 'legend_text' => sprintf(__('Attendee %d', 'event_espresso'), $attendee_nmbr) |
|
220 | 219 | ) |
221 | 220 | ) |
222 | 221 | ); |
223 | 222 | // verify that registration has valid event |
224 | - if ( $registration->event() instanceof EE_Event ) { |
|
223 | + if ($registration->event() instanceof EE_Event) { |
|
225 | 224 | $query_params = array( |
226 | 225 | array( |
227 | 226 | 'Event.EVT_ID' => $registration->event()->ID(), |
228 | 227 | 'Event_Question_Group.EQG_primary' => $registration->count() === 1 ? true : false |
229 | 228 | ), |
230 | - 'order_by'=>array( 'QSG_order'=>'ASC' ) |
|
229 | + 'order_by'=>array('QSG_order'=>'ASC') |
|
231 | 230 | ); |
232 | - $question_groups = $registration->event()->question_groups( $query_params ); |
|
233 | - if ( $question_groups ) { |
|
234 | - foreach ( $question_groups as $question_group ) { |
|
235 | - if ( $question_group instanceof EE_Question_Group ) { |
|
236 | - $form_args['subsections'][ $question_group->identifier() ] = $this->_question_group_reg_form( |
|
231 | + $question_groups = $registration->event()->question_groups($query_params); |
|
232 | + if ($question_groups) { |
|
233 | + foreach ($question_groups as $question_group) { |
|
234 | + if ($question_group instanceof EE_Question_Group) { |
|
235 | + $form_args['subsections'][$question_group->identifier()] = $this->_question_group_reg_form( |
|
237 | 236 | $registration, |
238 | 237 | $question_group |
239 | 238 | ); |
@@ -246,10 +245,10 @@ discard block |
||
246 | 245 | // if we have question groups for additional attendees, then display the copy options |
247 | 246 | $this->_print_copy_info = $attendee_nmbr > 1 ? true : $this->_print_copy_info; |
248 | 247 | } else { |
249 | - $form_args['subsections'][ 'attendee_info_not_required_' . $registration->reg_url_link( |
|
250 | - ) ] = new EE_Form_Section_HTML( |
|
248 | + $form_args['subsections']['attendee_info_not_required_'.$registration->reg_url_link( |
|
249 | + )] = new EE_Form_Section_HTML( |
|
251 | 250 | EEH_Template::locate_template( |
252 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . 'attendee_info_not_required.template.php', |
|
251 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'attendee_info_not_required.template.php', |
|
253 | 252 | apply_filters( |
254 | 253 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__attendee_info_not_required_template_args', |
255 | 254 | array() |
@@ -265,12 +264,12 @@ discard block |
||
265 | 264 | ); |
266 | 265 | } |
267 | 266 | } |
268 | - if ( $registration->is_primary_registrant() ) { |
|
267 | + if ($registration->is_primary_registrant()) { |
|
269 | 268 | // generate hidden input |
270 | - $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs( $registration ); |
|
269 | + $form_args['subsections']['primary_registrant'] = $this->_additional_primary_registrant_inputs($registration); |
|
271 | 270 | } |
272 | 271 | $attendee_nmbr++; |
273 | - return new EE_Form_Section_Proper( $form_args ); |
|
272 | + return new EE_Form_Section_Proper($form_args); |
|
274 | 273 | } |
275 | 274 | |
276 | 275 | |
@@ -291,7 +290,7 @@ discard block |
||
291 | 290 | // generate hidden input |
292 | 291 | return new EE_Hidden_Input( |
293 | 292 | array( |
294 | - 'html_id' => 'additional-attendee-reg-info-' . $registration->reg_url_link(), |
|
293 | + 'html_id' => 'additional-attendee-reg-info-'.$registration->reg_url_link(), |
|
295 | 294 | 'default' => $additional_attendee_reg_info |
296 | 295 | ) |
297 | 296 | ); |
@@ -305,26 +304,26 @@ discard block |
||
305 | 304 | * @return EE_Form_Section_Proper |
306 | 305 | * @throws \EE_Error |
307 | 306 | */ |
308 | - private function _question_group_reg_form( EE_Registration $registration, EE_Question_Group $question_group ){ |
|
307 | + private function _question_group_reg_form(EE_Registration $registration, EE_Question_Group $question_group) { |
|
309 | 308 | // array of params to pass to parent constructor |
310 | 309 | $form_args = array( |
311 | - 'html_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier(), |
|
310 | + 'html_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier(), |
|
312 | 311 | 'html_class' => $this->checkout->admin_request |
313 | 312 | ? 'form-table ee-reg-form-qstn-grp-dv' |
314 | 313 | : 'ee-reg-form-qstn-grp-dv', |
315 | - 'html_label_id' => 'ee-reg-form-qstn-grp-' . $question_group->identifier() . '-lbl', |
|
314 | + 'html_label_id' => 'ee-reg-form-qstn-grp-'.$question_group->identifier().'-lbl', |
|
316 | 315 | 'subsections' => array( |
317 | - 'reg_form_qstn_grp_hdr' => $this->_question_group_header( $question_group ) |
|
316 | + 'reg_form_qstn_grp_hdr' => $this->_question_group_header($question_group) |
|
318 | 317 | ), |
319 | 318 | 'layout_strategy' => $this->checkout->admin_request |
320 | 319 | ? new EE_Admin_Two_Column_Layout() |
321 | 320 | : new EE_Div_Per_Section_Layout() |
322 | 321 | ); |
323 | 322 | // where params |
324 | - $query_params = array( 'QST_deleted' => 0 ); |
|
323 | + $query_params = array('QST_deleted' => 0); |
|
325 | 324 | // don't load admin only questions on the frontend |
326 | - if ( ! $this->checkout->admin_request ) { |
|
327 | - $query_params['QST_admin_only'] = array( '!=', true ); |
|
325 | + if ( ! $this->checkout->admin_request) { |
|
326 | + $query_params['QST_admin_only'] = array('!=', true); |
|
328 | 327 | } |
329 | 328 | $questions = $question_group->get_many_related( |
330 | 329 | 'Question', |
@@ -346,10 +345,10 @@ discard block |
||
346 | 345 | ) |
347 | 346 | ); |
348 | 347 | // loop thru questions |
349 | - foreach ( $questions as $question ) { |
|
350 | - if( $question instanceof EE_Question ){ |
|
348 | + foreach ($questions as $question) { |
|
349 | + if ($question instanceof EE_Question) { |
|
351 | 350 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
352 | - $form_args['subsections'][ $identifier ] = $this->reg_form_question( $registration, $question ); |
|
351 | + $form_args['subsections'][$identifier] = $this->reg_form_question($registration, $question); |
|
353 | 352 | } |
354 | 353 | } |
355 | 354 | $form_args['subsections'] = apply_filters( |
@@ -370,7 +369,7 @@ discard block |
||
370 | 369 | ) |
371 | 370 | ); |
372 | 371 | // d( $form_args ); |
373 | - $question_group_reg_form = new EE_Form_Section_Proper( $form_args ); |
|
372 | + $question_group_reg_form = new EE_Form_Section_Proper($form_args); |
|
374 | 373 | return apply_filters( |
375 | 374 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
376 | 375 | $question_group_reg_form, |
@@ -387,11 +386,11 @@ discard block |
||
387 | 386 | * @param EE_Question_Group $question_group |
388 | 387 | * @return EE_Form_Section_HTML |
389 | 388 | */ |
390 | - private function _question_group_header( EE_Question_Group $question_group ){ |
|
389 | + private function _question_group_header(EE_Question_Group $question_group) { |
|
391 | 390 | $html = ''; |
392 | 391 | // group_name |
393 | - if ( $question_group->show_group_name() && $question_group->name() !== '' ) { |
|
394 | - if ( $this->checkout->admin_request ) { |
|
392 | + if ($question_group->show_group_name() && $question_group->name() !== '') { |
|
393 | + if ($this->checkout->admin_request) { |
|
395 | 394 | $html .= EEH_HTML::br(); |
396 | 395 | $html .= EEH_HTML::h3( |
397 | 396 | $question_group->name(), |
@@ -405,7 +404,7 @@ discard block |
||
405 | 404 | } |
406 | 405 | } |
407 | 406 | // group_desc |
408 | - if ( $question_group->show_group_desc() && $question_group->desc() !== '' ) { |
|
407 | + if ($question_group->show_group_desc() && $question_group->desc() !== '') { |
|
409 | 408 | $html .= EEH_HTML::p( |
410 | 409 | $question_group->desc(), |
411 | 410 | '', |
@@ -415,7 +414,7 @@ discard block |
||
415 | 414 | ); |
416 | 415 | |
417 | 416 | } |
418 | - return new EE_Form_Section_HTML( $html ); |
|
417 | + return new EE_Form_Section_HTML($html); |
|
419 | 418 | } |
420 | 419 | |
421 | 420 | |
@@ -425,7 +424,7 @@ discard block |
||
425 | 424 | * @return EE_Form_Section_Proper |
426 | 425 | * @throws \EE_Error |
427 | 426 | */ |
428 | - private function _copy_attendee_info_form(){ |
|
427 | + private function _copy_attendee_info_form() { |
|
429 | 428 | // array of params to pass to parent constructor |
430 | 429 | return new EE_Form_Section_Proper( |
431 | 430 | array( |
@@ -454,7 +453,7 @@ discard block |
||
454 | 453 | private function _auto_copy_attendee_info() { |
455 | 454 | return new EE_Form_Section_HTML( |
456 | 455 | EEH_Template::locate_template( |
457 | - SPCO_REG_STEPS_PATH . $this->_slug . DS . '_auto_copy_attendee_info.template.php', |
|
456 | + SPCO_REG_STEPS_PATH.$this->_slug.DS.'_auto_copy_attendee_info.template.php', |
|
458 | 457 | apply_filters( |
459 | 458 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
460 | 459 | array() |
@@ -478,32 +477,32 @@ discard block |
||
478 | 477 | $copy_attendee_info_inputs = array(); |
479 | 478 | $prev_ticket = NULL; |
480 | 479 | // grab the saved registrations from the transaction |
481 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
482 | - foreach ( $registrations as $registration ) { |
|
480 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
481 | + foreach ($registrations as $registration) { |
|
483 | 482 | // for all attendees other than the primary attendee |
484 | - if ( $registration instanceof EE_Registration && ! $registration->is_primary_registrant() ) { |
|
483 | + if ($registration instanceof EE_Registration && ! $registration->is_primary_registrant()) { |
|
485 | 484 | // if this is a new ticket OR if this is the very first additional attendee after the primary attendee |
486 | - if ( $registration->ticket()->ID() !== $prev_ticket ) { |
|
485 | + if ($registration->ticket()->ID() !== $prev_ticket) { |
|
487 | 486 | $item_name = $registration->ticket()->name(); |
488 | 487 | $item_name .= $registration->ticket()->description() !== '' |
489 | - ? ' - ' . $registration->ticket()->description() |
|
488 | + ? ' - '.$registration->ticket()->description() |
|
490 | 489 | : ''; |
491 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[ticket-' . $registration->ticket()->ID() . ']' ] = new EE_Form_Section_HTML( |
|
492 | - '<h6 class="spco-copy-attendee-event-hdr">' . $item_name . '</h6>' |
|
490 | + $copy_attendee_info_inputs['spco_copy_attendee_chk[ticket-'.$registration->ticket()->ID().']'] = new EE_Form_Section_HTML( |
|
491 | + '<h6 class="spco-copy-attendee-event-hdr">'.$item_name.'</h6>' |
|
493 | 492 | ); |
494 | 493 | $prev_ticket = $registration->ticket()->ID(); |
495 | 494 | } |
496 | 495 | |
497 | - $copy_attendee_info_inputs[ 'spco_copy_attendee_chk[' . $registration->ID() . ']' ] = new |
|
496 | + $copy_attendee_info_inputs['spco_copy_attendee_chk['.$registration->ID().']'] = new |
|
498 | 497 | EE_Checkbox_Multi_Input( |
499 | 498 | array( |
500 | 499 | $registration->ID() => sprintf( |
501 | - __( 'Attendee #%s', 'event_espresso' ), |
|
500 | + __('Attendee #%s', 'event_espresso'), |
|
502 | 501 | $registration->count() |
503 | 502 | ) |
504 | 503 | ), |
505 | 504 | array( |
506 | - 'html_id' => 'spco-copy-attendee-chk-' . $registration->reg_url_link(), |
|
505 | + 'html_id' => 'spco-copy-attendee-chk-'.$registration->reg_url_link(), |
|
507 | 506 | 'html_class' => 'spco-copy-attendee-chk ee-do-not-validate', |
508 | 507 | 'display_html_label_text' => false |
509 | 508 | ) |
@@ -523,7 +522,7 @@ discard block |
||
523 | 522 | * @return EE_Form_Input_Base |
524 | 523 | * @throws \EE_Error |
525 | 524 | */ |
526 | - private function _additional_primary_registrant_inputs( EE_Registration $registration ){ |
|
525 | + private function _additional_primary_registrant_inputs(EE_Registration $registration) { |
|
527 | 526 | // generate hidden input |
528 | 527 | return new EE_Hidden_Input( |
529 | 528 | array( |
@@ -542,7 +541,7 @@ discard block |
||
542 | 541 | * @return EE_Form_Input_Base |
543 | 542 | * @throws \EE_Error |
544 | 543 | */ |
545 | - public function reg_form_question( EE_Registration $registration, EE_Question $question ){ |
|
544 | + public function reg_form_question(EE_Registration $registration, EE_Question $question) { |
|
546 | 545 | |
547 | 546 | // if this question was for an attendee detail, then check for that answer |
548 | 547 | $answer_value = EEM_Answer::instance()->get_attendee_property_answer_value( |
@@ -551,32 +550,32 @@ discard block |
||
551 | 550 | ); |
552 | 551 | $answer = $answer_value === null |
553 | 552 | ? EEM_Answer::instance()->get_one( |
554 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
553 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
555 | 554 | ) |
556 | 555 | : null; |
557 | 556 | // if NOT returning to edit an existing registration |
558 | 557 | // OR if this question is for an attendee property |
559 | 558 | // OR we still don't have an EE_Answer object |
560 | - if( $answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link() ) { |
|
559 | + if ($answer_value || ! $answer instanceof EE_Answer || ! $registration->reg_url_link()) { |
|
561 | 560 | // create an EE_Answer object for storing everything in |
562 | - $answer = EE_Answer::new_instance ( array( |
|
561 | + $answer = EE_Answer::new_instance(array( |
|
563 | 562 | 'QST_ID'=> $question->ID(), |
564 | 563 | 'REG_ID'=> $registration->ID() |
565 | 564 | )); |
566 | 565 | } |
567 | 566 | // verify instance |
568 | - if( $answer instanceof EE_Answer ){ |
|
569 | - if ( ! empty( $answer_value )) { |
|
570 | - $answer->set( 'ANS_value', $answer_value ); |
|
567 | + if ($answer instanceof EE_Answer) { |
|
568 | + if ( ! empty($answer_value)) { |
|
569 | + $answer->set('ANS_value', $answer_value); |
|
571 | 570 | } |
572 | - $answer->cache( 'Question', $question ); |
|
571 | + $answer->cache('Question', $question); |
|
573 | 572 | //remember system ID had a bug where sometimes it could be null |
574 | - $answer_cache_id =$question->is_system_question() |
|
575 | - ? $question->system_ID() . '-' . $registration->reg_url_link() |
|
576 | - : $question->ID() . '-' . $registration->reg_url_link(); |
|
577 | - $registration->cache( 'Answer', $answer, $answer_cache_id ); |
|
573 | + $answer_cache_id = $question->is_system_question() |
|
574 | + ? $question->system_ID().'-'.$registration->reg_url_link() |
|
575 | + : $question->ID().'-'.$registration->reg_url_link(); |
|
576 | + $registration->cache('Answer', $answer, $answer_cache_id); |
|
578 | 577 | } |
579 | - return $this->_generate_question_input( $registration, $question, $answer ); |
|
578 | + return $this->_generate_question_input($registration, $question, $answer); |
|
580 | 579 | |
581 | 580 | } |
582 | 581 | |
@@ -589,46 +588,46 @@ discard block |
||
589 | 588 | * @return EE_Form_Input_Base |
590 | 589 | * @throws \EE_Error |
591 | 590 | */ |
592 | - private function _generate_question_input( EE_Registration $registration, EE_Question $question, $answer ){ |
|
591 | + private function _generate_question_input(EE_Registration $registration, EE_Question $question, $answer) { |
|
593 | 592 | $identifier = $question->is_system_question() ? $question->system_ID() : $question->ID(); |
594 | - $this->_required_questions[ $identifier ] = $question->required() ? true : false; |
|
593 | + $this->_required_questions[$identifier] = $question->required() ? true : false; |
|
595 | 594 | add_filter( |
596 | 595 | 'FHEE__EE_Question__generate_form_input__country_options', |
597 | - array( $this, 'use_cached_countries_for_form_input' ), |
|
596 | + array($this, 'use_cached_countries_for_form_input'), |
|
598 | 597 | 10, |
599 | 598 | 4 |
600 | 599 | ); |
601 | 600 | add_filter( |
602 | 601 | 'FHEE__EE_Question__generate_form_input__state_options', |
603 | - array( $this, 'use_cached_states_for_form_input' ), |
|
602 | + array($this, 'use_cached_states_for_form_input'), |
|
604 | 603 | 10, |
605 | 604 | 4 |
606 | 605 | ); |
607 | 606 | $input_constructor_args = array( |
608 | - 'html_name' => 'ee_reg_qstn[' . $registration->ID() . '][' . $identifier . ']', |
|
609 | - 'html_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
610 | - 'html_class' => 'ee-reg-qstn ee-reg-qstn-' . $identifier, |
|
611 | - 'html_label_id' => 'ee_reg_qstn-' . $registration->ID() . '-' . $identifier, |
|
607 | + 'html_name' => 'ee_reg_qstn['.$registration->ID().']['.$identifier.']', |
|
608 | + 'html_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
609 | + 'html_class' => 'ee-reg-qstn ee-reg-qstn-'.$identifier, |
|
610 | + 'html_label_id' => 'ee_reg_qstn-'.$registration->ID().'-'.$identifier, |
|
612 | 611 | 'html_label_class' => 'ee-reg-qstn', |
613 | 612 | ); |
614 | - $input_constructor_args['html_label_id'] .= '-lbl'; |
|
615 | - if ( $answer instanceof EE_Answer && $answer->ID() ) { |
|
616 | - $input_constructor_args[ 'html_name' ] .= '[' . $answer->ID() . ']'; |
|
617 | - $input_constructor_args[ 'html_id' ] .= '-' . $answer->ID(); |
|
618 | - $input_constructor_args[ 'html_label_id' ] .= '-' . $answer->ID(); |
|
613 | + $input_constructor_args['html_label_id'] .= '-lbl'; |
|
614 | + if ($answer instanceof EE_Answer && $answer->ID()) { |
|
615 | + $input_constructor_args['html_name'] .= '['.$answer->ID().']'; |
|
616 | + $input_constructor_args['html_id'] .= '-'.$answer->ID(); |
|
617 | + $input_constructor_args['html_label_id'] .= '-'.$answer->ID(); |
|
619 | 618 | } |
620 | - $form_input = $question->generate_form_input( |
|
619 | + $form_input = $question->generate_form_input( |
|
621 | 620 | $registration, |
622 | 621 | $answer, |
623 | 622 | $input_constructor_args |
624 | 623 | ); |
625 | 624 | remove_filter( |
626 | 625 | 'FHEE__EE_Question__generate_form_input__country_options', |
627 | - array( $this, 'use_cached_countries_for_form_input' ) |
|
626 | + array($this, 'use_cached_countries_for_form_input') |
|
628 | 627 | ); |
629 | 628 | remove_filter( |
630 | 629 | 'FHEE__EE_Question__generate_form_input__state_options', |
631 | - array( $this, 'use_cached_states_for_form_input' ) |
|
630 | + array($this, 'use_cached_states_for_form_input') |
|
632 | 631 | ); |
633 | 632 | return $form_input; |
634 | 633 | } |
@@ -642,23 +641,23 @@ discard block |
||
642 | 641 | * @return array 2d keys are country IDs, values are their names |
643 | 642 | * @throws \EE_Error |
644 | 643 | */ |
645 | - public function use_cached_countries_for_form_input( $countries_list, $question, $registration, $answer ) { |
|
646 | - $country_options = array( '' => '' ); |
|
644 | + public function use_cached_countries_for_form_input($countries_list, $question, $registration, $answer) { |
|
645 | + $country_options = array('' => ''); |
|
647 | 646 | // get possibly cached list of countries |
648 | 647 | $countries = $this->checkout->action === 'process_reg_step' |
649 | 648 | ? EEM_Country::instance()->get_all_countries() |
650 | 649 | : EEM_Country::instance()->get_all_active_countries(); |
651 | - if ( ! empty( $countries )) { |
|
652 | - foreach( $countries as $country ){ |
|
653 | - if ( $country instanceof EE_Country ) { |
|
654 | - $country_options[ $country->ID() ] = $country->name(); |
|
650 | + if ( ! empty($countries)) { |
|
651 | + foreach ($countries as $country) { |
|
652 | + if ($country instanceof EE_Country) { |
|
653 | + $country_options[$country->ID()] = $country->name(); |
|
655 | 654 | } |
656 | 655 | } |
657 | 656 | } |
658 | - if( $question instanceof EE_Question |
|
659 | - && $registration instanceof EE_Registration ) { |
|
657 | + if ($question instanceof EE_Question |
|
658 | + && $registration instanceof EE_Registration) { |
|
660 | 659 | $answer = EEM_Answer::instance()->get_one( |
661 | - array( array( 'QST_ID' => $question->ID(), 'REG_ID' => $registration->ID() ) ) |
|
660 | + array(array('QST_ID' => $question->ID(), 'REG_ID' => $registration->ID())) |
|
662 | 661 | ); |
663 | 662 | } else { |
664 | 663 | $answer = EE_Answer::new_instance(); |
@@ -685,15 +684,15 @@ discard block |
||
685 | 684 | * @return array 2d keys are state IDs, values are their names |
686 | 685 | * @throws \EE_Error |
687 | 686 | */ |
688 | - public function use_cached_states_for_form_input( $states_list, $question, $registration, $answer ) { |
|
689 | - $state_options = array( '' => array( '' => '')); |
|
687 | + public function use_cached_states_for_form_input($states_list, $question, $registration, $answer) { |
|
688 | + $state_options = array('' => array('' => '')); |
|
690 | 689 | $states = $this->checkout->action === 'process_reg_step' |
691 | 690 | ? EEM_State::instance()->get_all_states() |
692 | 691 | : EEM_State::instance()->get_all_active_states(); |
693 | - if ( ! empty( $states )) { |
|
694 | - foreach( $states as $state ){ |
|
695 | - if ( $state instanceof EE_State ) { |
|
696 | - $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name(); |
|
692 | + if ( ! empty($states)) { |
|
693 | + foreach ($states as $state) { |
|
694 | + if ($state instanceof EE_State) { |
|
695 | + $state_options[$state->country()->name()][$state->ID()] = $state->name(); |
|
697 | 696 | } |
698 | 697 | } |
699 | 698 | } |
@@ -721,24 +720,24 @@ discard block |
||
721 | 720 | * @throws \EE_Error |
722 | 721 | */ |
723 | 722 | public function process_reg_step() { |
724 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
723 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
725 | 724 | // grab validated data from form |
726 | 725 | $valid_data = $this->checkout->current_step->valid_data(); |
727 | 726 | // EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
728 | 727 | // EEH_Debug_Tools::printr( $valid_data, '$valid_data', __FILE__, __LINE__ ); |
729 | 728 | // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
730 | - if ( empty( $valid_data )) { |
|
729 | + if (empty($valid_data)) { |
|
731 | 730 | EE_Error::add_error( |
732 | - __( 'No valid question responses were received.', 'event_espresso' ), |
|
731 | + __('No valid question responses were received.', 'event_espresso'), |
|
733 | 732 | __FILE__, |
734 | 733 | __FUNCTION__, |
735 | 734 | __LINE__ |
736 | 735 | ); |
737 | 736 | return false; |
738 | 737 | } |
739 | - if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg ) { |
|
738 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
740 | 739 | EE_Error::add_error( |
741 | - __( 'A valid transaction could not be initiated for processing your registrations.', 'event_espresso' ), |
|
740 | + __('A valid transaction could not be initiated for processing your registrations.', 'event_espresso'), |
|
742 | 741 | __FILE__, |
743 | 742 | __FUNCTION__, |
744 | 743 | __LINE__ |
@@ -746,11 +745,11 @@ discard block |
||
746 | 745 | return false; |
747 | 746 | } |
748 | 747 | // get cached registrations |
749 | - $registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ); |
|
748 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
750 | 749 | // verify we got the goods |
751 | - if ( empty( $registrations )) { |
|
750 | + if (empty($registrations)) { |
|
752 | 751 | EE_Error::add_error( |
753 | - __( 'Your form data could not be applied to any valid registrations.', 'event_espresso' ), |
|
752 | + __('Your form data could not be applied to any valid registrations.', 'event_espresso'), |
|
754 | 753 | __FILE__, |
755 | 754 | __FUNCTION__, |
756 | 755 | __LINE__ |
@@ -758,15 +757,15 @@ discard block |
||
758 | 757 | return false; |
759 | 758 | } |
760 | 759 | // extract attendee info from form data and save to model objects |
761 | - $registrations_processed = $this->_process_registrations( $registrations, $valid_data ); |
|
760 | + $registrations_processed = $this->_process_registrations($registrations, $valid_data); |
|
762 | 761 | // if first pass thru SPCO, |
763 | 762 | // then let's check processed registrations against the total number of tickets in the cart |
764 | - if ( $registrations_processed === false ) { |
|
763 | + if ($registrations_processed === false) { |
|
765 | 764 | // but return immediately if the previous step exited early due to errors |
766 | 765 | return false; |
767 | - } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count ) { |
|
766 | + } else if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
768 | 767 | // generate a correctly translated string for all possible singular/plural combinations |
769 | - if ( $this->checkout->total_ticket_count === 1 && $registrations_processed !== 1 ) { |
|
768 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
770 | 769 | $error_msg = sprintf( |
771 | 770 | __( |
772 | 771 | 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
@@ -775,7 +774,7 @@ discard block |
||
775 | 774 | $this->checkout->total_ticket_count, |
776 | 775 | $registrations_processed |
777 | 776 | ); |
778 | - } else if ( $this->checkout->total_ticket_count !== 1 && $registrations_processed === 1 ) { |
|
777 | + } else if ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
779 | 778 | $error_msg = sprintf( |
780 | 779 | __( |
781 | 780 | 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
@@ -794,17 +793,17 @@ discard block |
||
794 | 793 | $registrations_processed |
795 | 794 | ); |
796 | 795 | } |
797 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
796 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
798 | 797 | return false; |
799 | 798 | } |
800 | 799 | // mark this reg step as completed |
801 | 800 | $this->set_completed(); |
802 | 801 | $this->_set_success_message( |
803 | - __( 'The Attendee Information Step has been successfully completed.', 'event_espresso' ) |
|
802 | + __('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
804 | 803 | ); |
805 | 804 | //do action in case a plugin wants to do something with the data submitted in step 1. |
806 | 805 | //passes EE_Single_Page_Checkout, and it's posted data |
807 | - do_action( 'AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data ); |
|
806 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
808 | 807 | return true; |
809 | 808 | } |
810 | 809 | |
@@ -818,9 +817,9 @@ discard block |
||
818 | 817 | * @return boolean | int |
819 | 818 | * @throws \EE_Error |
820 | 819 | */ |
821 | - private function _process_registrations( $registrations = array(), $valid_data = array() ) { |
|
820 | + private function _process_registrations($registrations = array(), $valid_data = array()) { |
|
822 | 821 | // load resources and set some defaults |
823 | - EE_Registry::instance()->load_model( 'Attendee' ); |
|
822 | + EE_Registry::instance()->load_model('Attendee'); |
|
824 | 823 | // holder for primary registrant attendee object |
825 | 824 | $this->checkout->primary_attendee_obj = NULL; |
826 | 825 | // array for tracking reg form data for the primary registrant |
@@ -837,9 +836,9 @@ discard block |
||
837 | 836 | // attendee counter |
838 | 837 | $att_nmbr = 0; |
839 | 838 | // grab the saved registrations from the transaction |
840 | - foreach ( $registrations as $registration ) { |
|
839 | + foreach ($registrations as $registration) { |
|
841 | 840 | // verify EE_Registration object |
842 | - if ( ! $registration instanceof EE_Registration ) { |
|
841 | + if ( ! $registration instanceof EE_Registration) { |
|
843 | 842 | EE_Error::add_error( |
844 | 843 | __( |
845 | 844 | 'An invalid Registration object was discovered when attempting to process your registration information.', |
@@ -854,12 +853,12 @@ discard block |
||
854 | 853 | /** @var string $reg_url_link */ |
855 | 854 | $reg_url_link = $registration->reg_url_link(); |
856 | 855 | // reg_url_link exists ? |
857 | - if ( ! empty( $reg_url_link ) ) { |
|
856 | + if ( ! empty($reg_url_link)) { |
|
858 | 857 | // should this registration be processed during this visit ? |
859 | - if ( $this->checkout->visit_allows_processing_of_this_registration( $registration ) ) { |
|
858 | + if ($this->checkout->visit_allows_processing_of_this_registration($registration)) { |
|
860 | 859 | // if NOT revisiting, then let's save the registration now, |
861 | 860 | // so that we have a REG_ID to use when generating other objects |
862 | - if ( ! $this->checkout->revisit ) { |
|
861 | + if ( ! $this->checkout->revisit) { |
|
863 | 862 | $registration->save(); |
864 | 863 | } |
865 | 864 | /** |
@@ -869,7 +868,7 @@ discard block |
||
869 | 868 | * @var bool if true is returned by the plugin then the |
870 | 869 | * registration processing is halted. |
871 | 870 | */ |
872 | - if ( apply_filters( |
|
871 | + if (apply_filters( |
|
873 | 872 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
874 | 873 | false, |
875 | 874 | $att_nmbr, |
@@ -877,38 +876,38 @@ discard block |
||
877 | 876 | $registrations, |
878 | 877 | $valid_data, |
879 | 878 | $this |
880 | - ) ) { |
|
879 | + )) { |
|
881 | 880 | return false; |
882 | 881 | } |
883 | 882 | |
884 | 883 | // Houston, we have a registration! |
885 | 884 | $att_nmbr++; |
886 | - $this->_attendee_data[ $reg_url_link ] = array(); |
|
885 | + $this->_attendee_data[$reg_url_link] = array(); |
|
887 | 886 | // grab any existing related answer objects |
888 | 887 | $this->_registration_answers = $registration->answers(); |
889 | 888 | // unset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ); |
890 | - if ( isset( $valid_data[ $reg_url_link ] ) ) { |
|
889 | + if (isset($valid_data[$reg_url_link])) { |
|
891 | 890 | // do we need to copy basic info from primary attendee ? |
892 | - $copy_primary = isset( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) |
|
893 | - && absint( $valid_data[ $reg_url_link ]['additional_attendee_reg_info'] ) === 0 |
|
891 | + $copy_primary = isset($valid_data[$reg_url_link]['additional_attendee_reg_info']) |
|
892 | + && absint($valid_data[$reg_url_link]['additional_attendee_reg_info']) === 0 |
|
894 | 893 | ? true |
895 | 894 | : false; |
896 | 895 | // filter form input data for this registration |
897 | - $valid_data[ $reg_url_link ] = (array)apply_filters( |
|
896 | + $valid_data[$reg_url_link] = (array) apply_filters( |
|
898 | 897 | 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
899 | - $valid_data[ $reg_url_link ] |
|
898 | + $valid_data[$reg_url_link] |
|
900 | 899 | ); |
901 | 900 | // EEH_Debug_Tools::printr( $valid_data[ $reg_url_link ], '$valid_data[ $reg_url_link ]', __FILE__, __LINE__ ); |
902 | - if ( isset( $valid_data['primary_attendee'] )) { |
|
903 | - $primary_registrant['line_item_id'] = ! empty( $valid_data['primary_attendee'] ) |
|
901 | + if (isset($valid_data['primary_attendee'])) { |
|
902 | + $primary_registrant['line_item_id'] = ! empty($valid_data['primary_attendee']) |
|
904 | 903 | ? $valid_data['primary_attendee'] |
905 | 904 | : false; |
906 | - unset( $valid_data['primary_attendee'] ); |
|
905 | + unset($valid_data['primary_attendee']); |
|
907 | 906 | } |
908 | 907 | // now loop through our array of valid post data && process attendee reg forms |
909 | - foreach ( $valid_data[ $reg_url_link ] as $form_section => $form_inputs ) { |
|
910 | - if ( ! in_array( $form_section, $non_input_form_sections )) { |
|
911 | - foreach ( $form_inputs as $form_input => $input_value ) { |
|
908 | + foreach ($valid_data[$reg_url_link] as $form_section => $form_inputs) { |
|
909 | + if ( ! in_array($form_section, $non_input_form_sections)) { |
|
910 | + foreach ($form_inputs as $form_input => $input_value) { |
|
912 | 911 | // \EEH_Debug_Tools::printr( $input_value, $form_input, __FILE__, __LINE__ ); |
913 | 912 | // check for critical inputs |
914 | 913 | if ( |
@@ -922,16 +921,16 @@ discard block |
||
922 | 921 | // store a bit of data about the primary attendee |
923 | 922 | if ( |
924 | 923 | $att_nmbr === 1 |
925 | - && ! empty( $input_value ) |
|
924 | + && ! empty($input_value) |
|
926 | 925 | && $reg_url_link === $primary_registrant['line_item_id'] |
927 | 926 | ) { |
928 | - $primary_registrant[ $form_input ] = $input_value; |
|
927 | + $primary_registrant[$form_input] = $input_value; |
|
929 | 928 | } else if ( |
930 | 929 | $copy_primary |
931 | 930 | && $input_value === null |
932 | - && isset( $primary_registrant[ $form_input ] ) |
|
931 | + && isset($primary_registrant[$form_input]) |
|
933 | 932 | ) { |
934 | - $input_value = $primary_registrant[ $form_input ]; |
|
933 | + $input_value = $primary_registrant[$form_input]; |
|
935 | 934 | } |
936 | 935 | // now attempt to save the input data |
937 | 936 | if ( |
@@ -973,57 +972,57 @@ discard block |
||
973 | 972 | // have we met before? |
974 | 973 | $attendee = $this->_find_existing_attendee( |
975 | 974 | $registration, |
976 | - $this->_attendee_data[ $reg_url_link ] |
|
975 | + $this->_attendee_data[$reg_url_link] |
|
977 | 976 | ); |
978 | 977 | // did we find an already existing record for this attendee ? |
979 | - if ( $attendee instanceof EE_Attendee ) { |
|
978 | + if ($attendee instanceof EE_Attendee) { |
|
980 | 979 | $attendee = $this->_update_existing_attendee_data( |
981 | 980 | $attendee, |
982 | - $this->_attendee_data[ $reg_url_link ] |
|
981 | + $this->_attendee_data[$reg_url_link] |
|
983 | 982 | ); |
984 | 983 | } else { |
985 | 984 | // ensure critical details are set for additional attendees |
986 | - $this->_attendee_data[ $reg_url_link ] = $att_nmbr > 1 |
|
985 | + $this->_attendee_data[$reg_url_link] = $att_nmbr > 1 |
|
987 | 986 | ? $this->_copy_critical_attendee_details_from_primary_registrant( |
988 | - $this->_attendee_data[ $reg_url_link ] |
|
987 | + $this->_attendee_data[$reg_url_link] |
|
989 | 988 | ) |
990 | - : $this->_attendee_data[ $reg_url_link ]; |
|
989 | + : $this->_attendee_data[$reg_url_link]; |
|
991 | 990 | $attendee = $this->_create_new_attendee( |
992 | 991 | $registration, |
993 | - $this->_attendee_data[ $reg_url_link ] |
|
992 | + $this->_attendee_data[$reg_url_link] |
|
994 | 993 | ); |
995 | 994 | } |
996 | 995 | // who's #1 ? |
997 | - if ( $att_nmbr === 1 ) { |
|
996 | + if ($att_nmbr === 1) { |
|
998 | 997 | $this->checkout->primary_attendee_obj = $attendee; |
999 | 998 | } |
1000 | 999 | } |
1001 | 1000 | // EEH_Debug_Tools::printr( $attendee, '$attendee', __FILE__, __LINE__ ); |
1002 | 1001 | // add relation to registration, set attendee ID, and cache attendee |
1003 | - $this->_associate_attendee_with_registration( $registration, $attendee ); |
|
1002 | + $this->_associate_attendee_with_registration($registration, $attendee); |
|
1004 | 1003 | // \EEH_Debug_Tools::printr( $registration, '$registration', __FILE__, __LINE__ ); |
1005 | - if ( ! $registration->attendee() instanceof EE_Attendee ) { |
|
1006 | - EE_Error::add_error( sprintf( __( 'Registration %s has an invalid or missing Attendee object.', 'event_espresso' ), $reg_url_link ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1004 | + if ( ! $registration->attendee() instanceof EE_Attendee) { |
|
1005 | + EE_Error::add_error(sprintf(__('Registration %s has an invalid or missing Attendee object.', 'event_espresso'), $reg_url_link), __FILE__, __FUNCTION__, __LINE__); |
|
1007 | 1006 | return false; |
1008 | 1007 | } |
1009 | 1008 | /** @type EE_Registration_Processor $registration_processor */ |
1010 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
1009 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
1011 | 1010 | // at this point, we should have enough details about the registrant to consider the registration NOT incomplete |
1012 | - $registration_processor->toggle_incomplete_registration_status_to_default( $registration, false ); |
|
1011 | + $registration_processor->toggle_incomplete_registration_status_to_default($registration, false); |
|
1013 | 1012 | /** @type EE_Transaction_Processor $transaction_processor */ |
1014 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
1013 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
1015 | 1014 | // we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned |
1016 | - $transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction ); |
|
1015 | + $transaction_processor->toggle_failed_transaction_status($this->checkout->transaction); |
|
1017 | 1016 | // if we've gotten this far, then let's save what we have |
1018 | 1017 | $registration->save(); |
1019 | 1018 | // add relation between TXN and registration |
1020 | - $this->_associate_registration_with_transaction( $registration ); |
|
1019 | + $this->_associate_registration_with_transaction($registration); |
|
1021 | 1020 | } // end of if ( ! $this->checkout->revisit || $this->checkout->primary_revisit || ( $this->checkout->revisit && $this->checkout->reg_url_link == $reg_url_link )) { |
1022 | 1021 | |
1023 | - } else { |
|
1024 | - EE_Error::add_error( __( 'An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1022 | + } else { |
|
1023 | + EE_Error::add_error(__('An invalid or missing line item ID was encountered while attempting to process the registration form.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1025 | 1024 | // remove malformed data |
1026 | - unset( $valid_data[ $reg_url_link ] ); |
|
1025 | + unset($valid_data[$reg_url_link]); |
|
1027 | 1026 | return false; |
1028 | 1027 | } |
1029 | 1028 | |
@@ -1052,26 +1051,26 @@ discard block |
||
1052 | 1051 | // \EEH_Debug_Tools::printr( $input_value, '$input_value', __FILE__, __LINE__ ); |
1053 | 1052 | // allow for plugins to hook in and do their own processing of the form input. |
1054 | 1053 | // For plugins to bypass normal processing here, they just need to return a boolean value. |
1055 | - if ( apply_filters( |
|
1054 | + if (apply_filters( |
|
1056 | 1055 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
1057 | 1056 | false, |
1058 | 1057 | $registration, |
1059 | 1058 | $form_input, |
1060 | 1059 | $input_value, |
1061 | 1060 | $this |
1062 | - ) ) { |
|
1061 | + )) { |
|
1063 | 1062 | return true; |
1064 | 1063 | } |
1065 | 1064 | // $answer_cache_id is the key used to find the EE_Answer we want |
1066 | 1065 | $answer_cache_id = $this->checkout->reg_url_link |
1067 | 1066 | ? $form_input |
1068 | - : $form_input . '-' . $registration->reg_url_link(); |
|
1069 | - $answer_is_obj = isset( $this->_registration_answers[ $answer_cache_id ] ) |
|
1070 | - && $this->_registration_answers[ $answer_cache_id ] instanceof EE_Answer |
|
1067 | + : $form_input.'-'.$registration->reg_url_link(); |
|
1068 | + $answer_is_obj = isset($this->_registration_answers[$answer_cache_id]) |
|
1069 | + && $this->_registration_answers[$answer_cache_id] instanceof EE_Answer |
|
1071 | 1070 | ? true |
1072 | 1071 | : false; |
1073 | 1072 | //rename form_inputs if they are EE_Attendee properties |
1074 | - switch( (string)$form_input ) { |
|
1073 | + switch ((string) $form_input) { |
|
1075 | 1074 | |
1076 | 1075 | case 'state' : |
1077 | 1076 | case 'STA_ID' : |
@@ -1086,32 +1085,32 @@ discard block |
||
1086 | 1085 | break; |
1087 | 1086 | |
1088 | 1087 | default : |
1089 | - $ATT_input = 'ATT_' . $form_input; |
|
1088 | + $ATT_input = 'ATT_'.$form_input; |
|
1090 | 1089 | //EEH_Debug_Tools::printr( $ATT_input, '$ATT_input', __FILE__, __LINE__ ); |
1091 | - $attendee_property = EEM_Attendee::instance()->has_field( $ATT_input ) ? true : false; |
|
1092 | - $form_input = $attendee_property ? 'ATT_' . $form_input : $form_input; |
|
1090 | + $attendee_property = EEM_Attendee::instance()->has_field($ATT_input) ? true : false; |
|
1091 | + $form_input = $attendee_property ? 'ATT_'.$form_input : $form_input; |
|
1093 | 1092 | } |
1094 | 1093 | // EEH_Debug_Tools::printr( $answer_cache_id, '$answer_cache_id', __FILE__, __LINE__ ); |
1095 | 1094 | // EEH_Debug_Tools::printr( $attendee_property, '$attendee_property', __FILE__, __LINE__ ); |
1096 | 1095 | // EEH_Debug_Tools::printr( $answer_is_obj, '$answer_is_obj', __FILE__, __LINE__ ); |
1097 | 1096 | // if this form input has a corresponding attendee property |
1098 | - if ( $attendee_property ) { |
|
1099 | - $this->_attendee_data[ $registration->reg_url_link() ][ $form_input ] = $input_value; |
|
1100 | - if ( $answer_is_obj ) { |
|
1097 | + if ($attendee_property) { |
|
1098 | + $this->_attendee_data[$registration->reg_url_link()][$form_input] = $input_value; |
|
1099 | + if ($answer_is_obj) { |
|
1101 | 1100 | // and delete the corresponding answer since we won't be storing this data in that object |
1102 | - $registration->_remove_relation_to( $this->_registration_answers[ $answer_cache_id ], 'Answer' ); |
|
1103 | - $this->_registration_answers[ $answer_cache_id ]->delete_permanently(); |
|
1101 | + $registration->_remove_relation_to($this->_registration_answers[$answer_cache_id], 'Answer'); |
|
1102 | + $this->_registration_answers[$answer_cache_id]->delete_permanently(); |
|
1104 | 1103 | } |
1105 | 1104 | return true; |
1106 | - } elseif ( $answer_is_obj ) { |
|
1105 | + } elseif ($answer_is_obj) { |
|
1107 | 1106 | // save this data to the answer object |
1108 | - $this->_registration_answers[ $answer_cache_id ]->set_value( $input_value ); |
|
1109 | - $result = $this->_registration_answers[ $answer_cache_id ]->save(); |
|
1107 | + $this->_registration_answers[$answer_cache_id]->set_value($input_value); |
|
1108 | + $result = $this->_registration_answers[$answer_cache_id]->save(); |
|
1110 | 1109 | return $result !== false ? true : false; |
1111 | 1110 | } else { |
1112 | - foreach ( $this->_registration_answers as $answer ) { |
|
1113 | - if ( $answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id ) { |
|
1114 | - $answer->set_value( $input_value ); |
|
1111 | + foreach ($this->_registration_answers as $answer) { |
|
1112 | + if ($answer instanceof EE_Answer && $answer->question_ID() === $answer_cache_id) { |
|
1113 | + $answer->set_value($input_value); |
|
1115 | 1114 | $result = $answer->save(); |
1116 | 1115 | return $result !== false ? true : false; |
1117 | 1116 | } |
@@ -1133,15 +1132,15 @@ discard block |
||
1133 | 1132 | $form_input = '', |
1134 | 1133 | $input_value = '' |
1135 | 1134 | ) { |
1136 | - if ( empty( $input_value ) ) { |
|
1135 | + if (empty($input_value)) { |
|
1137 | 1136 | // if the form input isn't marked as being required, then just return |
1138 | - if ( ! isset( $this->_required_questions[ $form_input ] ) || ! $this->_required_questions[ $form_input ] ) { |
|
1137 | + if ( ! isset($this->_required_questions[$form_input]) || ! $this->_required_questions[$form_input]) { |
|
1139 | 1138 | return true; |
1140 | 1139 | } |
1141 | - switch ( $form_input ) { |
|
1140 | + switch ($form_input) { |
|
1142 | 1141 | case 'fname' : |
1143 | 1142 | EE_Error::add_error( |
1144 | - __( 'First Name is a required value.', 'event_espresso' ), |
|
1143 | + __('First Name is a required value.', 'event_espresso'), |
|
1145 | 1144 | __FILE__, |
1146 | 1145 | __FUNCTION__, |
1147 | 1146 | __LINE__ |
@@ -1150,7 +1149,7 @@ discard block |
||
1150 | 1149 | break; |
1151 | 1150 | case 'lname' : |
1152 | 1151 | EE_Error::add_error( |
1153 | - __( 'Last Name is a required value.', 'event_espresso' ), |
|
1152 | + __('Last Name is a required value.', 'event_espresso'), |
|
1154 | 1153 | __FILE__, |
1155 | 1154 | __FUNCTION__, |
1156 | 1155 | __LINE__ |
@@ -1159,7 +1158,7 @@ discard block |
||
1159 | 1158 | break; |
1160 | 1159 | case 'email' : |
1161 | 1160 | EE_Error::add_error( |
1162 | - __( 'Please enter a valid email address.', 'event_espresso' ), |
|
1161 | + __('Please enter a valid email address.', 'event_espresso'), |
|
1163 | 1162 | __FILE__, |
1164 | 1163 | __FUNCTION__, |
1165 | 1164 | __LINE__ |
@@ -1192,21 +1191,21 @@ discard block |
||
1192 | 1191 | * @param array $attendee_data |
1193 | 1192 | * @return boolean |
1194 | 1193 | */ |
1195 | - private function _find_existing_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1194 | + private function _find_existing_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1196 | 1195 | $existing_attendee = null; |
1197 | 1196 | // does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address |
1198 | - $ATT_fname = isset( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_fname'] ) |
|
1197 | + $ATT_fname = isset($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_fname']) |
|
1199 | 1198 | ? $attendee_data['ATT_fname'] |
1200 | 1199 | : ''; |
1201 | - $ATT_lname = isset( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_lname'] ) |
|
1200 | + $ATT_lname = isset($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_lname']) |
|
1202 | 1201 | ? $attendee_data['ATT_lname'] |
1203 | 1202 | : ''; |
1204 | - $ATT_email = isset( $attendee_data['ATT_email'] ) && ! empty( $attendee_data['ATT_email'] ) |
|
1203 | + $ATT_email = isset($attendee_data['ATT_email']) && ! empty($attendee_data['ATT_email']) |
|
1205 | 1204 | ? $attendee_data['ATT_email'] |
1206 | 1205 | : ''; |
1207 | 1206 | // but only if those have values |
1208 | - if ( $ATT_fname && $ATT_lname && $ATT_email ) { |
|
1209 | - $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array( |
|
1207 | + if ($ATT_fname && $ATT_lname && $ATT_email) { |
|
1208 | + $existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array( |
|
1210 | 1209 | 'ATT_fname' => $ATT_fname, |
1211 | 1210 | 'ATT_lname' => $ATT_lname, |
1212 | 1211 | 'ATT_email' => $ATT_email |
@@ -1230,13 +1229,13 @@ discard block |
||
1230 | 1229 | * @return \EE_Attendee |
1231 | 1230 | * @throws \EE_Error |
1232 | 1231 | */ |
1233 | - private function _update_existing_attendee_data( EE_Attendee $existing_attendee, $attendee_data = array() ) { |
|
1232 | + private function _update_existing_attendee_data(EE_Attendee $existing_attendee, $attendee_data = array()) { |
|
1234 | 1233 | // first remove fname, lname, and email from attendee data |
1235 | - $dont_set = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1234 | + $dont_set = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1236 | 1235 | // now loop thru what's left and add to attendee CPT |
1237 | - foreach ( $attendee_data as $property_name => $property_value ) { |
|
1238 | - if ( ! in_array( $property_name, $dont_set ) && EEM_Attendee::instance()->has_field( $property_name )) { |
|
1239 | - $existing_attendee->set( $property_name, $property_value ); |
|
1236 | + foreach ($attendee_data as $property_name => $property_value) { |
|
1237 | + if ( ! in_array($property_name, $dont_set) && EEM_Attendee::instance()->has_field($property_name)) { |
|
1238 | + $existing_attendee->set($property_name, $property_value); |
|
1240 | 1239 | } |
1241 | 1240 | } |
1242 | 1241 | // better save that now |
@@ -1254,11 +1253,11 @@ discard block |
||
1254 | 1253 | * @return void |
1255 | 1254 | * @throws \EE_Error |
1256 | 1255 | */ |
1257 | - private function _associate_attendee_with_registration( EE_Registration $registration, EE_Attendee $attendee ) { |
|
1256 | + private function _associate_attendee_with_registration(EE_Registration $registration, EE_Attendee $attendee) { |
|
1258 | 1257 | // add relation to attendee |
1259 | - $registration->_add_relation_to( $attendee, 'Attendee' ); |
|
1260 | - $registration->set_attendee_id( $attendee->ID() ); |
|
1261 | - $registration->update_cache_after_object_save( 'Attendee', $attendee ); |
|
1258 | + $registration->_add_relation_to($attendee, 'Attendee'); |
|
1259 | + $registration->set_attendee_id($attendee->ID()); |
|
1260 | + $registration->update_cache_after_object_save('Attendee', $attendee); |
|
1262 | 1261 | } |
1263 | 1262 | |
1264 | 1263 | |
@@ -1270,10 +1269,10 @@ discard block |
||
1270 | 1269 | * @return void |
1271 | 1270 | * @throws \EE_Error |
1272 | 1271 | */ |
1273 | - private function _associate_registration_with_transaction( EE_Registration $registration ) { |
|
1272 | + private function _associate_registration_with_transaction(EE_Registration $registration) { |
|
1274 | 1273 | // add relation to attendee |
1275 | - $this->checkout->transaction->_add_relation_to( $registration, 'Registration' ); |
|
1276 | - $this->checkout->transaction->update_cache_after_object_save( 'Registration', $registration ); |
|
1274 | + $this->checkout->transaction->_add_relation_to($registration, 'Registration'); |
|
1275 | + $this->checkout->transaction->update_cache_after_object_save('Registration', $registration); |
|
1277 | 1276 | } |
1278 | 1277 | |
1279 | 1278 | |
@@ -1286,14 +1285,14 @@ discard block |
||
1286 | 1285 | * @return array |
1287 | 1286 | * @throws \EE_Error |
1288 | 1287 | */ |
1289 | - private function _copy_critical_attendee_details_from_primary_registrant( $attendee_data = array() ) { |
|
1288 | + private function _copy_critical_attendee_details_from_primary_registrant($attendee_data = array()) { |
|
1290 | 1289 | // bare minimum critical details include first name, last name, email address |
1291 | - $critical_attendee_details = array( 'ATT_fname', 'ATT_lname', 'ATT_email' ); |
|
1290 | + $critical_attendee_details = array('ATT_fname', 'ATT_lname', 'ATT_email'); |
|
1292 | 1291 | // add address info to critical details? |
1293 | - if ( apply_filters( |
|
1292 | + if (apply_filters( |
|
1294 | 1293 | 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
1295 | 1294 | false |
1296 | - ) ) { |
|
1295 | + )) { |
|
1297 | 1296 | $address_details = array( |
1298 | 1297 | 'ATT_address', |
1299 | 1298 | 'ATT_address2', |
@@ -1303,13 +1302,13 @@ discard block |
||
1303 | 1302 | 'ATT_zip', |
1304 | 1303 | 'ATT_phone' |
1305 | 1304 | ); |
1306 | - $critical_attendee_details = array_merge( $critical_attendee_details, $address_details ); |
|
1305 | + $critical_attendee_details = array_merge($critical_attendee_details, $address_details); |
|
1307 | 1306 | } |
1308 | - foreach ( $critical_attendee_details as $critical_attendee_detail ) { |
|
1309 | - if ( ! isset( $attendee_data[ $critical_attendee_detail ] ) |
|
1310 | - || empty( $attendee_data[ $critical_attendee_detail ] ) |
|
1307 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
1308 | + if ( ! isset($attendee_data[$critical_attendee_detail]) |
|
1309 | + || empty($attendee_data[$critical_attendee_detail]) |
|
1311 | 1310 | ) { |
1312 | - $attendee_data[ $critical_attendee_detail ] = $this->checkout->primary_attendee_obj->get( |
|
1311 | + $attendee_data[$critical_attendee_detail] = $this->checkout->primary_attendee_obj->get( |
|
1313 | 1312 | $critical_attendee_detail |
1314 | 1313 | ); |
1315 | 1314 | } |
@@ -1327,11 +1326,11 @@ discard block |
||
1327 | 1326 | * @return \EE_Attendee |
1328 | 1327 | * @throws \EE_Error |
1329 | 1328 | */ |
1330 | - private function _create_new_attendee( EE_Registration $registration, $attendee_data = array() ) { |
|
1329 | + private function _create_new_attendee(EE_Registration $registration, $attendee_data = array()) { |
|
1331 | 1330 | // create new attendee object |
1332 | - $new_attendee = EE_Attendee::new_instance( $attendee_data ); |
|
1331 | + $new_attendee = EE_Attendee::new_instance($attendee_data); |
|
1333 | 1332 | // set author to event creator |
1334 | - $new_attendee->set( 'ATT_author', $registration->event()->wp_user() ); |
|
1333 | + $new_attendee->set('ATT_author', $registration->event()->wp_user()); |
|
1335 | 1334 | $new_attendee->save(); |
1336 | 1335 | return $new_attendee; |
1337 | 1336 | } |
@@ -1348,7 +1347,7 @@ discard block |
||
1348 | 1347 | */ |
1349 | 1348 | public function update_reg_step() { |
1350 | 1349 | // save everything |
1351 | - if ( $this->process_reg_step() ) { |
|
1350 | + if ($this->process_reg_step()) { |
|
1352 | 1351 | $this->checkout->redirect = true; |
1353 | 1352 | $this->checkout->redirect_url = add_query_arg( |
1354 | 1353 | array( |
@@ -1357,7 +1356,7 @@ discard block |
||
1357 | 1356 | ), |
1358 | 1357 | $this->checkout->thank_you_page_url |
1359 | 1358 | ); |
1360 | - $this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url ); |
|
1359 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
1361 | 1360 | return true; |
1362 | 1361 | } |
1363 | 1362 | return false; |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * Gets all the attendees for this transaction (handy for use with EE_Attendee's get_registrations_for_event function |
413 | 413 | * for getting attendees and how many registrations they each have for an event) |
414 | 414 | * |
415 | - * @return mixed EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
415 | + * @return EE_Base_Class[] EE_Attendee[] by default, int if $output is set to 'COUNT' |
|
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function attendees() { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | * Gets all the extra meta info on this payment |
694 | 694 | * |
695 | 695 | * @param array $query_params like EEM_Base::get_all |
696 | - * @return EE_Extra_Meta |
|
696 | + * @return EE_Base_Class[] |
|
697 | 697 | * @throws \EE_Error |
698 | 698 | */ |
699 | 699 | public function extra_meta( $query_params = array() ) { |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | * Sets PMD_ID |
871 | 871 | * |
872 | 872 | * @param int $PMD_ID |
873 | - * @return boolean |
|
873 | + * @return boolean|null |
|
874 | 874 | * @throws \EE_Error |
875 | 875 | */ |
876 | 876 | public function set_payment_method_ID($PMD_ID) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Transaction class |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | * @return EE_Transaction |
26 | 26 | * @throws \EE_Error |
27 | 27 | */ |
28 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
29 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
28 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
29 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
30 | 30 | return $has_object |
31 | 31 | ? $has_object |
32 | - : new self( $props_n_values, false, $timezone, $date_formats ); |
|
32 | + : new self($props_n_values, false, $timezone, $date_formats); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @return EE_Transaction |
42 | 42 | * @throws \EE_Error |
43 | 43 | */ |
44 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
45 | - return new self( $props_n_values, TRUE, $timezone ); |
|
44 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
45 | + return new self($props_n_values, TRUE, $timezone); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function lock() { |
60 | 60 | // attempt to set lock, but if that fails... |
61 | - if ( ! $this->add_extra_meta( 'lock', time(), true ) ) { |
|
61 | + if ( ! $this->add_extra_meta('lock', time(), true)) { |
|
62 | 62 | // then attempt to remove the lock in case it is expired |
63 | - if ( $this->_remove_expired_lock() ) { |
|
63 | + if ($this->_remove_expired_lock()) { |
|
64 | 64 | // if removal was successful, then try setting lock again |
65 | 65 | $this->lock(); |
66 | 66 | } else { |
67 | 67 | // but if the lock can not be removed, then throw an exception |
68 | 68 | throw new EE_Error( |
69 | 69 | sprintf( |
70 | - __( 'Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso' ), |
|
70 | + __('Could not lock Transaction %1$d because it is already locked, meaning another part of the system is currently editing it. It should already be unlocked by the time you read this, so please refresh the page and try again.', 'event_espresso'), |
|
71 | 71 | $this->ID() |
72 | 72 | ) |
73 | 73 | ); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @throws \EE_Error |
87 | 87 | */ |
88 | 88 | public function unlock() { |
89 | - return $this->delete_extra_meta( 'lock' ); |
|
89 | + return $this->delete_extra_meta('lock'); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function is_locked() { |
109 | 109 | // if TXN is not locked, then return false immediately |
110 | - if ( ! $this->_get_lock() ) { |
|
110 | + if ( ! $this->_get_lock()) { |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | // if not, then let's try and remove the lock in case it's expired... |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @throws \EE_Error |
129 | 129 | */ |
130 | 130 | protected function _get_lock() { |
131 | - return (int)$this->get_extra_meta( 'lock', true, 0 ); |
|
131 | + return (int) $this->get_extra_meta('lock', true, 0); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function _remove_expired_lock() { |
145 | 145 | $locked = $this->_get_lock(); |
146 | - if ( $locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked ) { |
|
146 | + if ($locked && time() - EE_Transaction::LOCK_EXPIRATION > $locked) { |
|
147 | 147 | return $this->unlock(); |
148 | 148 | } |
149 | 149 | return 0; |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param float $total total value of transaction |
159 | 159 | * @throws \EE_Error |
160 | 160 | */ |
161 | - public function set_total( $total = 0.00 ) { |
|
162 | - $this->set( 'TXN_total', (float)$total ); |
|
161 | + public function set_total($total = 0.00) { |
|
162 | + $this->set('TXN_total', (float) $total); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param float $total_paid total amount paid to date (sum of all payments) |
172 | 172 | * @throws \EE_Error |
173 | 173 | */ |
174 | - public function set_paid( $total_paid = 0.00 ) { |
|
175 | - $this->set( 'TXN_paid', (float)$total_paid ); |
|
174 | + public function set_paid($total_paid = 0.00) { |
|
175 | + $this->set('TXN_paid', (float) $total_paid); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $status whether the transaction is open, declined, accepted, or any number of custom values that can be set |
185 | 185 | * @throws \EE_Error |
186 | 186 | */ |
187 | - public function set_status( $status = '' ) { |
|
188 | - $this->set( 'STS_ID', $status ); |
|
187 | + public function set_status($status = '') { |
|
188 | + $this->set('STS_ID', $status); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param string $hash_salt required for some payment gateways |
198 | 198 | * @throws \EE_Error |
199 | 199 | */ |
200 | - public function set_hash_salt( $hash_salt = '' ) { |
|
201 | - $this->set( 'TXN_hash_salt', $hash_salt ); |
|
200 | + public function set_hash_salt($hash_salt = '') { |
|
201 | + $this->set('TXN_hash_salt', $hash_salt); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | * @param array $txn_reg_steps |
210 | 210 | * @throws \EE_Error |
211 | 211 | */ |
212 | - public function set_reg_steps( array $txn_reg_steps ) { |
|
213 | - $this->set( 'TXN_reg_steps', $txn_reg_steps ); |
|
212 | + public function set_reg_steps(array $txn_reg_steps) { |
|
213 | + $this->set('TXN_reg_steps', $txn_reg_steps); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @throws \EE_Error |
223 | 223 | */ |
224 | 224 | public function reg_steps() { |
225 | - $TXN_reg_steps = $this->get( 'TXN_reg_steps' ); |
|
226 | - return is_array( $TXN_reg_steps ) ? (array)$TXN_reg_steps : array(); |
|
225 | + $TXN_reg_steps = $this->get('TXN_reg_steps'); |
|
226 | + return is_array($TXN_reg_steps) ? (array) $TXN_reg_steps : array(); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @throws \EE_Error |
234 | 234 | */ |
235 | 235 | public function pretty_total() { |
236 | - return $this->get_pretty( 'TXN_total' ); |
|
236 | + return $this->get_pretty('TXN_total'); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @throws \EE_Error |
246 | 246 | */ |
247 | 247 | public function pretty_paid() { |
248 | - return $this->get_pretty( 'TXN_paid' ); |
|
248 | + return $this->get_pretty('TXN_paid'); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @throws \EE_Error |
259 | 259 | */ |
260 | 260 | public function remaining() { |
261 | - return (float)( $this->total() - $this->paid() ); |
|
261 | + return (float) ($this->total() - $this->paid()); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @throws \EE_Error |
272 | 272 | */ |
273 | 273 | public function total() { |
274 | - return (float)$this->get( 'TXN_total' ); |
|
274 | + return (float) $this->get('TXN_total'); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @throws \EE_Error |
285 | 285 | */ |
286 | 286 | public function paid() { |
287 | - return (float)$this->get( 'TXN_paid' ); |
|
287 | + return (float) $this->get('TXN_paid'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * @throws \EE_Error |
297 | 297 | */ |
298 | 298 | public function get_cart_session() { |
299 | - $session_data = (array)$this->get( 'TXN_session_data' ); |
|
300 | - return isset( $session_data[ 'cart' ] ) && $session_data[ 'cart' ] instanceof EE_Cart |
|
301 | - ? $session_data[ 'cart' ] |
|
299 | + $session_data = (array) $this->get('TXN_session_data'); |
|
300 | + return isset($session_data['cart']) && $session_data['cart'] instanceof EE_Cart |
|
301 | + ? $session_data['cart'] |
|
302 | 302 | : null; |
303 | 303 | } |
304 | 304 | |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @throws \EE_Error |
312 | 312 | */ |
313 | 313 | public function session_data() { |
314 | - $session_data = $this->get( 'TXN_session_data' ); |
|
315 | - if ( empty( $session_data ) ) { |
|
314 | + $session_data = $this->get('TXN_session_data'); |
|
315 | + if (empty($session_data)) { |
|
316 | 316 | $session_data = array( |
317 | 317 | 'id' => null, |
318 | 318 | 'user_id' => null, |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | * @param EE_Session|array $session_data |
336 | 336 | * @throws \EE_Error |
337 | 337 | */ |
338 | - public function set_txn_session_data( $session_data ) { |
|
339 | - if ( $session_data instanceof EE_Session ) { |
|
340 | - $this->set( 'TXN_session_data', $session_data->get_session_data( NULL, TRUE )); |
|
338 | + public function set_txn_session_data($session_data) { |
|
339 | + if ($session_data instanceof EE_Session) { |
|
340 | + $this->set('TXN_session_data', $session_data->get_session_data(NULL, TRUE)); |
|
341 | 341 | } else { |
342 | - $this->set( 'TXN_session_data', $session_data ); |
|
342 | + $this->set('TXN_session_data', $session_data); |
|
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | * @throws \EE_Error |
353 | 353 | */ |
354 | 354 | public function hash_salt_() { |
355 | - return $this->get( 'TXN_hash_salt' ); |
|
355 | + return $this->get('TXN_hash_salt'); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | * @return string | int |
373 | 373 | * @throws \EE_Error |
374 | 374 | */ |
375 | - public function datetime( $format = FALSE, $gmt = FALSE ) { |
|
376 | - if ( $format ) { |
|
377 | - return $this->get_pretty( 'TXN_timestamp' ); |
|
378 | - } else if ( $gmt ) { |
|
379 | - return $this->get_raw( 'TXN_timestamp' ); |
|
375 | + public function datetime($format = FALSE, $gmt = FALSE) { |
|
376 | + if ($format) { |
|
377 | + return $this->get_pretty('TXN_timestamp'); |
|
378 | + } else if ($gmt) { |
|
379 | + return $this->get_raw('TXN_timestamp'); |
|
380 | 380 | } else { |
381 | - return $this->get( 'TXN_timestamp' ); |
|
381 | + return $this->get('TXN_timestamp'); |
|
382 | 382 | } |
383 | 383 | } |
384 | 384 | |
@@ -392,8 +392,8 @@ discard block |
||
392 | 392 | * @return EE_Registration[] |
393 | 393 | * @throws \EE_Error |
394 | 394 | */ |
395 | - public function registrations( $query_params = array(), $get_cached = FALSE ) { |
|
396 | - $query_params = ( empty( $query_params ) || ! is_array( $query_params ) ) |
|
395 | + public function registrations($query_params = array(), $get_cached = FALSE) { |
|
396 | + $query_params = (empty($query_params) || ! is_array($query_params)) |
|
397 | 397 | ? array( |
398 | 398 | 'order_by' => array( |
399 | 399 | 'Event.EVT_name' => 'ASC', |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | ) |
404 | 404 | : $query_params; |
405 | 405 | $query_params = $get_cached ? array() : $query_params; |
406 | - return $this->get_many_related( 'Registration', $query_params ); |
|
406 | + return $this->get_many_related('Registration', $query_params); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | * @throws \EE_Error |
417 | 417 | */ |
418 | 418 | public function attendees() { |
419 | - return $this->get_many_related( 'Attendee', array( array( 'Registration.Transaction.TXN_ID' => $this->ID() ) ) ); |
|
419 | + return $this->get_many_related('Attendee', array(array('Registration.Transaction.TXN_ID' => $this->ID()))); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @return EE_Payment[] |
429 | 429 | * @throws \EE_Error |
430 | 430 | */ |
431 | - public function payments( $query_params = array() ) { |
|
432 | - return $this->get_many_related( 'Payment', $query_params ); |
|
431 | + public function payments($query_params = array()) { |
|
432 | + return $this->get_many_related('Payment', $query_params); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * @throws \EE_Error |
442 | 442 | */ |
443 | 443 | public function approved_payments() { |
444 | - EE_Registry::instance()->load_model( 'Payment' ); |
|
445 | - return $this->get_many_related( 'Payment', array( array( 'STS_ID' => EEM_Payment::status_id_approved ), 'order_by' => array( 'PAY_timestamp' => 'DESC' ) ) ); |
|
444 | + EE_Registry::instance()->load_model('Payment'); |
|
445 | + return $this->get_many_related('Payment', array(array('STS_ID' => EEM_Payment::status_id_approved), 'order_by' => array('PAY_timestamp' => 'DESC'))); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | * @return string |
455 | 455 | * @throws \EE_Error |
456 | 456 | */ |
457 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
458 | - echo $this->pretty_status( $show_icons ); |
|
457 | + public function e_pretty_status($show_icons = FALSE) { |
|
458 | + echo $this->pretty_status($show_icons); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | |
@@ -467,10 +467,10 @@ discard block |
||
467 | 467 | * @return string |
468 | 468 | * @throws \EE_Error |
469 | 469 | */ |
470 | - public function pretty_status( $show_icons = FALSE ) { |
|
471 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
470 | + public function pretty_status($show_icons = FALSE) { |
|
471 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
472 | 472 | $icon = ''; |
473 | - switch ( $this->status_ID() ) { |
|
473 | + switch ($this->status_ID()) { |
|
474 | 474 | case EEM_Transaction::complete_status_code: |
475 | 475 | $icon = $show_icons ? '<span class="dashicons dashicons-yes ee-icon-size-24 green-text"></span>' : ''; |
476 | 476 | break; |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | $icon = $show_icons ? '<span class="dashicons dashicons-plus ee-icon-size-16 orange-text"></span>' : ''; |
488 | 488 | break; |
489 | 489 | } |
490 | - return $icon . $status[ $this->status_ID() ]; |
|
490 | + return $icon.$status[$this->status_ID()]; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * @throws \EE_Error |
500 | 500 | */ |
501 | 501 | public function status_ID() { |
502 | - return $this->get( 'STS_ID' ); |
|
502 | + return $this->get('STS_ID'); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @throws \EE_Error |
512 | 512 | */ |
513 | 513 | public function is_free() { |
514 | - return EEH_Money::compare_floats( $this->get( 'TXN_total' ), 0, '==' ); |
|
514 | + return EEH_Money::compare_floats($this->get('TXN_total'), 0, '=='); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | |
@@ -591,12 +591,12 @@ discard block |
||
591 | 591 | * @return string |
592 | 592 | * @throws \EE_Error |
593 | 593 | */ |
594 | - public function invoice_url( $type = 'html' ) { |
|
594 | + public function invoice_url($type = 'html') { |
|
595 | 595 | $REG = $this->primary_registration(); |
596 | - if ( ! $REG instanceof EE_Registration ) { |
|
596 | + if ( ! $REG instanceof EE_Registration) { |
|
597 | 597 | return ''; |
598 | 598 | } |
599 | - return $REG->invoice_url( $type ); |
|
599 | + return $REG->invoice_url($type); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | * @throws \EE_Error |
609 | 609 | */ |
610 | 610 | public function primary_registration() { |
611 | - return $this->get_first_related( 'Registration', array( array( 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT ) ) ); |
|
611 | + return $this->get_first_related('Registration', array(array('REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT))); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | * @return string |
621 | 621 | * @throws \EE_Error |
622 | 622 | */ |
623 | - public function receipt_url( $type = 'html' ) { |
|
623 | + public function receipt_url($type = 'html') { |
|
624 | 624 | $REG = $this->primary_registration(); |
625 | - if ( ! $REG instanceof EE_Registration ) { |
|
625 | + if ( ! $REG instanceof EE_Registration) { |
|
626 | 626 | return ''; |
627 | 627 | } |
628 | - return $REG->receipt_url( $type ); |
|
628 | + return $REG->receipt_url($type); |
|
629 | 629 | } |
630 | 630 | |
631 | 631 | |
@@ -653,15 +653,15 @@ discard block |
||
653 | 653 | * @return boolean |
654 | 654 | * @throws \EE_Error |
655 | 655 | */ |
656 | - public function update_based_on_payments(){ |
|
656 | + public function update_based_on_payments() { |
|
657 | 657 | EE_Error::doing_it_wrong( |
658 | - __CLASS__ . '::' . __FUNCTION__, |
|
659 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
658 | + __CLASS__.'::'.__FUNCTION__, |
|
659 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
660 | 660 | '4.6.0' |
661 | 661 | ); |
662 | 662 | /** @type EE_Transaction_Processor $transaction_processor */ |
663 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
664 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this ); |
|
663 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
664 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | * @throws \EE_Error |
672 | 672 | */ |
673 | 673 | public function gateway_response_on_transaction() { |
674 | - $payment = $this->get_first_related( 'Payment' ); |
|
674 | + $payment = $this->get_first_related('Payment'); |
|
675 | 675 | return $payment instanceof EE_Payment ? $payment->gateway_response() : ''; |
676 | 676 | } |
677 | 677 | |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | * @throws \EE_Error |
685 | 685 | */ |
686 | 686 | public function status_obj() { |
687 | - return $this->get_first_related( 'Status' ); |
|
687 | + return $this->get_first_related('Status'); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | * @return EE_Extra_Meta |
697 | 697 | * @throws \EE_Error |
698 | 698 | */ |
699 | - public function extra_meta( $query_params = array() ) { |
|
700 | - return $this->get_many_related( 'Extra_Meta', $query_params ); |
|
699 | + public function extra_meta($query_params = array()) { |
|
700 | + return $this->get_many_related('Extra_Meta', $query_params); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | * @return EE_Base_Class the relation was added to |
710 | 710 | * @throws \EE_Error |
711 | 711 | */ |
712 | - public function add_registration( EE_Registration $registration ) { |
|
713 | - return $this->_add_relation_to( $registration, 'Registration' ); |
|
712 | + public function add_registration(EE_Registration $registration) { |
|
713 | + return $this->_add_relation_to($registration, 'Registration'); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
@@ -723,8 +723,8 @@ discard block |
||
723 | 723 | * @return EE_Base_Class that was removed from being related |
724 | 724 | * @throws \EE_Error |
725 | 725 | */ |
726 | - public function remove_registration_with_id( $registration_or_id ) { |
|
727 | - return $this->_remove_relation_to( $registration_or_id, 'Registration' ); |
|
726 | + public function remove_registration_with_id($registration_or_id) { |
|
727 | + return $this->_remove_relation_to($registration_or_id, 'Registration'); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | * @throws \EE_Error |
737 | 737 | */ |
738 | 738 | public function items_purchased() { |
739 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_line_item ) ) ); |
|
739 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_line_item))); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | * @return EE_Base_Class the relation was added to |
749 | 749 | * @throws \EE_Error |
750 | 750 | */ |
751 | - public function add_line_item( EE_Line_Item $line_item ) { |
|
752 | - return $this->_add_relation_to( $line_item, 'Line_Item' ); |
|
751 | + public function add_line_item(EE_Line_Item $line_item) { |
|
752 | + return $this->_add_relation_to($line_item, 'Line_Item'); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
@@ -761,8 +761,8 @@ discard block |
||
761 | 761 | * @return EE_Line_Item[] |
762 | 762 | * @throws \EE_Error |
763 | 763 | */ |
764 | - public function line_items( $query_params = array() ) { |
|
765 | - return $this->get_many_related( 'Line_Item', $query_params ); |
|
764 | + public function line_items($query_params = array()) { |
|
765 | + return $this->get_many_related('Line_Item', $query_params); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | * @throws \EE_Error |
775 | 775 | */ |
776 | 776 | public function tax_items() { |
777 | - return $this->line_items( array( array( 'LIN_type' => EEM_Line_Item::type_tax ) ) ); |
|
777 | + return $this->line_items(array(array('LIN_type' => EEM_Line_Item::type_tax))); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -787,9 +787,9 @@ discard block |
||
787 | 787 | * @throws \EE_Error |
788 | 788 | */ |
789 | 789 | public function total_line_item() { |
790 | - $item = $this->get_first_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_total ) ) ); |
|
791 | - if( ! $item ){ |
|
792 | - $item = EEH_Line_Item::create_total_line_item( $this ); |
|
790 | + $item = $this->get_first_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_total))); |
|
791 | + if ( ! $item) { |
|
792 | + $item = EEH_Line_Item::create_total_line_item($this); |
|
793 | 793 | } |
794 | 794 | return $item; |
795 | 795 | } |
@@ -805,10 +805,10 @@ discard block |
||
805 | 805 | */ |
806 | 806 | public function tax_total() { |
807 | 807 | $tax_line_item = $this->tax_total_line_item(); |
808 | - if ( $tax_line_item ) { |
|
809 | - return (float)$tax_line_item->total(); |
|
808 | + if ($tax_line_item) { |
|
809 | + return (float) $tax_line_item->total(); |
|
810 | 810 | } else { |
811 | - return (float)0; |
|
811 | + return (float) 0; |
|
812 | 812 | } |
813 | 813 | } |
814 | 814 | |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @throws \EE_Error |
822 | 822 | */ |
823 | 823 | public function tax_total_line_item() { |
824 | - return EEH_Line_Item::get_taxes_subtotal( $this->total_line_item() ); |
|
824 | + return EEH_Line_Item::get_taxes_subtotal($this->total_line_item()); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -832,20 +832,20 @@ discard block |
||
832 | 832 | * @return EE_Form_Section_Proper |
833 | 833 | * @throws \EE_Error |
834 | 834 | */ |
835 | - public function billing_info(){ |
|
835 | + public function billing_info() { |
|
836 | 836 | $payment_method = $this->payment_method(); |
837 | - if ( !$payment_method){ |
|
837 | + if ( ! $payment_method) { |
|
838 | 838 | EE_Error::add_error(__("Could not find billing info for transaction because no gateway has been used for it yet", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
839 | 839 | return false; |
840 | 840 | } |
841 | 841 | $primary_reg = $this->primary_registration(); |
842 | - if ( ! $primary_reg ) { |
|
843 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
842 | + if ( ! $primary_reg) { |
|
843 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because no primary registration exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
844 | 844 | return FALSE; |
845 | 845 | } |
846 | 846 | $attendee = $primary_reg->attendee(); |
847 | - if ( ! $attendee ) { |
|
848 | - EE_Error::add_error( __( "Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso" ), __FILE__, __FUNCTION__, __LINE__ ); |
|
847 | + if ( ! $attendee) { |
|
848 | + EE_Error::add_error(__("Cannot get billing info for gateway %s on transaction because the primary registration has no attendee exists", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
849 | 849 | return FALSE; |
850 | 850 | } |
851 | 851 | return $attendee->billing_info_for_payment_method($payment_method); |
@@ -886,15 +886,15 @@ discard block |
||
886 | 886 | * @return EE_Payment_Method |
887 | 887 | * @throws \EE_Error |
888 | 888 | */ |
889 | - public function payment_method(){ |
|
889 | + public function payment_method() { |
|
890 | 890 | $pm = $this->get_first_related('Payment_Method'); |
891 | - if( $pm instanceof EE_Payment_Method ){ |
|
891 | + if ($pm instanceof EE_Payment_Method) { |
|
892 | 892 | return $pm; |
893 | - }else{ |
|
893 | + } else { |
|
894 | 894 | $last_payment = $this->last_payment(); |
895 | - if( $last_payment instanceof EE_Payment && $last_payment->payment_method() ){ |
|
895 | + if ($last_payment instanceof EE_Payment && $last_payment->payment_method()) { |
|
896 | 896 | return $last_payment->payment_method(); |
897 | - }else{ |
|
897 | + } else { |
|
898 | 898 | return NULL; |
899 | 899 | } |
900 | 900 | } |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @throws \EE_Error |
910 | 910 | */ |
911 | 911 | public function last_payment() { |
912 | - return $this->get_first_related( 'Payment', array( 'order_by' => array( 'PAY_ID' => 'desc' ) ) ); |
|
912 | + return $this->get_first_related('Payment', array('order_by' => array('PAY_ID' => 'desc'))); |
|
913 | 913 | } |
914 | 914 | |
915 | 915 | |
@@ -920,8 +920,8 @@ discard block |
||
920 | 920 | * @return EE_Line_Item[] |
921 | 921 | * @throws \EE_Error |
922 | 922 | */ |
923 | - public function non_ticket_line_items(){ |
|
924 | - return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction( $this->ID() ); |
|
923 | + public function non_ticket_line_items() { |
|
924 | + return EEM_Line_Item::instance()->get_all_non_ticket_line_items_for_transaction($this->ID()); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 |