@@ -104,8 +104,9 @@ discard block |
||
104 | 104 | * @param string $timezone timezone to set. |
105 | 105 | */ |
106 | 106 | public function set_timezone( $timezone ) { |
107 | - if($timezone !== NULL) |
|
108 | - $this->_timezone = $timezone; |
|
107 | + if($timezone !== NULL) { |
|
108 | + $this->_timezone = $timezone; |
|
109 | + } |
|
109 | 110 | } |
110 | 111 | |
111 | 112 | |
@@ -213,12 +214,12 @@ discard block |
||
213 | 214 | $deleted_count++; |
214 | 215 | if( ! $delete_is_blocked ){ |
215 | 216 | $related_model_object->delete_permanently(); |
216 | - }else{ |
|
217 | + } else{ |
|
217 | 218 | //delete is blocked |
218 | 219 | //brent and darren, in this case, wanted to just soft delete it then |
219 | 220 | $related_model_object->delete(); |
220 | 221 | } |
221 | - }else{ |
|
222 | + } else{ |
|
222 | 223 | //its not a soft-deletable thing anyways. do the normal logic. |
223 | 224 | if( ! $delete_is_blocked ){ |
224 | 225 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
@@ -241,7 +242,7 @@ discard block |
||
241 | 242 | protected function _get_model_object_id($model_object_or_id) { |
242 | 243 | if($model_object_or_id instanceof EE_Base_Class){ |
243 | 244 | $model_object_id = $model_object_or_id->ID(); |
244 | - }else{ |
|
245 | + } else{ |
|
245 | 246 | $model_object_id = $model_object_or_id; |
246 | 247 | } |
247 | 248 | if( ! $model_object_id){ |
@@ -316,7 +317,7 @@ discard block |
||
316 | 317 | public function get_deletion_error_message(){ |
317 | 318 | if($this->_blocking_delete_error_message){ |
318 | 319 | return $this->_blocking_delete_error_message; |
319 | - }else{ |
|
320 | + } else{ |
|
320 | 321 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
321 | 322 | return sprintf( |
322 | 323 | __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * Once those two models are setup correctly, and the relation object has the names of each, it can |
8 | 8 | * magically figure out what tables must be joined on what fields during querying. |
9 | 9 | */ |
10 | -abstract class EE_Model_Relation_Base{ |
|
10 | +abstract class EE_Model_Relation_Base { |
|
11 | 11 | /** |
12 | 12 | * The model name of which this relation is a component (ie, the model that called new EE_Model_Relation_Base) |
13 | 13 | * @var string eg Event, Question_Group, Registration |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @param boolean $block_deletes if there are related models across this relation, block (prevent and add an error) the deletion of this model |
43 | 43 | * @param string $blocking_delete_error_message a customized error message on blocking deletes instead of the default |
44 | 44 | */ |
45 | - function __construct($block_deletes, $blocking_delete_error_message){ |
|
45 | + function __construct($block_deletes, $blocking_delete_error_message) { |
|
46 | 46 | $this->_blocking_delete = $block_deletes; |
47 | - $this->_blocking_delete_error_message=$blocking_delete_error_message; |
|
47 | + $this->_blocking_delete_error_message = $blocking_delete_error_message; |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | * @param $other_model_name |
55 | 55 | * @throws EE_Error |
56 | 56 | */ |
57 | - function _construct_finalize_set_models($this_model_name, $other_model_name){ |
|
57 | + function _construct_finalize_set_models($this_model_name, $other_model_name) { |
|
58 | 58 | $this->_this_model_name = $this_model_name; |
59 | 59 | $this->_other_model_name = $other_model_name; |
60 | - if(is_string($this->_blocking_delete)){ |
|
60 | + if (is_string($this->_blocking_delete)) { |
|
61 | 61 | throw new EE_Error(sprintf(__("When instantiating the relation of type %s from %s to %s, the \$block_deletes argument should be a boolean, not a string (%s)", "event_espresso"), |
62 | - get_class($this),$this_model_name,$other_model_name,$this->_blocking_delete)); |
|
62 | + get_class($this), $this_model_name, $other_model_name, $this->_blocking_delete)); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Gets the model where this relation is defined. |
70 | 70 | * @return EEM_Base |
71 | 71 | */ |
72 | - function get_this_model(){ |
|
72 | + function get_this_model() { |
|
73 | 73 | return $this->_get_model($this->_this_model_name); |
74 | 74 | } |
75 | 75 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * this relation object was defined on get_this_model(), get_other_model() is the other one) |
81 | 81 | * @return EEM_Base |
82 | 82 | */ |
83 | - function get_other_model(){ |
|
83 | + function get_other_model() { |
|
84 | 84 | return $this->_get_model($this->_other_model_name); |
85 | 85 | } |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @param string $model_name like Event, Question_Group, etc. omit the EEM_ |
92 | 92 | * @return EEM_Base |
93 | 93 | */ |
94 | - protected function _get_model($model_name){ |
|
95 | - $modelInstance = EE_Registry::instance()->load_model( $model_name ); |
|
96 | - $modelInstance->set_timezone( $this->_timezone ); |
|
94 | + protected function _get_model($model_name) { |
|
95 | + $modelInstance = EE_Registry::instance()->load_model($model_name); |
|
96 | + $modelInstance->set_timezone($this->_timezone); |
|
97 | 97 | return $modelInstance; |
98 | 98 | } |
99 | 99 | |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | * entirely possible that relations may be called from a model and we need to make sure those relations have their timezone set correctly. |
104 | 104 | * @param string $timezone timezone to set. |
105 | 105 | */ |
106 | - public function set_timezone( $timezone ) { |
|
107 | - if($timezone !== NULL) |
|
106 | + public function set_timezone($timezone) { |
|
107 | + if ($timezone !== NULL) |
|
108 | 108 | $this->_timezone = $timezone; |
109 | 109 | } |
110 | 110 | |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | * @param string $extra_join_sql |
120 | 120 | * @return string |
121 | 121 | */ |
122 | - protected function _left_join($other_table,$other_table_alias,$other_table_column,$this_table_alias,$this_table_join_column, $extra_join_sql = ''){ |
|
123 | - return " LEFT JOIN ".$other_table." AS ".$other_table_alias. " ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column. ($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
122 | + protected function _left_join($other_table, $other_table_alias, $other_table_column, $this_table_alias, $this_table_join_column, $extra_join_sql = '') { |
|
123 | + return " LEFT JOIN ".$other_table." AS ".$other_table_alias." ON ".$other_table_alias.".".$other_table_column."=".$this_table_alias.".".$this_table_join_column.($extra_join_sql ? " AND $extra_join_sql" : ''); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | * @param boolean $values_already_prepared_by_model_object |
137 | 137 | * @return EE_Base_Class[] |
138 | 138 | */ |
139 | - public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false){ |
|
139 | + public function get_all_related($model_object_or_id, $query_params = array(), $values_already_prepared_by_model_object = false) { |
|
140 | 140 | $query_params = $this->_disable_default_where_conditions_on_query_param($query_params); |
141 | 141 | $query_param_where_this_model_pk = $this->get_this_model()->get_this_model_name().".".$this->get_this_model()->get_primary_key_field()->get_name(); |
142 | - $model_object_id = $this->_get_model_object_id( $model_object_or_id ); |
|
142 | + $model_object_id = $this->_get_model_object_id($model_object_or_id); |
|
143 | 143 | $query_params[0][$query_param_where_this_model_pk] = $model_object_id; |
144 | 144 | return $this->get_other_model()->get_all($query_params); |
145 | 145 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param string $query_params |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - protected function _disable_default_where_conditions_on_query_param($query_params){ |
|
155 | - if( ! isset($query_params['default_where_conditions'])){ |
|
156 | - $query_params['default_where_conditions']='none'; |
|
154 | + protected function _disable_default_where_conditions_on_query_param($query_params) { |
|
155 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
156 | + $query_params['default_where_conditions'] = 'none'; |
|
157 | 157 | } |
158 | 158 | return $query_params; |
159 | 159 | } |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | * @param array $query_params |
170 | 170 | * @return int of how many related models got deleted |
171 | 171 | */ |
172 | - public function delete_all_related($model_object_or_id,$query_params = array()){ |
|
172 | + public function delete_all_related($model_object_or_id, $query_params = array()) { |
|
173 | 173 | //for each thing we would delete, |
174 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
174 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
175 | 175 | //determine if it's blocked by anything else before it can be deletedx |
176 | 176 | $deleted_count = 0; |
177 | - foreach($related_model_objects as $related_model_object){ |
|
177 | + foreach ($related_model_objects as $related_model_object) { |
|
178 | 178 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
179 | 179 | /* @var $model_object_or_id EE_Base_Class */ |
180 | - if( ! $delete_is_blocked ){ |
|
180 | + if ( ! $delete_is_blocked) { |
|
181 | 181 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
182 | 182 | $related_model_object->delete(); |
183 | 183 | $deleted_count++; |
@@ -197,27 +197,27 @@ discard block |
||
197 | 197 | * @param array $query_params |
198 | 198 | * @return int of how many related models got deleted |
199 | 199 | */ |
200 | - public function delete_related_permanently($model_object_or_id,$query_params = array()){ |
|
200 | + public function delete_related_permanently($model_object_or_id, $query_params = array()) { |
|
201 | 201 | //for each thing we would delete, |
202 | - $related_model_objects = $this->get_all_related($model_object_or_id,$query_params); |
|
202 | + $related_model_objects = $this->get_all_related($model_object_or_id, $query_params); |
|
203 | 203 | //determine if it's blocked by anything else before it can be deletedx |
204 | 204 | $deleted_count = 0; |
205 | - foreach($related_model_objects as $related_model_object){ |
|
205 | + foreach ($related_model_objects as $related_model_object) { |
|
206 | 206 | $delete_is_blocked = $this->get_other_model()->delete_is_blocked_by_related_models($related_model_object, $model_object_or_id); |
207 | 207 | /* @var $model_object_or_id EE_Base_Class */ |
208 | - if( $related_model_object instanceof EE_Soft_Delete_Base_Class ){ |
|
208 | + if ($related_model_object instanceof EE_Soft_Delete_Base_Class) { |
|
209 | 209 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
210 | 210 | $deleted_count++; |
211 | - if( ! $delete_is_blocked ){ |
|
211 | + if ( ! $delete_is_blocked) { |
|
212 | 212 | $related_model_object->delete_permanently(); |
213 | - }else{ |
|
213 | + } else { |
|
214 | 214 | //delete is blocked |
215 | 215 | //brent and darren, in this case, wanted to just soft delete it then |
216 | 216 | $related_model_object->delete(); |
217 | 217 | } |
218 | - }else{ |
|
218 | + } else { |
|
219 | 219 | //its not a soft-deletable thing anyways. do the normal logic. |
220 | - if( ! $delete_is_blocked ){ |
|
220 | + if ( ! $delete_is_blocked) { |
|
221 | 221 | $this->remove_relation_to($model_object_or_id, $related_model_object); |
222 | 222 | $related_model_object->delete(); |
223 | 223 | $deleted_count++; |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | * @return int |
237 | 237 | */ |
238 | 238 | protected function _get_model_object_id($model_object_or_id) { |
239 | - if($model_object_or_id instanceof EE_Base_Class){ |
|
239 | + if ($model_object_or_id instanceof EE_Base_Class) { |
|
240 | 240 | $model_object_id = $model_object_or_id->ID(); |
241 | - }else{ |
|
241 | + } else { |
|
242 | 242 | $model_object_id = $model_object_or_id; |
243 | 243 | } |
244 | - if( ! $model_object_id){ |
|
245 | - throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"),$this->get_other_model()->get_this_model_name(),$this->get_this_model()->get_this_model_name())); |
|
244 | + if ( ! $model_object_id) { |
|
245 | + throw new EE_Error(sprintf(__("Sorry, we cant get the related %s model objects to %s model object before it has an ID. You can solve that by just saving it before trying to get its related model objects", "event_espresso"), $this->get_other_model()->get_this_model_name(), $this->get_this_model()->get_this_model_name())); |
|
246 | 246 | } |
247 | 247 | return $model_object_id; |
248 | 248 | } |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | * @param array $where_query_param like EEM_Base::get_all's $query_params[0] (where conditions) |
286 | 286 | * @return EE_Base_Class[] |
287 | 287 | */ |
288 | - public function remove_relations($this_obj_or_id,$where_query_param = array()){ |
|
289 | - $related_things = $this->get_all_related($this_obj_or_id,array($where_query_param)); |
|
288 | + public function remove_relations($this_obj_or_id, $where_query_param = array()) { |
|
289 | + $related_things = $this->get_all_related($this_obj_or_id, array($where_query_param)); |
|
290 | 290 | $objs_removed = array(); |
291 | - foreach($related_things as $related_thing){ |
|
291 | + foreach ($related_things as $related_thing) { |
|
292 | 292 | $objs_removed[] = $this->remove_relation_to($this_obj_or_id, $related_thing); |
293 | 293 | } |
294 | 294 | return $objs_removed; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * related objects exist, returns false. |
302 | 302 | * @return boolean |
303 | 303 | */ |
304 | - public function block_delete_if_related_models_exist(){ |
|
304 | + public function block_delete_if_related_models_exist() { |
|
305 | 305 | return $this->_blocking_delete; |
306 | 306 | } |
307 | 307 | |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * Gets the error message to show |
311 | 311 | * @return string |
312 | 312 | */ |
313 | - public function get_deletion_error_message(){ |
|
314 | - if($this->_blocking_delete_error_message){ |
|
313 | + public function get_deletion_error_message() { |
|
314 | + if ($this->_blocking_delete_error_message) { |
|
315 | 315 | return $this->_blocking_delete_error_message; |
316 | - }else{ |
|
316 | + } else { |
|
317 | 317 | // return sprintf(__('Cannot delete %1$s when there are related %2$s', "event_espresso"),$this->get_this_model()->item_name(2),$this->get_other_model()->item_name(2)); |
318 | 318 | return sprintf( |
319 | - __( 'This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
319 | + __('This %1$s is currently linked to one or more %2$s records. If this %1$s is incorrect, then please remove it from all %3$s before attempting to delete it.', "event_espresso"), |
|
320 | 320 | $this->get_this_model()->item_name(1), |
321 | 321 | $this->get_other_model()->item_name(1), |
322 | 322 | $this->get_other_model()->item_name(2) |
@@ -33,7 +33,7 @@ |
||
33 | 33 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
34 | 34 | if($field){ |
35 | 35 | return $field->get_name(); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
38 | 38 | } |
39 | 39 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | /* |
4 | 4 | * Strategy specifically for adding where conditions specific to CPT models. |
5 | 5 | */ |
6 | -class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions{ |
|
6 | +class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions { |
|
7 | 7 | /** |
8 | 8 | * Strategy for setting default soft delete where conditions. This strategy will find |
9 | 9 | * the field of type 'EE_Trashed_Flag_Field', and add a condition that it be FALSE on all queries involving |
@@ -12,16 +12,16 @@ discard block |
||
12 | 12 | * Eg, |
13 | 13 | * |
14 | 14 | */ |
15 | - function __construct(){} |
|
15 | + function __construct() {} |
|
16 | 16 | /** |
17 | 17 | * Gets the where default where conditions for a custom post type model |
18 | 18 | * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment" |
19 | 19 | * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
20 | 20 | */ |
21 | - function get_default_where_conditions($model_relation_chain = null){ |
|
21 | + function get_default_where_conditions($model_relation_chain = null) { |
|
22 | 22 | //make sure there's a period at the end of $model_relation_chain |
23 | - if($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain)-1] !='.'){ |
|
24 | - $model_relation_chain=$model_relation_chain."."; |
|
23 | + if ($model_relation_chain != '' && $model_relation_chain[strlen($model_relation_chain) - 1] != '.') { |
|
24 | + $model_relation_chain = $model_relation_chain."."; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | $trashed_field_name = $this->deleted_field_name(); |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | * @return string |
36 | 36 | * @throws EE_Error |
37 | 37 | */ |
38 | - private function deleted_field_name(){ |
|
38 | + private function deleted_field_name() { |
|
39 | 39 | $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
40 | - if($field){ |
|
40 | + if ($field) { |
|
41 | 41 | return $field->get_name(); |
42 | - }else{ |
|
43 | - throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this))); |
|
42 | + } else { |
|
43 | + throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this))); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -61,10 +61,10 @@ |
||
61 | 61 | $first_item = reset($arr); |
62 | 62 | if(is_array($first_item)){ |
63 | 63 | return true;//yep, there's at least 2 levels to this array |
64 | - }else{ |
|
64 | + } else{ |
|
65 | 65 | return false;//nope, only 1 level |
66 | 66 | } |
67 | - }else{ |
|
67 | + } else{ |
|
68 | 68 | return false;//its not an array at all! |
69 | 69 | } |
70 | 70 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('NO direct script access allowed'); } |
3 | 3 | |
4 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
4 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
5 | 5 | |
6 | 6 | /** |
7 | 7 | * EE_Array |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * @param array $array2 an array of objects |
27 | 27 | * @return array an array of objects found in array 1 that aren't found in array 2. |
28 | 28 | */ |
29 | - public static function object_array_diff( $array1, $array2 ) { |
|
30 | - return array_udiff( $array1, $array2, array('self', '_compare_objects' )); |
|
29 | + public static function object_array_diff($array1, $array2) { |
|
30 | + return array_udiff($array1, $array2, array('self', '_compare_objects')); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param array $arr |
36 | 36 | * @return boolean |
37 | 37 | */ |
38 | - public static function is_associative_array($arr){ |
|
38 | + public static function is_associative_array($arr) { |
|
39 | 39 | return array_keys($arr) !== range(0, count($arr) - 1); |
40 | 40 | } |
41 | 41 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param array $arr |
46 | 46 | * @return mixed what ever is in the array |
47 | 47 | */ |
48 | - public static function get_one_item_from_array($arr){ |
|
48 | + public static function get_one_item_from_array($arr) { |
|
49 | 49 | $item = end($arr); |
50 | 50 | reset($arr); |
51 | 51 | return $item; |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @param mixed $arr |
57 | 57 | * @return boolean |
58 | 58 | */ |
59 | - public static function is_multi_dimensional_array($arr){ |
|
60 | - if(is_array($arr)){ |
|
59 | + public static function is_multi_dimensional_array($arr) { |
|
60 | + if (is_array($arr)) { |
|
61 | 61 | $first_item = reset($arr); |
62 | - if(is_array($first_item)){ |
|
63 | - return true;//yep, there's at least 2 levels to this array |
|
64 | - }else{ |
|
65 | - return false;//nope, only 1 level |
|
62 | + if (is_array($first_item)) { |
|
63 | + return true; //yep, there's at least 2 levels to this array |
|
64 | + } else { |
|
65 | + return false; //nope, only 1 level |
|
66 | 66 | } |
67 | - }else{ |
|
68 | - return false;//its not an array at all! |
|
67 | + } else { |
|
68 | + return false; //its not an array at all! |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @param mixed $default |
77 | 77 | * @return mixed |
78 | 78 | */ |
79 | - public static function is_set( $arr, $index, $default ) { |
|
80 | - return isset( $arr[ $index ] ) ? $arr[ $index ] : $default; |
|
79 | + public static function is_set($arr, $index, $default) { |
|
80 | + return isset($arr[$index]) ? $arr[$index] : $default; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | } //end EEH_Template class |
84 | 84 | \ No newline at end of file |
@@ -23,10 +23,10 @@ |
||
23 | 23 | private static $_instance = NULL; |
24 | 24 | |
25 | 25 | /** |
26 | - * $_autoloaders |
|
27 | - * @var array $_autoloaders |
|
28 | - * @access private |
|
29 | - */ |
|
26 | + * $_autoloaders |
|
27 | + * @var array $_autoloaders |
|
28 | + * @access private |
|
29 | + */ |
|
30 | 30 | private static $_autoloaders; |
31 | 31 | |
32 | 32 |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * EEH_Autoloader |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function instance() { |
40 | 40 | // check if class object is instantiated, and instantiated properly |
41 | - if ( ! self::$_instance instanceof EEH_Autoloader ) { |
|
41 | + if ( ! self::$_instance instanceof EEH_Autoloader) { |
|
42 | 42 | self::$_instance = new self(); |
43 | 43 | } |
44 | 44 | return self::$_instance; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | private function __construct() { |
56 | 56 | self::$_autoloaders = array(); |
57 | 57 | $this->_register_custom_autoloaders(); |
58 | - spl_autoload_register( array( $this, 'espresso_autoloader' )); |
|
58 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @internal param string $class_name - simple class name ie: session |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - public static function espresso_autoloader( $class_name ) { |
|
73 | - if ( isset( self::$_autoloaders[ $class_name ] ) ) { |
|
74 | - require_once( self::$_autoloaders[ $class_name ] ); |
|
72 | + public static function espresso_autoloader($class_name) { |
|
73 | + if (isset(self::$_autoloaders[$class_name])) { |
|
74 | + require_once(self::$_autoloaders[$class_name]); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @throws \EE_Error |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public static function register_autoloader( $class_paths, $read_check = true ) { |
|
90 | - $class_paths = is_array( $class_paths ) ? $class_paths : array( $class_paths ); |
|
91 | - foreach ( $class_paths as $class => $path ) { |
|
89 | + public static function register_autoloader($class_paths, $read_check = true) { |
|
90 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
91 | + foreach ($class_paths as $class => $path) { |
|
92 | 92 | // don't give up! you gotta... |
93 | 93 | // get some class |
94 | - if ( empty( $class )) { |
|
95 | - throw new EE_Error ( sprintf( __( 'No Class name was specified while registering an autoloader for the following path: %s.','event_espresso' ), $path )); |
|
94 | + if (empty($class)) { |
|
95 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
96 | 96 | } |
97 | 97 | // one day you will find the path young grasshopper |
98 | - if ( empty( $path )) { |
|
99 | - throw new EE_Error ( sprintf( __( 'No path was specified while registering an autoloader for the %s class.','event_espresso' ), $class )); |
|
98 | + if (empty($path)) { |
|
99 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
100 | 100 | } |
101 | 101 | // is file readable ? |
102 | - if ( $read_check && ! is_readable( $path )) { |
|
103 | - throw new EE_Error ( sprintf( __( 'The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s','event_espresso' ), $class, $path )); |
|
102 | + if ($read_check && ! is_readable($path)) { |
|
103 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
104 | 104 | } |
105 | - self::$_autoloaders[ $class ] = str_replace( array( '\/', '/' ), DS, $path ); |
|
105 | + self::$_autoloaders[$class] = str_replace(array('\/', '/'), DS, $path); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | * @return void |
130 | 130 | */ |
131 | 131 | private function _register_custom_autoloaders() { |
132 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE ); |
|
133 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_MODELS, TRUE ); |
|
134 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CLASSES ); |
|
132 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
133 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, TRUE); |
|
134 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
135 | 135 | EEH_Autoloader::register_form_sections_autoloaders(); |
136 | 136 | } |
137 | 137 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return void |
146 | 146 | */ |
147 | 147 | public static function register_form_sections_autoloaders() { |
148 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, TRUE ); |
|
148 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, TRUE); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return void |
159 | 159 | */ |
160 | 160 | public static function register_line_item_display_autoloaders() { |
161 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_LIBRARIES . 'line_item_display' , TRUE ); |
|
161 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', TRUE); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -173,31 +173,31 @@ discard block |
||
173 | 173 | * @param bool $recursive |
174 | 174 | * @return array |
175 | 175 | */ |
176 | - public static function register_autoloaders_for_each_file_in_folder( $folder, $recursive = FALSE ){ |
|
176 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = FALSE) { |
|
177 | 177 | // make sure last char is a / |
178 | - $folder .= $folder[strlen($folder)-1] != DS ? DS : ''; |
|
178 | + $folder .= $folder[strlen($folder) - 1] != DS ? DS : ''; |
|
179 | 179 | $class_to_filepath_map = array(); |
180 | - $exclude = array( 'index' ); |
|
180 | + $exclude = array('index'); |
|
181 | 181 | //get all the files in that folder that end in php |
182 | - $filepaths = glob( $folder.'*'); |
|
182 | + $filepaths = glob($folder.'*'); |
|
183 | 183 | |
184 | - if ( empty( $filepaths ) ) { |
|
184 | + if (empty($filepaths)) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
188 | - foreach( $filepaths as $filepath ) { |
|
189 | - if ( substr( $filepath, -4, 4 ) == '.php' ) { |
|
190 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename( $filepath ); |
|
191 | - if ( ! in_array( $class_name, $exclude )) { |
|
192 | - $class_to_filepath_map [ $class_name ] = str_replace( array( '\/', '/' ), DS, $filepath ); |
|
188 | + foreach ($filepaths as $filepath) { |
|
189 | + if (substr($filepath, -4, 4) == '.php') { |
|
190 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
191 | + if ( ! in_array($class_name, $exclude)) { |
|
192 | + $class_to_filepath_map [$class_name] = str_replace(array('\/', '/'), DS, $filepath); |
|
193 | 193 | } |
194 | - } else if ( $recursive ) { |
|
195 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $filepath, $recursive ); |
|
194 | + } else if ($recursive) { |
|
195 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | |
199 | 199 | //we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
200 | - self::register_autoloader($class_to_filepath_map, FALSE ); |
|
200 | + self::register_autoloader($class_to_filepath_map, FALSE); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * @ override magic methods |
34 | 34 | * @ return void |
35 | 35 | */ |
36 | - public function __set($a,$b) { return FALSE; } |
|
36 | + public function __set($a, $b) { return FALSE; } |
|
37 | 37 | public function __get($a) { return FALSE; } |
38 | 38 | public function __isset($a) { return FALSE; } |
39 | 39 | public function __unset($a) { return FALSE; } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function get_called_class() { |
37 | 37 | $backtrace = debug_backtrace(); |
38 | - if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['class'] ) && ! isset( $backtrace[2]['file'] )) { |
|
38 | + if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['class']) && ! isset($backtrace[2]['file'])) { |
|
39 | 39 | return $backtrace[2]['class']; |
40 | - } else if ( isset( $backtrace[3] ) && is_array( $backtrace[3] ) && isset( $backtrace[3]['class'] ) && ! isset( $backtrace[3]['file'] )) { |
|
40 | + } else if (isset($backtrace[3]) && is_array($backtrace[3]) && isset($backtrace[3]['class']) && ! isset($backtrace[3]['file'])) { |
|
41 | 41 | return $backtrace[3]['class']; |
42 | - } else if ( isset( $backtrace[2] ) && is_array( $backtrace[2] ) && isset( $backtrace[2]['file'] ) && isset( $backtrace[2]['line'] )) { |
|
43 | - if ( self::$file_line == $backtrace[2]['file'] . $backtrace[2]['line'] ) { |
|
42 | + } else if (isset($backtrace[2]) && is_array($backtrace[2]) && isset($backtrace[2]['file']) && isset($backtrace[2]['line'])) { |
|
43 | + if (self::$file_line == $backtrace[2]['file'].$backtrace[2]['line']) { |
|
44 | 44 | self::$i++; |
45 | 45 | } else { |
46 | 46 | self::$i = 0; |
47 | - self::$file_line = $backtrace[2]['file'] . $backtrace[2]['line']; |
|
47 | + self::$file_line = $backtrace[2]['file'].$backtrace[2]['line']; |
|
48 | 48 | } |
49 | 49 | // was class method called via call_user_func ? |
50 | - if ( $backtrace[2]['function'] == 'call_user_func' && isset( $backtrace[2]['args'] ) && is_array( $backtrace[2]['args'] )){ |
|
51 | - if ( isset( $backtrace[2]['args'][0] ) && isset( $backtrace[2]['args'][0][0] )) { |
|
50 | + if ($backtrace[2]['function'] == 'call_user_func' && isset($backtrace[2]['args']) && is_array($backtrace[2]['args'])) { |
|
51 | + if (isset($backtrace[2]['args'][0]) && isset($backtrace[2]['args'][0][0])) { |
|
52 | 52 | $called_class = $backtrace[2]['args'][0][0]; |
53 | 53 | // is it an EE function ? |
54 | - if ( strpos( $called_class, 'EE' ) === 0 ) { |
|
55 | - $prefix_chars = strpos( $called_class, '_' ) + 1; |
|
56 | - $prefix = substr( $called_class, 0, $prefix_chars ); |
|
57 | - $classname = substr( $called_class, $prefix_chars, strlen( $called_class )); |
|
58 | - $classname = $prefix . str_replace( ' ', '_', ucwords( strtolower( str_replace( '_', ' ', $classname )))); |
|
54 | + if (strpos($called_class, 'EE') === 0) { |
|
55 | + $prefix_chars = strpos($called_class, '_') + 1; |
|
56 | + $prefix = substr($called_class, 0, $prefix_chars); |
|
57 | + $classname = substr($called_class, $prefix_chars, strlen($called_class)); |
|
58 | + $classname = $prefix.str_replace(' ', '_', ucwords(strtolower(str_replace('_', ' ', $classname)))); |
|
59 | 59 | return $classname; |
60 | 60 | } |
61 | 61 | } |
62 | 62 | } else { |
63 | - $lines = file( $backtrace[2]['file'] ); |
|
64 | - preg_match_all( '/([a-zA-Z0-9\_]+)::' . $backtrace[2]['function'] . '/', $lines[$backtrace[2]['line']-1], $matches ); |
|
65 | - if ( isset( $matches[1] ) && isset( $matches[1][ self::$i ] )) { |
|
66 | - return $matches[1][ self::$i ]; |
|
63 | + $lines = file($backtrace[2]['file']); |
|
64 | + preg_match_all('/([a-zA-Z0-9\_]+)::'.$backtrace[2]['function'].'/', $lines[$backtrace[2]['line'] - 1], $matches); |
|
65 | + if (isset($matches[1]) && isset($matches[1][self::$i])) { |
|
66 | + return $matches[1][self::$i]; |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * @param string $hook |
81 | 81 | * @return array |
82 | 82 | */ |
83 | - public static function get_class_names_for_all_callbacks_on_hook( $hook = NULL ) { |
|
83 | + public static function get_class_names_for_all_callbacks_on_hook($hook = NULL) { |
|
84 | 84 | global $wp_filter; |
85 | 85 | $class_names = array(); |
86 | 86 | // are any callbacks registered for this hook ? |
87 | - if ( isset( $wp_filter[ $hook ] )) { |
|
87 | + if (isset($wp_filter[$hook])) { |
|
88 | 88 | // loop thru all of the callbacks attached to the deprecated hookpoint |
89 | - foreach( $wp_filter[ $hook ] as $priority ) { |
|
90 | - foreach( $priority as $callback ) { |
|
89 | + foreach ($wp_filter[$hook] as $priority) { |
|
90 | + foreach ($priority as $callback) { |
|
91 | 91 | // is the callback a non-static class method ? |
92 | - if ( isset( $callback['function'] ) && is_array( $callback['function'] )) { |
|
93 | - if ( isset( $callback['function'][0] ) && is_object( $callback['function'][0] )) { |
|
94 | - $class_names[] = get_class( $callback['function'][0] ); |
|
92 | + if (isset($callback['function']) && is_array($callback['function'])) { |
|
93 | + if (isset($callback['function'][0]) && is_object($callback['function'][0])) { |
|
94 | + $class_names[] = get_class($callback['function'][0]); |
|
95 | 95 | } |
96 | 96 | // test for static method |
97 | - } else if ( strpos( $callback['function'], '::' ) !== FALSE ) { |
|
98 | - $class = explode( '::', $callback['function'] ); |
|
97 | + } else if (strpos($callback['function'], '::') !== FALSE) { |
|
98 | + $class = explode('::', $callback['function']); |
|
99 | 99 | $class_names[] = $class[0]; |
100 | 100 | } else { |
101 | 101 | // just a function |
@@ -116,24 +116,24 @@ discard block |
||
116 | 116 | * @param string $property |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - public static function has_property( $class = NULL, $property = NULL ) { |
|
119 | + public static function has_property($class = NULL, $property = NULL) { |
|
120 | 120 | // if $class or $property don't exist, then get out, cuz that would be like... fatal dude |
121 | - if ( empty( $class ) || empty( $property )) { |
|
121 | + if (empty($class) || empty($property)) { |
|
122 | 122 | return FALSE; |
123 | 123 | } |
124 | 124 | // if your hosting company doesn't cut the mustard |
125 | - if ( version_compare( PHP_VERSION, '5.3.0' ) < 0 ) { |
|
125 | + if (version_compare(PHP_VERSION, '5.3.0') < 0) { |
|
126 | 126 | // just in case $class is an actual instantiated object |
127 | - if ( is_object( $class )) { |
|
128 | - return isset( $class->$property ) ? TRUE : FALSE; |
|
127 | + if (is_object($class)) { |
|
128 | + return isset($class->$property) ? TRUE : FALSE; |
|
129 | 129 | } else { |
130 | 130 | // use reflection for < PHP 5.3 to get details using just the class name |
131 | - $reflector = new ReflectionClass( $class ); |
|
132 | - return $reflector->hasProperty( $property ); |
|
131 | + $reflector = new ReflectionClass($class); |
|
132 | + return $reflector->hasProperty($property); |
|
133 | 133 | } |
134 | 134 | } else { |
135 | 135 | // or try regular property exists method which works as expected in PHP 5.3+ |
136 | - return property_exists( $class, $property ); |
|
136 | + return property_exists($class, $property); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // if PHP version < 5.3 |
146 | -if ( ! function_exists( 'get_called_class' )) { |
|
146 | +if ( ! function_exists('get_called_class')) { |
|
147 | 147 | /** |
148 | 148 | * @return bool|string |
149 | 149 | */ |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Class EEH_Debug_Tools |
4 | 6 | * |
@@ -122,8 +124,7 @@ discard block |
||
122 | 124 | return; |
123 | 125 | } |
124 | 126 | echo '<h5>For Tag: '. $tag .'</h5>'; |
125 | - } |
|
126 | - else { |
|
127 | + } else { |
|
127 | 128 | $hook=$wp_filter; |
128 | 129 | ksort( $hook ); |
129 | 130 | } |
@@ -183,7 +184,7 @@ discard block |
||
183 | 184 | if( isset( $this->_start_times[ $timer_name ] ) ){ |
184 | 185 | $start_time = $this->_start_times[ $timer_name ]; |
185 | 186 | unset( $this->_start_times[ $timer_name ] ); |
186 | - }else{ |
|
187 | + } else{ |
|
187 | 188 | $start_time = array_pop( $this->_start_times ); |
188 | 189 | } |
189 | 190 | $total_time = microtime( TRUE ) - $start_time; |
@@ -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 |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | // check if class object is instantiated, and instantiated properly |
38 | - if ( ! self::$_instance instanceof EEH_Debug_Tools ) { |
|
38 | + if ( ! self::$_instance instanceof EEH_Debug_Tools) { |
|
39 | 39 | self::$_instance = new self(); |
40 | 40 | } |
41 | 41 | return self::$_instance; |
@@ -51,19 +51,19 @@ discard block |
||
51 | 51 | */ |
52 | 52 | private function __construct() { |
53 | 53 | // load Kint PHP debugging library |
54 | - if ( ! class_exists( 'Kint' ) && file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){ |
|
54 | + if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) { |
|
55 | 55 | // despite EE4 having a check for an existing copy of the Kint debugging class, |
56 | 56 | // if another plugin was loaded AFTER EE4 and they did NOT perform a similar check, |
57 | 57 | // then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error |
58 | 58 | // so we've moved it to our test folder so that it is not included with production releases |
59 | 59 | // plz use https://wordpress.org/plugins/kint-debugger/ if testing production versions of EE |
60 | - require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' ); |
|
60 | + require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php'); |
|
61 | 61 | } |
62 | - if ( ! defined('DOING_AJAX') || ! isset( $_REQUEST['noheader'] ) || $_REQUEST['noheader'] != 'true' || ! isset( $_REQUEST['TB_iframe'] )) { |
|
62 | + if ( ! defined('DOING_AJAX') || ! isset($_REQUEST['noheader']) || $_REQUEST['noheader'] != 'true' || ! isset($_REQUEST['TB_iframe'])) { |
|
63 | 63 | //add_action( 'shutdown', array($this,'espresso_session_footer_dump') ); |
64 | 64 | } |
65 | - add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' )); |
|
66 | - add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' )); |
|
65 | + add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors')); |
|
66 | + add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name')); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | * @return void |
75 | 75 | */ |
76 | 76 | public static function show_db_name() { |
77 | - if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) { |
|
78 | - echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>'; |
|
77 | + if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) { |
|
78 | + echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>'; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @return void |
88 | 88 | */ |
89 | 89 | public function espresso_session_footer_dump() { |
90 | - if ( class_exists('Kint') && function_exists( 'wp_get_current_user' ) && current_user_can('update_core') && ( defined('WP_DEBUG') && WP_DEBUG ) && ! defined('DOING_AJAX') && class_exists( 'EE_Registry' )) { |
|
91 | - Kint::dump( EE_Registry::instance()->SSN->id() ); |
|
92 | - Kint::dump( EE_Registry::instance()->SSN ); |
|
90 | + if (class_exists('Kint') && function_exists('wp_get_current_user') && current_user_can('update_core') && (defined('WP_DEBUG') && WP_DEBUG) && ! defined('DOING_AJAX') && class_exists('EE_Registry')) { |
|
91 | + Kint::dump(EE_Registry::instance()->SSN->id()); |
|
92 | + Kint::dump(EE_Registry::instance()->SSN); |
|
93 | 93 | // Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() ); |
94 | 94 | $this->espresso_list_hooked_functions(); |
95 | 95 | $this->show_times(); |
@@ -106,27 +106,27 @@ discard block |
||
106 | 106 | * @param bool $tag |
107 | 107 | * @return void |
108 | 108 | */ |
109 | - public function espresso_list_hooked_functions( $tag=FALSE ){ |
|
109 | + public function espresso_list_hooked_functions($tag = FALSE) { |
|
110 | 110 | global $wp_filter; |
111 | 111 | echo '<br/><br/><br/><h3>Hooked Functions</h3>'; |
112 | - if ( $tag ) { |
|
113 | - $hook[$tag]=$wp_filter[$tag]; |
|
114 | - if ( ! is_array( $hook[$tag] )) { |
|
115 | - trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING ); |
|
112 | + if ($tag) { |
|
113 | + $hook[$tag] = $wp_filter[$tag]; |
|
114 | + if ( ! is_array($hook[$tag])) { |
|
115 | + trigger_error("Nothing found for '$tag' hook", E_USER_WARNING); |
|
116 | 116 | return; |
117 | 117 | } |
118 | - echo '<h5>For Tag: '. $tag .'</h5>'; |
|
118 | + echo '<h5>For Tag: '.$tag.'</h5>'; |
|
119 | 119 | } |
120 | 120 | else { |
121 | - $hook=$wp_filter; |
|
122 | - ksort( $hook ); |
|
121 | + $hook = $wp_filter; |
|
122 | + ksort($hook); |
|
123 | 123 | } |
124 | - foreach( $hook as $tag => $priorities ) { |
|
124 | + foreach ($hook as $tag => $priorities) { |
|
125 | 125 | echo "<br />>>>>>\t<strong>$tag</strong><br />"; |
126 | - ksort( $priorities ); |
|
127 | - foreach( $priorities as $priority => $function ){ |
|
126 | + ksort($priorities); |
|
127 | + foreach ($priorities as $priority => $function) { |
|
128 | 128 | echo $priority; |
129 | - foreach( $function as $name => $properties ) { |
|
129 | + foreach ($function as $name => $properties) { |
|
130 | 130 | echo "\t$name<br />"; |
131 | 131 | } |
132 | 132 | } |
@@ -142,15 +142,15 @@ discard block |
||
142 | 142 | * @param string $hook_name |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - public static function registered_filter_callbacks( $hook_name = '' ) { |
|
145 | + public static function registered_filter_callbacks($hook_name = '') { |
|
146 | 146 | $filters = array(); |
147 | 147 | global $wp_filter; |
148 | - if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
149 | - $filters[ $hook_name ] = array(); |
|
150 | - foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) { |
|
151 | - $filters[ $hook_name ][ $priority ] = array(); |
|
152 | - foreach ( $callbacks as $callback ) { |
|
153 | - $filters[ $hook_name ][ $priority ][] = $callback['function']; |
|
148 | + if (isset($wp_filter[$hook_name])) { |
|
149 | + $filters[$hook_name] = array(); |
|
150 | + foreach ($wp_filter[$hook_name] as $priority => $callbacks) { |
|
151 | + $filters[$hook_name][$priority] = array(); |
|
152 | + foreach ($callbacks as $callback) { |
|
153 | + $filters[$hook_name][$priority][] = $callback['function']; |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | } |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * start_timer |
164 | 164 | * @param null $timer_name |
165 | 165 | */ |
166 | - public function start_timer( $timer_name = NULL ){ |
|
167 | - $this->_start_times[$timer_name] = microtime( TRUE ); |
|
166 | + public function start_timer($timer_name = NULL) { |
|
167 | + $this->_start_times[$timer_name] = microtime(TRUE); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | * stop_timer |
174 | 174 | * @param string $timer_name |
175 | 175 | */ |
176 | - public function stop_timer($timer_name = 'default'){ |
|
177 | - if( isset( $this->_start_times[ $timer_name ] ) ){ |
|
178 | - $start_time = $this->_start_times[ $timer_name ]; |
|
179 | - unset( $this->_start_times[ $timer_name ] ); |
|
180 | - }else{ |
|
181 | - $start_time = array_pop( $this->_start_times ); |
|
176 | + public function stop_timer($timer_name = 'default') { |
|
177 | + if (isset($this->_start_times[$timer_name])) { |
|
178 | + $start_time = $this->_start_times[$timer_name]; |
|
179 | + unset($this->_start_times[$timer_name]); |
|
180 | + } else { |
|
181 | + $start_time = array_pop($this->_start_times); |
|
182 | 182 | } |
183 | - $total_time = microtime( TRUE ) - $start_time; |
|
184 | - switch ( $total_time ) { |
|
183 | + $total_time = microtime(TRUE) - $start_time; |
|
184 | + switch ($total_time) { |
|
185 | 185 | case $total_time < 0.00001 : |
186 | 186 | $color = '#8A549A'; |
187 | 187 | $bold = 'normal'; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $bold = 'bold'; |
208 | 208 | break; |
209 | 209 | } |
210 | - $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0em 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">' . number_format( $total_time, 8 ) . '</div> ' . $timer_name; |
|
210 | + $this->_times[] = '<hr /><div style="display: inline-block; min-width: 10px; margin:0em 1em; color:'.$color.'; font-weight:'.$bold.'; font-size:1.2em;">'.number_format($total_time, 8).'</div> '.$timer_name; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | |
@@ -217,12 +217,12 @@ discard block |
||
217 | 217 | * @param bool $output_now |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - public function show_times($output_now=true){ |
|
221 | - if($output_now){ |
|
222 | - echo implode("<br>",$this->_times); |
|
220 | + public function show_times($output_now = true) { |
|
221 | + if ($output_now) { |
|
222 | + echo implode("<br>", $this->_times); |
|
223 | 223 | return ''; |
224 | 224 | } |
225 | - return implode("<br>",$this->_times); |
|
225 | + return implode("<br>", $this->_times); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,27 +233,27 @@ discard block |
||
233 | 233 | * @return void |
234 | 234 | */ |
235 | 235 | public static function ee_plugin_activation_errors() { |
236 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
236 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
237 | 237 | $activation_errors = ob_get_contents(); |
238 | - if ( class_exists( 'EE_Registry' )) { |
|
239 | - EE_Registry::instance()->load_helper( 'File' ); |
|
238 | + if (class_exists('EE_Registry')) { |
|
239 | + EE_Registry::instance()->load_helper('File'); |
|
240 | 240 | } else { |
241 | - include_once( EE_HELPERS . 'EEH_File.helper.php' ); |
|
241 | + include_once(EE_HELPERS.'EEH_File.helper.php'); |
|
242 | 242 | } |
243 | - if ( class_exists( 'EEH_File' )) { |
|
243 | + if (class_exists('EEH_File')) { |
|
244 | 244 | try { |
245 | - EEH_File::ensure_folder_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS ); |
|
246 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' ); |
|
247 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
248 | - } catch( EE_Error $e ){ |
|
249 | - EE_Error::add_error( sprintf( __( 'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
245 | + EEH_File::ensure_folder_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS); |
|
246 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html'); |
|
247 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
248 | + } catch (EE_Error $e) { |
|
249 | + EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
250 | 250 | } |
251 | 251 | } else { |
252 | 252 | // old school attempt |
253 | - file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors ); |
|
253 | + file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors); |
|
254 | 254 | } |
255 | - $activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors; |
|
256 | - update_option( 'ee_plugin_activation_errors', $activation_errors ); |
|
255 | + $activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors; |
|
256 | + update_option('ee_plugin_activation_errors', $activation_errors); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param string $version The version of Event Espresso where the error was added |
269 | 269 | * @uses trigger_error() |
270 | 270 | */ |
271 | - public function doing_it_wrong( $function, $message, $version ) { |
|
272 | - do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
273 | - $version = is_null( $version ) ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version ); |
|
274 | - trigger_error( sprintf( __('%1$s was called <strong>incorrectly</strong>. %2$s %3$s','event_espresso' ), $function, $message, $version ), E_USER_DEPRECATED ); |
|
271 | + public function doing_it_wrong($function, $message, $version) { |
|
272 | + do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version); |
|
273 | + $version = is_null($version) ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version); |
|
274 | + trigger_error(sprintf(__('%1$s was called <strong>incorrectly</strong>. %2$s %3$s', 'event_espresso'), $function, $message, $version), E_USER_DEPRECATED); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | |
@@ -292,22 +292,22 @@ discard block |
||
292 | 292 | * @param string $debug_index |
293 | 293 | * @param string $debug_key |
294 | 294 | */ |
295 | - public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) { |
|
296 | - if ( WP_DEBUG ) { |
|
297 | - $debug_key = $debug_key . '_' . EE_Session::instance()->id(); |
|
298 | - $debug_data = get_option( $debug_key, array() ); |
|
295 | + public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') { |
|
296 | + if (WP_DEBUG) { |
|
297 | + $debug_key = $debug_key.'_'.EE_Session::instance()->id(); |
|
298 | + $debug_data = get_option($debug_key, array()); |
|
299 | 299 | $default_data = array( |
300 | - $class => $func . '() : ' . $line, |
|
300 | + $class => $func.'() : '.$line, |
|
301 | 301 | 'REQ' => $display_request ? $_REQUEST : '', |
302 | 302 | ); |
303 | 303 | // don't serialize objects |
304 | - $info = self::strip_objects( $info ); |
|
305 | - $index = ! empty( $debug_index ) ? $debug_index : 0; |
|
306 | - if ( ! isset( $debug_data[$index] ) ) { |
|
304 | + $info = self::strip_objects($info); |
|
305 | + $index = ! empty($debug_index) ? $debug_index : 0; |
|
306 | + if ( ! isset($debug_data[$index])) { |
|
307 | 307 | $debug_data[$index] = array(); |
308 | 308 | } |
309 | - $debug_data[$index][microtime()] = array_merge( $default_data, $info ); |
|
310 | - update_option( $debug_key, $debug_data ); |
|
309 | + $debug_data[$index][microtime()] = array_merge($default_data, $info); |
|
310 | + update_option($debug_key, $debug_data); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -319,26 +319,26 @@ discard block |
||
319 | 319 | * @param array $info |
320 | 320 | * @return array |
321 | 321 | */ |
322 | - public static function strip_objects( $info = array() ) { |
|
323 | - foreach ( $info as $key => $value ) { |
|
324 | - if ( is_array( $value ) ) { |
|
325 | - $info[ $key ] = self::strip_objects( $value ); |
|
326 | - } else if ( is_object( $value ) ) { |
|
327 | - $object_class = get_class( $value ); |
|
328 | - $info[ $object_class ] = array(); |
|
329 | - $info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value ); |
|
330 | - if ( method_exists( $value, 'ID' ) ) { |
|
331 | - $info[ $object_class ][ 'ID' ] = $value->ID(); |
|
322 | + public static function strip_objects($info = array()) { |
|
323 | + foreach ($info as $key => $value) { |
|
324 | + if (is_array($value)) { |
|
325 | + $info[$key] = self::strip_objects($value); |
|
326 | + } else if (is_object($value)) { |
|
327 | + $object_class = get_class($value); |
|
328 | + $info[$object_class] = array(); |
|
329 | + $info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value); |
|
330 | + if (method_exists($value, 'ID')) { |
|
331 | + $info[$object_class]['ID'] = $value->ID(); |
|
332 | 332 | } |
333 | - if ( method_exists( $value, 'status' ) ) { |
|
334 | - $info[ $object_class ][ 'status' ] = $value->status(); |
|
335 | - } else if ( method_exists( $value, 'status_ID' ) ) { |
|
336 | - $info[ $object_class ][ 'status' ] = $value->status_ID(); |
|
333 | + if (method_exists($value, 'status')) { |
|
334 | + $info[$object_class]['status'] = $value->status(); |
|
335 | + } else if (method_exists($value, 'status_ID')) { |
|
336 | + $info[$object_class]['status'] = $value->status_ID(); |
|
337 | 337 | } |
338 | - unset( $info[ $key ] ); |
|
338 | + unset($info[$key]); |
|
339 | 339 | } |
340 | 340 | } |
341 | - return (array)$info; |
|
341 | + return (array) $info; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | |
@@ -355,30 +355,30 @@ discard block |
||
355 | 355 | * @param string $height |
356 | 356 | * @param bool $die |
357 | 357 | */ |
358 | - public static function printr( $var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false ) { |
|
358 | + public static function printr($var, $var_name = false, $file = __FILE__, $line = __LINE__, $height = 'auto', $die = false) { |
|
359 | 359 | $print_r = false; |
360 | - if ( is_object( $var ) ) { |
|
360 | + if (is_object($var)) { |
|
361 | 361 | $var_name = ! $var_name ? 'object' : $var_name; |
362 | 362 | $print_r = true; |
363 | - } else if ( is_array( $var ) ) { |
|
363 | + } else if (is_array($var)) { |
|
364 | 364 | $var_name = ! $var_name ? 'array' : $var_name; |
365 | 365 | $print_r = true; |
366 | - } else if ( is_numeric( $var ) ) { |
|
366 | + } else if (is_numeric($var)) { |
|
367 | 367 | $var_name = ! $var_name ? 'numeric' : $var_name; |
368 | - } else if ( is_string( $var ) ) { |
|
368 | + } else if (is_string($var)) { |
|
369 | 369 | $var_name = ! $var_name ? 'string' : $var_name; |
370 | - } else if ( is_null( $var ) ) { |
|
370 | + } else if (is_null($var)) { |
|
371 | 371 | $var_name = ! $var_name ? 'null' : $var_name; |
372 | 372 | } |
373 | - $var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) ); |
|
373 | + $var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name)); |
|
374 | 374 | ob_start(); |
375 | - echo '<pre style="display:block; width:100%; height:' . $height . '; border:2px solid light-blue;">'; |
|
376 | - echo '<h5 style="color:#2EA2CC;"><b>' . $var_name . '</b></h5><span style="color:#E76700">'; |
|
377 | - $print_r ? print_r( $var ) : var_dump( $var ); |
|
378 | - echo '</span><br /><span style="font-size:10px;font-weight:normal;">' . $file . '<br />line no: ' . $line . '</span></pre>'; |
|
375 | + echo '<pre style="display:block; width:100%; height:'.$height.'; border:2px solid light-blue;">'; |
|
376 | + echo '<h5 style="color:#2EA2CC;"><b>'.$var_name.'</b></h5><span style="color:#E76700">'; |
|
377 | + $print_r ? print_r($var) : var_dump($var); |
|
378 | + echo '</span><br /><span style="font-size:10px;font-weight:normal;">'.$file.'<br />line no: '.$line.'</span></pre>'; |
|
379 | 379 | $result = ob_get_clean(); |
380 | - if ( $die ) { |
|
381 | - die( $result ); |
|
380 | + if ($die) { |
|
381 | + die($result); |
|
382 | 382 | } else { |
383 | 383 | echo $result; |
384 | 384 | } |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * borrowed from Kint Debugger |
396 | 396 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
397 | 397 | */ |
398 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) { |
|
399 | - function dump_wp_query(){ |
|
398 | +if (class_exists('Kint') && ! function_exists('dump_wp_query')) { |
|
399 | + function dump_wp_query() { |
|
400 | 400 | global $wp_query; |
401 | 401 | d($wp_query); |
402 | 402 | } |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | * borrowed from Kint Debugger |
407 | 407 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
408 | 408 | */ |
409 | -if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) { |
|
410 | - function dump_wp(){ |
|
409 | +if (class_exists('Kint') && ! function_exists('dump_wp')) { |
|
410 | + function dump_wp() { |
|
411 | 411 | global $wp; |
412 | 412 | d($wp); |
413 | 413 | } |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * borrowed from Kint Debugger |
418 | 418 | * Plugin URI: http://upthemes.com/plugins/kint-debugger/ |
419 | 419 | */ |
420 | -if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) { |
|
421 | - function dump_post(){ |
|
420 | +if (class_exists('Kint') && ! function_exists('dump_post')) { |
|
421 | + function dump_post() { |
|
422 | 422 | global $post; |
423 | 423 | d($post); |
424 | 424 | } |
@@ -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 | * Event Espresso |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function add_query_filters() { |
87 | 87 | //add query filters |
88 | - add_action( 'pre_get_posts', array( 'EEH_Event_Query', 'filter_query_parts' ), 10, 1 ); |
|
88 | + add_action('pre_get_posts', array('EEH_Event_Query', 'filter_query_parts'), 10, 1); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param \WP_Query $WP_Query |
98 | 98 | * @return bool |
99 | 99 | */ |
100 | - public static function apply_query_filters( WP_Query $WP_Query ) { |
|
101 | - return ( isset( $WP_Query->query, $WP_Query->query['post_type'] ) && $WP_Query->query['post_type'] == 'espresso_events' ) || apply_filters( 'FHEE__EEH_Event_Query__apply_query_filters', false ) ? true : false; |
|
100 | + public static function apply_query_filters(WP_Query $WP_Query) { |
|
101 | + return (isset($WP_Query->query, $WP_Query->query['post_type']) && $WP_Query->query['post_type'] == 'espresso_events') || apply_filters('FHEE__EEH_Event_Query__apply_query_filters', false) ? true : false; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -108,15 +108,15 @@ discard block |
||
108 | 108 | * @access public |
109 | 109 | * @param \WP_Query $WP_Query |
110 | 110 | */ |
111 | - public static function filter_query_parts( WP_Query $WP_Query ) { |
|
111 | + public static function filter_query_parts(WP_Query $WP_Query) { |
|
112 | 112 | //ONLY add our filters if this isn't the main wp_query, because if this is the main wp_query we already have our cpt strategies take care of adding things in. |
113 | - if ( $WP_Query instanceof WP_Query && ! $WP_Query->is_main_query() ) { |
|
113 | + if ($WP_Query instanceof WP_Query && ! $WP_Query->is_main_query()) { |
|
114 | 114 | // build event list query |
115 | - add_filter( 'posts_fields', array( 'EEH_Event_Query', 'posts_fields' ), 10, 2 ); |
|
116 | - add_filter( 'posts_join', array( 'EEH_Event_Query', 'posts_join' ), 10, 2 ); |
|
117 | - add_filter( 'posts_where', array( 'EEH_Event_Query', 'posts_where' ), 10, 2 ); |
|
118 | - add_filter( 'posts_orderby', array( 'EEH_Event_Query', 'posts_orderby' ), 10, 2 ); |
|
119 | - add_filter( 'posts_clauses_request', array( 'EEH_Event_Query', 'posts_clauses' ), 10, 2 ); |
|
115 | + add_filter('posts_fields', array('EEH_Event_Query', 'posts_fields'), 10, 2); |
|
116 | + add_filter('posts_join', array('EEH_Event_Query', 'posts_join'), 10, 2); |
|
117 | + add_filter('posts_where', array('EEH_Event_Query', 'posts_where'), 10, 2); |
|
118 | + add_filter('posts_orderby', array('EEH_Event_Query', 'posts_orderby'), 10, 2); |
|
119 | + add_filter('posts_clauses_request', array('EEH_Event_Query', 'posts_clauses'), 10, 2); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | * @param string $orderby |
132 | 132 | * @param string $sort |
133 | 133 | */ |
134 | - public static function set_query_params( $month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC' ) { |
|
134 | + public static function set_query_params($month = '', $category = '', $show_expired = FALSE, $orderby = 'start_date', $sort = 'ASC') { |
|
135 | 135 | self::$_query_params = array(); |
136 | - EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month( $month ); |
|
137 | - EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug( $category ); |
|
138 | - EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired( $show_expired ); |
|
139 | - EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby( $orderby ); |
|
140 | - EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort( $sort ); |
|
136 | + EEH_Event_Query::$_event_query_month = EEH_Event_Query::_display_month($month); |
|
137 | + EEH_Event_Query::$_event_query_category = EEH_Event_Query::_event_category_slug($category); |
|
138 | + EEH_Event_Query::$_event_query_show_expired = EEH_Event_Query::_show_expired($show_expired); |
|
139 | + EEH_Event_Query::$_event_query_orderby = EEH_Event_Query::_orderby($orderby); |
|
140 | + EEH_Event_Query::$_event_query_sort = EEH_Event_Query::_sort($sort); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param string $month |
150 | 150 | * @return string |
151 | 151 | */ |
152 | - private static function _display_month( $month = '' ) { |
|
153 | - return EE_Registry::instance()->REQ->is_set( 'event_query_month' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_month' ) ) : $month; |
|
152 | + private static function _display_month($month = '') { |
|
153 | + return EE_Registry::instance()->REQ->is_set('event_query_month') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_month')) : $month; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * @param string $category |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - private static function _event_category_slug( $category = '' ) { |
|
166 | - return EE_Registry::instance()->REQ->is_set( 'event_query_category' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_category' ) ) : $category; |
|
165 | + private static function _event_category_slug($category = '') { |
|
166 | + return EE_Registry::instance()->REQ->is_set('event_query_category') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_category')) : $category; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | * @param bool $show_expired |
176 | 176 | * @return boolean |
177 | 177 | */ |
178 | - private static function _show_expired( $show_expired = FALSE ) { |
|
178 | + private static function _show_expired($show_expired = FALSE) { |
|
179 | 179 | // override default expired option if set via filter |
180 | - $_event_query_show_expired =EE_Registry::instance()->REQ->is_set( 'event_query_show_expired' ) ? EE_Registry::instance()->REQ->get( 'event_query_show_expired' ) : $show_expired; |
|
181 | - return filter_var( $_event_query_show_expired, FILTER_VALIDATE_BOOLEAN ); |
|
180 | + $_event_query_show_expired = EE_Registry::instance()->REQ->is_set('event_query_show_expired') ? EE_Registry::instance()->REQ->get('event_query_show_expired') : $show_expired; |
|
181 | + return filter_var($_event_query_show_expired, FILTER_VALIDATE_BOOLEAN); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * @param string $orderby |
191 | 191 | * @return array |
192 | 192 | */ |
193 | - private static function _orderby( $orderby = 'start_date' ) { |
|
194 | - $event_query_orderby = EE_Registry::instance()->REQ->is_set( 'event_query_orderby' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_orderby' ) ) : $orderby; |
|
195 | - $event_query_orderby = is_array( $event_query_orderby ) ? $event_query_orderby : explode( ',', $event_query_orderby ); |
|
196 | - $event_query_orderby = array_map( 'trim', $event_query_orderby ); |
|
193 | + private static function _orderby($orderby = 'start_date') { |
|
194 | + $event_query_orderby = EE_Registry::instance()->REQ->is_set('event_query_orderby') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_orderby')) : $orderby; |
|
195 | + $event_query_orderby = is_array($event_query_orderby) ? $event_query_orderby : explode(',', $event_query_orderby); |
|
196 | + $event_query_orderby = array_map('trim', $event_query_orderby); |
|
197 | 197 | return $event_query_orderby; |
198 | 198 | } |
199 | 199 | |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | * @param string $sort |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - private static function _sort( $sort = 'ASC' ) { |
|
210 | - $sort = EE_Registry::instance()->REQ->is_set( 'event_query_sort' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'event_query_sort' ) ) : $sort; |
|
211 | - return in_array( $sort, array( 'ASC', 'asc', 'DESC', 'desc' )) ? strtoupper( $sort ) : 'ASC'; |
|
209 | + private static function _sort($sort = 'ASC') { |
|
210 | + $sort = EE_Registry::instance()->REQ->is_set('event_query_sort') ? sanitize_text_field(EE_Registry::instance()->REQ->get('event_query_sort')) : $sort; |
|
211 | + return in_array($sort, array('ASC', 'asc', 'DESC', 'desc')) ? strtoupper($sort) : 'ASC'; |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array array of clauses |
223 | 223 | */ |
224 | - public static function posts_clauses( $clauses, WP_Query $wp_query ) { |
|
225 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
224 | + public static function posts_clauses($clauses, WP_Query $wp_query) { |
|
225 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
226 | 226 | $clauses['distinct'] = "DISTINCT"; |
227 | 227 | } |
228 | 228 | return $clauses; |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | * @param WP_Query $wp_query |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - public static function posts_fields( $SQL, WP_Query $wp_query ) { |
|
242 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
241 | + public static function posts_fields($SQL, WP_Query $wp_query) { |
|
242 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
243 | 243 | // adds something like ", wp_esp_datetime.* " to WP Query SELECT statement |
244 | - $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby( EEH_Event_Query::$_event_query_orderby ); |
|
244 | + $SQL .= EEH_Event_Query::posts_fields_sql_for_orderby(EEH_Event_Query::$_event_query_orderby); |
|
245 | 245 | } |
246 | 246 | return $SQL; |
247 | 247 | } |
@@ -256,29 +256,29 @@ discard block |
||
256 | 256 | * @internal param bool|string $mixed $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
257 | 257 | * @return string |
258 | 258 | */ |
259 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
260 | - $SQL= ''; |
|
261 | - foreach( (array)$orderby_params as $orderby ) { |
|
262 | - switch ( $orderby ) { |
|
259 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
260 | + $SQL = ''; |
|
261 | + foreach ((array) $orderby_params as $orderby) { |
|
262 | + switch ($orderby) { |
|
263 | 263 | |
264 | 264 | case 'ticket_start' : |
265 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_start_date' ; |
|
265 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_start_date'; |
|
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'ticket_end' : |
269 | - $SQL .= ', ' . EEM_Ticket::instance()->table() . '.TKT_end_date' ; |
|
269 | + $SQL .= ', '.EEM_Ticket::instance()->table().'.TKT_end_date'; |
|
270 | 270 | break; |
271 | 271 | |
272 | 272 | case 'venue_title' : |
273 | - $SQL .= ', Venue.post_title AS venue_title' ; |
|
273 | + $SQL .= ', Venue.post_title AS venue_title'; |
|
274 | 274 | break; |
275 | 275 | |
276 | 276 | case 'city' : |
277 | - $SQL .= ', ' . EEM_Venue::instance()->second_table() . '.VNU_city' ; |
|
277 | + $SQL .= ', '.EEM_Venue::instance()->second_table().'.VNU_city'; |
|
278 | 278 | break; |
279 | 279 | |
280 | 280 | case 'state' : |
281 | - $SQL .= ', ' . EEM_State::instance()->table() . '.STA_name' ; |
|
281 | + $SQL .= ', '.EEM_State::instance()->table().'.STA_name'; |
|
282 | 282 | break; |
283 | 283 | |
284 | 284 | } |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | * @param WP_Query $wp_query |
297 | 297 | * @return string |
298 | 298 | */ |
299 | - public static function posts_join( $SQL = '', WP_Query $wp_query ) { |
|
300 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
299 | + public static function posts_join($SQL = '', WP_Query $wp_query) { |
|
300 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
301 | 301 | // Category |
302 | - $SQL = EEH_Event_Query::posts_join_sql_for_show_expired( $SQL, EEH_Event_Query::$_event_query_show_expired ); |
|
303 | - $SQL = EEH_Event_Query::posts_join_sql_for_terms( $SQL, EEH_Event_Query::$_event_query_category ); |
|
304 | - $SQL = EEH_Event_Query::posts_join_for_orderby( $SQL, EEH_Event_Query::$_event_query_orderby ); |
|
302 | + $SQL = EEH_Event_Query::posts_join_sql_for_show_expired($SQL, EEH_Event_Query::$_event_query_show_expired); |
|
303 | + $SQL = EEH_Event_Query::posts_join_sql_for_terms($SQL, EEH_Event_Query::$_event_query_category); |
|
304 | + $SQL = EEH_Event_Query::posts_join_for_orderby($SQL, EEH_Event_Query::$_event_query_orderby); |
|
305 | 305 | } |
306 | 306 | return $SQL; |
307 | 307 | } |
@@ -316,11 +316,11 @@ discard block |
||
316 | 316 | * @param boolean $show_expired if TRUE, then displayed past events |
317 | 317 | * @return string |
318 | 318 | */ |
319 | - public static function posts_join_sql_for_show_expired( $SQL = '', $show_expired = FALSE ) { |
|
320 | - if ( ! $show_expired ) { |
|
321 | - $join = EEM_Event::instance()->table() . '.ID = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
322 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
323 | - $SQL .= ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' ) '; |
|
319 | + public static function posts_join_sql_for_show_expired($SQL = '', $show_expired = FALSE) { |
|
320 | + if ( ! $show_expired) { |
|
321 | + $join = EEM_Event::instance()->table().'.ID = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
322 | + if (strpos($SQL, $join) === FALSE) { |
|
323 | + $SQL .= ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' ) '; |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | return $SQL; |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | * @param string $join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public static function posts_join_sql_for_terms( $SQL = '', $join_terms = '' ) { |
|
340 | - if ( ! empty( $join_terms ) ) { |
|
339 | + public static function posts_join_sql_for_terms($SQL = '', $join_terms = '') { |
|
340 | + if ( ! empty($join_terms)) { |
|
341 | 341 | global $wpdb; |
342 | 342 | $SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)"; |
343 | 343 | $SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; |
@@ -357,25 +357,25 @@ discard block |
||
357 | 357 | * @param array $orderby_params |
358 | 358 | * @return string |
359 | 359 | */ |
360 | - public static function posts_join_for_orderby( $SQL = '', $orderby_params = array() ) { |
|
361 | - foreach ( (array)$orderby_params as $orderby ) { |
|
362 | - switch ( $orderby ) { |
|
360 | + public static function posts_join_for_orderby($SQL = '', $orderby_params = array()) { |
|
361 | + foreach ((array) $orderby_params as $orderby) { |
|
362 | + switch ($orderby) { |
|
363 | 363 | case 'ticket_start' : |
364 | 364 | case 'ticket_end' : |
365 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Datetime::instance()->primary_key_name() ); |
|
366 | - $SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' = ' . EEM_Ticket::instance()->table() . '.' . EEM_Ticket::instance()->primary_key_name() . ' )'; |
|
365 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Datetime_Ticket::instance()->table().'.'.EEM_Datetime::instance()->primary_key_name()); |
|
366 | + $SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' = '.EEM_Ticket::instance()->table().'.'.EEM_Ticket::instance()->primary_key_name().' )'; |
|
367 | 367 | break; |
368 | 368 | case 'venue_title' : |
369 | 369 | case 'city' : |
370 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
370 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
371 | 371 | break; |
372 | 372 | case 'state' : |
373 | - $SQL .= EEH_Event_Query::_posts_join_for_event_venue( $SQL ); |
|
374 | - $SQL .= EEH_Event_Query::_posts_join_for_venue_state( $SQL ); |
|
373 | + $SQL .= EEH_Event_Query::_posts_join_for_event_venue($SQL); |
|
374 | + $SQL .= EEH_Event_Query::_posts_join_for_venue_state($SQL); |
|
375 | 375 | break; |
376 | 376 | case 'start_date' : |
377 | 377 | default : |
378 | - $SQL .= EEH_Event_Query::_posts_join_for_datetime( $SQL, EEM_Event::instance()->table() . '.ID' ); |
|
378 | + $SQL .= EEH_Event_Query::_posts_join_for_datetime($SQL, EEM_Event::instance()->table().'.ID'); |
|
379 | 379 | break; |
380 | 380 | |
381 | 381 | } |
@@ -393,11 +393,11 @@ discard block |
||
393 | 393 | * @param string $join |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - protected static function _posts_join_for_datetime( $SQL = '', $join = '' ) { |
|
397 | - if ( ! empty( $join )) { |
|
398 | - $join .= ' = ' . EEM_Datetime::instance()->table() . '.' . EEM_Event::instance()->primary_key_name(); |
|
399 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
400 | - return ' INNER JOIN ' . EEM_Datetime::instance()->table() . ' ON ( ' . $join . ' )'; |
|
396 | + protected static function _posts_join_for_datetime($SQL = '', $join = '') { |
|
397 | + if ( ! empty($join)) { |
|
398 | + $join .= ' = '.EEM_Datetime::instance()->table().'.'.EEM_Event::instance()->primary_key_name(); |
|
399 | + if (strpos($SQL, $join) === FALSE) { |
|
400 | + return ' INNER JOIN '.EEM_Datetime::instance()->table().' ON ( '.$join.' )'; |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | return ''; |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @param string $SQL |
413 | 413 | * @return string |
414 | 414 | */ |
415 | - protected static function _posts_join_for_event_venue( $SQL = '' ) { |
|
415 | + protected static function _posts_join_for_event_venue($SQL = '') { |
|
416 | 416 | // Event Venue table name |
417 | 417 | $event_venue_table = EEM_Event_Venue::instance()->table(); |
418 | 418 | // generate conditions for: Event <=> Event Venue JOIN clause |
419 | - $event_to_event_venue_join = EEM_Event::instance()->table() . '.ID = ' . $event_venue_table . '.' . EEM_Event::instance()->primary_key_name(); |
|
419 | + $event_to_event_venue_join = EEM_Event::instance()->table().'.ID = '.$event_venue_table.'.'.EEM_Event::instance()->primary_key_name(); |
|
420 | 420 | // don't add joins if they have already been added |
421 | - if ( strpos( $SQL, $event_to_event_venue_join ) === FALSE ) { |
|
421 | + if (strpos($SQL, $event_to_event_venue_join) === FALSE) { |
|
422 | 422 | // Venue table name |
423 | 423 | $venue_table = EEM_Venue::instance()->table(); |
424 | 424 | // Venue table pk |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | $venue_SQL .= " LEFT JOIN $venue_table as Venue ON ( $event_venue_table.$venue_table_pk = Venue.ID )"; |
432 | 432 | // generate JOIN clause for: Venue <=> Venue Meta |
433 | 433 | $venue_SQL .= " LEFT JOIN $venue_meta_table ON ( Venue.ID = $venue_meta_table.$venue_table_pk )"; |
434 | - unset( $event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table ); |
|
434 | + unset($event_venue_table, $event_to_event_venue_join, $venue_table, $venue_table_pk, $venue_meta_table); |
|
435 | 435 | return $venue_SQL; |
436 | 436 | } |
437 | - unset( $event_venue_table, $event_to_event_venue_join ); |
|
437 | + unset($event_venue_table, $event_to_event_venue_join); |
|
438 | 438 | return ''; |
439 | 439 | } |
440 | 440 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @param string $SQL |
448 | 448 | * @return string |
449 | 449 | */ |
450 | - protected static function _posts_join_for_venue_state( $SQL = '' ) { |
|
450 | + protected static function _posts_join_for_venue_state($SQL = '') { |
|
451 | 451 | // Venue Meta table name |
452 | 452 | $venue_meta_table = EEM_Venue::instance()->second_table(); |
453 | 453 | // State table name |
@@ -455,16 +455,16 @@ discard block |
||
455 | 455 | // State table pk |
456 | 456 | $state_table_pk = EEM_State::instance()->primary_key_name(); |
457 | 457 | // verify vars |
458 | - if ( $venue_meta_table && $state_table && $state_table_pk ) { |
|
458 | + if ($venue_meta_table && $state_table && $state_table_pk) { |
|
459 | 459 | // like: wp_esp_venue_meta.STA_ID = wp_esp_state.STA_ID |
460 | 460 | $join = "$venue_meta_table.$state_table_pk = $state_table.$state_table_pk"; |
461 | 461 | // don't add join if it has already been added |
462 | - if ( strpos( $SQL, $join ) === FALSE ) { |
|
463 | - unset( $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
462 | + if (strpos($SQL, $join) === FALSE) { |
|
463 | + unset($state_table_pk, $venue_meta_table, $venue_table_pk); |
|
464 | 464 | return " LEFT JOIN $state_table ON ( $join )"; |
465 | 465 | } |
466 | 466 | } |
467 | - unset( $join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk ); |
|
467 | + unset($join, $state_table, $state_table_pk, $venue_meta_table, $venue_table_pk); |
|
468 | 468 | return ''; |
469 | 469 | } |
470 | 470 | |
@@ -478,14 +478,14 @@ discard block |
||
478 | 478 | * @param WP_Query $wp_query |
479 | 479 | * @return string |
480 | 480 | */ |
481 | - public static function posts_where( $SQL = '', WP_Query $wp_query ) { |
|
482 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
481 | + public static function posts_where($SQL = '', WP_Query $wp_query) { |
|
482 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
483 | 483 | // Show Expired ? |
484 | - $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired( EEH_Event_Query::$_event_query_show_expired ); |
|
484 | + $SQL .= EEH_Event_Query::posts_where_sql_for_show_expired(EEH_Event_Query::$_event_query_show_expired); |
|
485 | 485 | // Category |
486 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug( EEH_Event_Query::$_event_query_category ); |
|
486 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_category_slug(EEH_Event_Query::$_event_query_category); |
|
487 | 487 | // Start Date |
488 | - $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month( EEH_Event_Query::$_event_query_month ); |
|
488 | + $SQL .= EEH_Event_Query::posts_where_sql_for_event_list_month(EEH_Event_Query::$_event_query_month); |
|
489 | 489 | } |
490 | 490 | return $SQL; |
491 | 491 | } |
@@ -499,8 +499,8 @@ discard block |
||
499 | 499 | * @param boolean $show_expired if TRUE, then displayed past events |
500 | 500 | * @return string |
501 | 501 | */ |
502 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
503 | - return ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . current_time( 'mysql', TRUE ) . '" ' : ''; |
|
502 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
503 | + return ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.current_time('mysql', TRUE).'" ' : ''; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | * @param boolean $event_category_slug |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
515 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
516 | 516 | global $wpdb; |
517 | - return ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : ''; |
|
517 | + return ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : ''; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | |
@@ -526,13 +526,13 @@ discard block |
||
526 | 526 | * @param boolean $month |
527 | 527 | * @return string |
528 | 528 | */ |
529 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
529 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
530 | 530 | $SQL = ''; |
531 | - if ( ! empty( $month ) ) { |
|
531 | + if ( ! empty($month)) { |
|
532 | 532 | // event start date is LESS than the end of the month ( so nothing that doesn't start until next month ) |
533 | - $SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start <= "' . gmdate( 'Y-m-t 23:59:59', strtotime( $month ) ) . '"'; |
|
533 | + $SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start <= "'.gmdate('Y-m-t 23:59:59', strtotime($month)).'"'; |
|
534 | 534 | // event end date is GREATER than the start of the month ( so nothing that ended before this month ) |
535 | - $SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end >= "' . gmdate( 'Y-m-01 0:0:00', strtotime( $month ) ) . '" '; |
|
535 | + $SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end >= "'.gmdate('Y-m-01 0:0:00', strtotime($month)).'" '; |
|
536 | 536 | } |
537 | 537 | return $SQL; |
538 | 538 | } |
@@ -547,9 +547,9 @@ discard block |
||
547 | 547 | * @param WP_Query $wp_query |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - public static function posts_orderby( $SQL = '', WP_Query $wp_query ) { |
|
551 | - if ( EEH_Event_Query::apply_query_filters( $wp_query ) ) { |
|
552 | - $SQL = EEH_Event_Query::posts_orderby_sql( EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort ); |
|
550 | + public static function posts_orderby($SQL = '', WP_Query $wp_query) { |
|
551 | + if (EEH_Event_Query::apply_query_filters($wp_query)) { |
|
552 | + $SQL = EEH_Event_Query::posts_orderby_sql(EEH_Event_Query::$_event_query_orderby, EEH_Event_Query::$_event_query_sort); |
|
553 | 553 | } |
554 | 554 | return $SQL; |
555 | 555 | } |
@@ -580,63 +580,63 @@ discard block |
||
580 | 580 | * @param string $sort |
581 | 581 | * @return string |
582 | 582 | */ |
583 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
583 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
584 | 584 | global $wpdb; |
585 | 585 | $SQL = ''; |
586 | 586 | $counter = 0; |
587 | 587 | //make sure 'orderby' is set in query params |
588 | - if ( ! isset( self::$_query_params['orderby'] )) { |
|
588 | + if ( ! isset(self::$_query_params['orderby'])) { |
|
589 | 589 | self::$_query_params['orderby'] = array(); |
590 | 590 | } |
591 | 591 | // loop thru $orderby_params (type cast as array) |
592 | - foreach ( (array)$orderby_params as $orderby ) { |
|
592 | + foreach ((array) $orderby_params as $orderby) { |
|
593 | 593 | // check if we have already added this param |
594 | - if ( isset( self::$_query_params['orderby'][ $orderby ] )) { |
|
594 | + if (isset(self::$_query_params['orderby'][$orderby])) { |
|
595 | 595 | // if so then remove from the $orderby_params so that the count() method below is accurate |
596 | - unset( $orderby_params[ $orderby ] ); |
|
596 | + unset($orderby_params[$orderby]); |
|
597 | 597 | // then bump ahead to the next param |
598 | 598 | continue; |
599 | 599 | } |
600 | 600 | // this will ad a comma depending on whether this is the first or last param |
601 | - $glue = $counter == 0 || $counter == count( $orderby_params ) ? ' ' : ', '; |
|
601 | + $glue = $counter == 0 || $counter == count($orderby_params) ? ' ' : ', '; |
|
602 | 602 | // ok what's we dealing with? |
603 | - switch ( $orderby ) { |
|
603 | + switch ($orderby) { |
|
604 | 604 | case 'id' : |
605 | 605 | case 'ID' : |
606 | - $SQL .= $glue . $wpdb->posts . '.ID ' . $sort; |
|
606 | + $SQL .= $glue.$wpdb->posts.'.ID '.$sort; |
|
607 | 607 | break; |
608 | 608 | case 'end_date' : |
609 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort; |
|
609 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort; |
|
610 | 610 | break; |
611 | 611 | case 'event_name' : |
612 | - $SQL .= $glue . $wpdb->posts . '.post_title ' . $sort; |
|
612 | + $SQL .= $glue.$wpdb->posts.'.post_title '.$sort; |
|
613 | 613 | break; |
614 | 614 | case 'category_slug' : |
615 | - $SQL .= $glue . $wpdb->terms . '.slug ' . $sort; |
|
615 | + $SQL .= $glue.$wpdb->terms.'.slug '.$sort; |
|
616 | 616 | break; |
617 | 617 | case 'ticket_start' : |
618 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort; |
|
618 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort; |
|
619 | 619 | break; |
620 | 620 | case 'ticket_end' : |
621 | - $SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort; |
|
621 | + $SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort; |
|
622 | 622 | break; |
623 | 623 | case 'venue_title' : |
624 | - $SQL .= $glue . 'venue_title ' . $sort; |
|
624 | + $SQL .= $glue.'venue_title '.$sort; |
|
625 | 625 | break; |
626 | 626 | case 'city' : |
627 | - $SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort; |
|
627 | + $SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort; |
|
628 | 628 | break; |
629 | 629 | case 'state' : |
630 | - $SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort; |
|
630 | + $SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort; |
|
631 | 631 | break; |
632 | 632 | case 'start_date' : |
633 | 633 | default : |
634 | - $SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort; |
|
634 | + $SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort; |
|
635 | 635 | break; |
636 | 636 | } |
637 | 637 | // add to array of orderby params that have been added |
638 | - self::$_query_params['orderby'][ $orderby ] = TRUE; |
|
639 | - $counter ++; |
|
638 | + self::$_query_params['orderby'][$orderby] = TRUE; |
|
639 | + $counter++; |
|
640 | 640 | } |
641 | 641 | return $SQL; |
642 | 642 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @ version 4.0 |
13 | 13 | * |
14 | 14 | */ |
15 | -require_once( EE_HELPERS . 'EEH_Base.helper.php' ); |
|
15 | +require_once(EE_HELPERS.'EEH_Base.helper.php'); |
|
16 | 16 | /** |
17 | 17 | * |
18 | 18 | * Class EEH_File |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | private static function _get_wp_filesystem() { |
42 | 42 | global $wp_filesystem; |
43 | 43 | // no filesystem setup ??? |
44 | - if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { |
|
44 | + if ( ! $wp_filesystem instanceof WP_Filesystem_Base) { |
|
45 | 45 | // if some eager beaver's just trying to get in there too early... |
46 | 46 | // let them do it, because we are one of those eager beavers! :P |
47 | 47 | /** |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | * and there may be troubles if the WP files are owned by a different user |
55 | 55 | * than the server user. But both of these issues should exist in 4.4 and earlier too |
56 | 56 | */ |
57 | - if ( FALSE && ! did_action( 'wp_loaded' )) { |
|
57 | + if (FALSE && ! did_action('wp_loaded')) { |
|
58 | 58 | $msg = __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso'); |
59 | - if ( WP_DEBUG ) { |
|
60 | - $msg .= '<br />' . __('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
59 | + if (WP_DEBUG) { |
|
60 | + $msg .= '<br />'.__('The WP Filesystem can not be accessed until after the "wp_loaded" hook has run, so it\'s best not to attempt access until the "admin_init" hookpoint.', 'event_espresso'); |
|
61 | 61 | } |
62 | - throw new EE_Error( $msg ); |
|
62 | + throw new EE_Error($msg); |
|
63 | 63 | } else { |
64 | 64 | // should be loaded if we are past the wp_loaded hook... |
65 | - if ( ! function_exists( 'WP_Filesystem' )) { |
|
66 | - require_once( ABSPATH . 'wp-admin/includes/file.php' ); |
|
67 | - require_once( ABSPATH . 'wp-admin/includes/template.php' ); |
|
65 | + if ( ! function_exists('WP_Filesystem')) { |
|
66 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
67 | + require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
68 | 68 | } |
69 | 69 | // basically check for direct or previously configured access |
70 | - if ( ! WP_Filesystem() ) { |
|
70 | + if ( ! WP_Filesystem()) { |
|
71 | 71 | // turn on output buffering so that we can capture the credentials form |
72 | 72 | ob_start(); |
73 | - $credentials = request_filesystem_credentials( '' ); |
|
73 | + $credentials = request_filesystem_credentials(''); |
|
74 | 74 | // store credentials form for the time being |
75 | 75 | EEH_File::$_credentials_form = ob_get_clean(); |
76 | 76 | // if credentials do NOT exist |
77 | - if ( $credentials === FALSE ) { |
|
78 | - add_action( 'admin_notices', array( 'EEH_File', 'display_request_filesystem_credentials_form' ), 999 ); |
|
79 | - throw new EE_Error( __('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
77 | + if ($credentials === FALSE) { |
|
78 | + add_action('admin_notices', array('EEH_File', 'display_request_filesystem_credentials_form'), 999); |
|
79 | + throw new EE_Error(__('An attempt to access and/or write to a file on the server could not be completed due to a lack of sufficient credentials.', 'event_espresso')); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * display_request_filesystem_credentials_form |
90 | 90 | */ |
91 | 91 | public static function display_request_filesystem_credentials_form() { |
92 | - if ( ! empty( EEH_File::$_credentials_form )) { |
|
93 | - echo '<div class="updated espresso-notices-attention"><p>' . EEH_File::$_credentials_form . '</p></div>'; |
|
92 | + if ( ! empty(EEH_File::$_credentials_form)) { |
|
93 | + echo '<div class="updated espresso-notices-attention"><p>'.EEH_File::$_credentials_form.'</p></div>'; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -108,29 +108,29 @@ discard block |
||
108 | 108 | * @throws EE_Error |
109 | 109 | * @return bool |
110 | 110 | */ |
111 | - public static function verify_filepath_and_permissions( $full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '' ) { |
|
111 | + public static function verify_filepath_and_permissions($full_file_path = '', $file_name = '', $file_ext = '', $type_of_file = '') { |
|
112 | 112 | // load WP_Filesystem and set file permissions |
113 | 113 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
114 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
115 | - if ( ! $wp_filesystem->is_readable( $full_file_path )) { |
|
116 | - $file_name = ! empty( $type_of_file ) ? $file_name . ' ' . $type_of_file : $file_name; |
|
117 | - $file_name .= ! empty( $file_ext ) ? ' file' : ' folder'; |
|
114 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
115 | + if ( ! $wp_filesystem->is_readable($full_file_path)) { |
|
116 | + $file_name = ! empty($type_of_file) ? $file_name.' '.$type_of_file : $file_name; |
|
117 | + $file_name .= ! empty($file_ext) ? ' file' : ' folder'; |
|
118 | 118 | $msg = sprintf( |
119 | - __( 'The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso' ), |
|
119 | + __('The requested %1$s could not be found or is not readable, possibly due to an incorrect filepath, or incorrect file permissions.%2$s', 'event_espresso'), |
|
120 | 120 | $file_name, |
121 | 121 | '<br />' |
122 | 122 | ); |
123 | - if ( EEH_File::exists( $full_file_path )) { |
|
124 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, $type_of_file ); |
|
123 | + if (EEH_File::exists($full_file_path)) { |
|
124 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, $type_of_file); |
|
125 | 125 | } else { |
126 | 126 | // no file permissions means the file was not found |
127 | 127 | $msg .= sprintf( |
128 | - __( 'Please ensure the following path is correct: "%s".', 'event_espresso' ), |
|
128 | + __('Please ensure the following path is correct: "%s".', 'event_espresso'), |
|
129 | 129 | $full_file_path |
130 | 130 | ); |
131 | 131 | } |
132 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
133 | - throw new EE_Error( $msg . '||' . $msg ); |
|
132 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
133 | + throw new EE_Error($msg.'||'.$msg); |
|
134 | 134 | } |
135 | 135 | return FALSE; |
136 | 136 | } |
@@ -147,24 +147,24 @@ discard block |
||
147 | 147 | * @param string $type_of_file - general type of file (ie: "module"), this is only used to improve error messages |
148 | 148 | * @return string |
149 | 149 | */ |
150 | - private static function _permissions_error_for_unreadable_filepath( $full_file_path = '', $type_of_file = '' ){ |
|
150 | + private static function _permissions_error_for_unreadable_filepath($full_file_path = '', $type_of_file = '') { |
|
151 | 151 | // load WP_Filesystem and set file permissions |
152 | 152 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
153 | 153 | // check file permissions |
154 | - $perms = $wp_filesystem->getchmod( $full_file_path ); |
|
155 | - if ( $perms ) { |
|
154 | + $perms = $wp_filesystem->getchmod($full_file_path); |
|
155 | + if ($perms) { |
|
156 | 156 | // file permissions exist, but way be set incorrectly |
157 | - $type_of_file = ! empty( $type_of_file ) ? $type_of_file . ' ' : ''; |
|
158 | - $type_of_file .= ! empty( $type_of_file ) ? 'file' : 'folder'; |
|
157 | + $type_of_file = ! empty($type_of_file) ? $type_of_file.' ' : ''; |
|
158 | + $type_of_file .= ! empty($type_of_file) ? 'file' : 'folder'; |
|
159 | 159 | return sprintf( |
160 | - __( 'File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso' ), |
|
160 | + __('File permissions for the requested %1$s are currently set at "%2$s". The recommended permissions are 644 for files and 755 for folders.', 'event_espresso'), |
|
161 | 161 | $type_of_file, |
162 | 162 | $perms |
163 | 163 | ); |
164 | 164 | } else { |
165 | 165 | // file exists but file permissions could not be read ?!?! |
166 | 166 | return sprintf( |
167 | - __( 'Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso' ), |
|
167 | + __('Please ensure that the server and/or PHP configuration allows the current process to access the following file: "%s".', 'event_espresso'), |
|
168 | 168 | $full_file_path |
169 | 169 | ); |
170 | 170 | } |
@@ -179,33 +179,33 @@ discard block |
||
179 | 179 | * @throws EE_Error |
180 | 180 | * @return bool |
181 | 181 | */ |
182 | - public static function ensure_folder_exists_and_is_writable( $folder = '' ){ |
|
183 | - if ( empty( $folder )) { |
|
182 | + public static function ensure_folder_exists_and_is_writable($folder = '') { |
|
183 | + if (empty($folder)) { |
|
184 | 184 | return FALSE; |
185 | 185 | } |
186 | 186 | // remove ending DS |
187 | - $folder = EEH_File::standardise_directory_separators( rtrim( $folder, '/\\' )); |
|
187 | + $folder = EEH_File::standardise_directory_separators(rtrim($folder, '/\\')); |
|
188 | 188 | // determine parent folder |
189 | - $folder_segments = explode( DS, $folder ); |
|
190 | - array_pop( $folder_segments ); |
|
191 | - $parent_folder = implode( DS, $folder_segments ) . DS; |
|
189 | + $folder_segments = explode(DS, $folder); |
|
190 | + array_pop($folder_segments); |
|
191 | + $parent_folder = implode(DS, $folder_segments).DS; |
|
192 | 192 | // add DS to folder |
193 | - $folder = EEH_File::end_with_directory_separator( $folder ); |
|
193 | + $folder = EEH_File::end_with_directory_separator($folder); |
|
194 | 194 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
195 | - if ( ! $wp_filesystem->is_dir( $folder )) { |
|
196 | - if ( ! EEH_File::verify_is_writable( $parent_folder, 'folder' )) { |
|
195 | + if ( ! $wp_filesystem->is_dir($folder)) { |
|
196 | + if ( ! EEH_File::verify_is_writable($parent_folder, 'folder')) { |
|
197 | 197 | return FALSE; |
198 | 198 | } else { |
199 | - if ( ! $wp_filesystem->mkdir( $folder )) { |
|
200 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
201 | - $msg = sprintf( __( '"%s" could not be created.', 'event_espresso' ), $folder ); |
|
202 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $folder ); |
|
203 | - throw new EE_Error( $msg ); |
|
199 | + if ( ! $wp_filesystem->mkdir($folder)) { |
|
200 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
201 | + $msg = sprintf(__('"%s" could not be created.', 'event_espresso'), $folder); |
|
202 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($folder); |
|
203 | + throw new EE_Error($msg); |
|
204 | 204 | } |
205 | 205 | return FALSE; |
206 | 206 | } |
207 | 207 | } |
208 | - } elseif ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
208 | + } elseif ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
209 | 209 | return FALSE; |
210 | 210 | } |
211 | 211 | return TRUE; |
@@ -220,15 +220,15 @@ discard block |
||
220 | 220 | * @throws EE_Error |
221 | 221 | * @return bool |
222 | 222 | */ |
223 | - public static function verify_is_writable( $full_path = '', $file_or_folder = 'folder' ){ |
|
223 | + public static function verify_is_writable($full_path = '', $file_or_folder = 'folder') { |
|
224 | 224 | // load WP_Filesystem and set file permissions |
225 | 225 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
226 | - $full_path = EEH_File::standardise_directory_separators( $full_path ); |
|
227 | - if ( ! $wp_filesystem->is_writable( $full_path )) { |
|
228 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
229 | - $msg = sprintf( __( 'The "%1$s" %2$s is not writable.', 'event_espresso' ), $full_path, $file_or_folder ); |
|
230 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_path ); |
|
231 | - throw new EE_Error( $msg ); |
|
226 | + $full_path = EEH_File::standardise_directory_separators($full_path); |
|
227 | + if ( ! $wp_filesystem->is_writable($full_path)) { |
|
228 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
229 | + $msg = sprintf(__('The "%1$s" %2$s is not writable.', 'event_espresso'), $full_path, $file_or_folder); |
|
230 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_path); |
|
231 | + throw new EE_Error($msg); |
|
232 | 232 | } |
233 | 233 | return FALSE; |
234 | 234 | } |
@@ -244,21 +244,21 @@ discard block |
||
244 | 244 | * @throws EE_Error |
245 | 245 | * @return bool |
246 | 246 | */ |
247 | - public static function ensure_file_exists_and_is_writable( $full_file_path = '' ) { |
|
247 | + public static function ensure_file_exists_and_is_writable($full_file_path = '') { |
|
248 | 248 | // load WP_Filesystem and set file permissions |
249 | 249 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
250 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
251 | - if ( ! EEH_File::exists( $full_file_path )) { |
|
252 | - if ( ! $wp_filesystem->touch( $full_file_path )) { |
|
253 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
254 | - $msg = sprintf( __( 'The "%s" file could not be created.', 'event_espresso' ), $full_file_path ); |
|
255 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
256 | - throw new EE_Error( $msg ); |
|
250 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
251 | + if ( ! EEH_File::exists($full_file_path)) { |
|
252 | + if ( ! $wp_filesystem->touch($full_file_path)) { |
|
253 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
254 | + $msg = sprintf(__('The "%s" file could not be created.', 'event_espresso'), $full_file_path); |
|
255 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
256 | + throw new EE_Error($msg); |
|
257 | 257 | } |
258 | 258 | return FALSE; |
259 | 259 | } |
260 | 260 | } |
261 | - if ( ! EEH_File::verify_is_writable( $full_file_path, 'file' )) { |
|
261 | + if ( ! EEH_File::verify_is_writable($full_file_path, 'file')) { |
|
262 | 262 | return FALSE; |
263 | 263 | } |
264 | 264 | return TRUE; |
@@ -271,12 +271,12 @@ discard block |
||
271 | 271 | * @param string $full_file_path |
272 | 272 | * @return string |
273 | 273 | */ |
274 | - public static function get_file_contents( $full_file_path = '' ){ |
|
275 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
276 | - if ( EEH_File::verify_filepath_and_permissions( $full_file_path, EEH_File::get_filename_from_filepath( $full_file_path ) , EEH_File::get_file_extension( $full_file_path ))) { |
|
274 | + public static function get_file_contents($full_file_path = '') { |
|
275 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
276 | + if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { |
|
277 | 277 | // load WP_Filesystem and set file permissions |
278 | 278 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
279 | - return $wp_filesystem->get_contents( $full_file_path ); |
|
279 | + return $wp_filesystem->get_contents($full_file_path); |
|
280 | 280 | } |
281 | 281 | return ''; |
282 | 282 | } |
@@ -291,26 +291,26 @@ discard block |
||
291 | 291 | * @throws EE_Error |
292 | 292 | * @return bool |
293 | 293 | */ |
294 | - public static function write_to_file( $full_file_path = '', $file_contents = '', $file_type = '' ){ |
|
295 | - $full_file_path = EEH_File::standardise_directory_separators( $full_file_path ); |
|
296 | - $file_type = ! empty( $file_type ) ? rtrim( $file_type, ' ' ) . ' ' : ''; |
|
297 | - $folder = EEH_File::remove_filename_from_filepath( $full_file_path ); |
|
298 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
299 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
300 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" is not writable.', 'event_espresso' ), $file_type, $full_file_path ); |
|
301 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path ); |
|
302 | - throw new EE_Error( $msg ); |
|
294 | + public static function write_to_file($full_file_path = '', $file_contents = '', $file_type = '') { |
|
295 | + $full_file_path = EEH_File::standardise_directory_separators($full_file_path); |
|
296 | + $file_type = ! empty($file_type) ? rtrim($file_type, ' ').' ' : ''; |
|
297 | + $folder = EEH_File::remove_filename_from_filepath($full_file_path); |
|
298 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
299 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
300 | + $msg = sprintf(__('The %1$sfile located at "%2$s" is not writable.', 'event_espresso'), $file_type, $full_file_path); |
|
301 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path); |
|
302 | + throw new EE_Error($msg); |
|
303 | 303 | } |
304 | 304 | return FALSE; |
305 | 305 | } |
306 | 306 | // load WP_Filesystem and set file permissions |
307 | 307 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
308 | 308 | // write the file |
309 | - if ( ! $wp_filesystem->put_contents( $full_file_path, $file_contents )) { |
|
310 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
311 | - $msg = sprintf( __( 'The %1$sfile located at "%2$s" could not be written to.', 'event_espresso' ), $file_type, $full_file_path ); |
|
312 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_file_path, 'f' ); |
|
313 | - throw new EE_Error( $msg ); |
|
309 | + if ( ! $wp_filesystem->put_contents($full_file_path, $file_contents)) { |
|
310 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
311 | + $msg = sprintf(__('The %1$sfile located at "%2$s" could not be written to.', 'event_espresso'), $file_type, $full_file_path); |
|
312 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_file_path, 'f'); |
|
313 | + throw new EE_Error($msg); |
|
314 | 314 | } |
315 | 315 | return FALSE; |
316 | 316 | } |
@@ -326,9 +326,9 @@ discard block |
||
326 | 326 | * @param string $full_file_path |
327 | 327 | * @return bool |
328 | 328 | */ |
329 | - public static function exists( $full_file_path = '' ) { |
|
329 | + public static function exists($full_file_path = '') { |
|
330 | 330 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
331 | - return $wp_filesystem->exists( $full_file_path ) ? TRUE : FALSE; |
|
331 | + return $wp_filesystem->exists($full_file_path) ? TRUE : FALSE; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * @param string $full_file_path |
341 | 341 | * @return bool |
342 | 342 | */ |
343 | - public static function is_readable( $full_file_path = '' ) { |
|
343 | + public static function is_readable($full_file_path = '') { |
|
344 | 344 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
345 | - return $wp_filesystem->is_readable( $full_file_path ) ? TRUE : FALSE; |
|
345 | + return $wp_filesystem->is_readable($full_file_path) ? TRUE : FALSE; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $full_file_path |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public static function remove_filename_from_filepath( $full_file_path = '' ) { |
|
358 | - return pathinfo( $full_file_path, PATHINFO_DIRNAME ); |
|
357 | + public static function remove_filename_from_filepath($full_file_path = '') { |
|
358 | + return pathinfo($full_file_path, PATHINFO_DIRNAME); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $full_file_path |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - public static function get_filename_from_filepath( $full_file_path = '' ) { |
|
369 | - return pathinfo( $full_file_path, PATHINFO_BASENAME ); |
|
368 | + public static function get_filename_from_filepath($full_file_path = '') { |
|
369 | + return pathinfo($full_file_path, PATHINFO_BASENAME); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $full_file_path |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public static function get_file_extension( $full_file_path = '' ) { |
|
380 | - return pathinfo( $full_file_path, PATHINFO_EXTENSION ); |
|
379 | + public static function get_file_extension($full_file_path = '') { |
|
380 | + return pathinfo($full_file_path, PATHINFO_EXTENSION); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @param string $folder |
388 | 388 | * @return bool |
389 | 389 | */ |
390 | - public static function add_htaccess_deny_from_all( $folder = '' ) { |
|
391 | - $folder = EEH_File::standardise_and_end_with_directory_separator( $folder ); |
|
392 | - if ( ! EEH_File::exists( $folder . '.htaccess' ) ) { |
|
393 | - if ( ! EEH_File::write_to_file( $folder . '.htaccess', 'deny from all', '.htaccess' )) { |
|
390 | + public static function add_htaccess_deny_from_all($folder = '') { |
|
391 | + $folder = EEH_File::standardise_and_end_with_directory_separator($folder); |
|
392 | + if ( ! EEH_File::exists($folder.'.htaccess')) { |
|
393 | + if ( ! EEH_File::write_to_file($folder.'.htaccess', 'deny from all', '.htaccess')) { |
|
394 | 394 | return FALSE; |
395 | 395 | } |
396 | 396 | } |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | * @param string $file_path |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - public static function get_classname_from_filepath_with_standard_filename( $file_path ){ |
|
408 | + public static function get_classname_from_filepath_with_standard_filename($file_path) { |
|
409 | 409 | //extract file from path |
410 | - $filename = basename( $file_path ); |
|
410 | + $filename = basename($file_path); |
|
411 | 411 | //now remove the first period and everything after |
412 | - $pos_of_first_period = strpos( $filename,'.' ); |
|
412 | + $pos_of_first_period = strpos($filename, '.'); |
|
413 | 413 | return substr($filename, 0, $pos_of_first_period); |
414 | 414 | } |
415 | 415 | |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * @param string $file_path |
422 | 422 | * @return string |
423 | 423 | */ |
424 | - public static function standardise_directory_separators( $file_path ){ |
|
425 | - return str_replace( array( '\\', '/' ), DS, $file_path ); |
|
424 | + public static function standardise_directory_separators($file_path) { |
|
425 | + return str_replace(array('\\', '/'), DS, $file_path); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | * @param string $file_path |
434 | 434 | * @return string |
435 | 435 | */ |
436 | - public static function end_with_directory_separator( $file_path ){ |
|
437 | - return rtrim( $file_path, '/\\' ) . DS; |
|
436 | + public static function end_with_directory_separator($file_path) { |
|
437 | + return rtrim($file_path, '/\\').DS; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * @param $file_path |
445 | 445 | * @return string |
446 | 446 | */ |
447 | - public static function standardise_and_end_with_directory_separator( $file_path ){ |
|
448 | - return self::end_with_directory_separator( self::standardise_directory_separators( $file_path )); |
|
447 | + public static function standardise_and_end_with_directory_separator($file_path) { |
|
448 | + return self::end_with_directory_separator(self::standardise_directory_separators($file_path)); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -462,21 +462,21 @@ discard block |
||
462 | 462 | * if $index_numerically == FALSE (Default) keys are what the class names SHOULD be; |
463 | 463 | * and values are their filepaths |
464 | 464 | */ |
465 | - public static function get_contents_of_folders( $folder_paths = array(), $index_numerically = FALSE ){ |
|
465 | + public static function get_contents_of_folders($folder_paths = array(), $index_numerically = FALSE) { |
|
466 | 466 | $class_to_folder_path = array(); |
467 | - foreach( $folder_paths as $folder_path ){ |
|
468 | - $folder_path = self::standardise_and_end_with_directory_separator( $folder_path ); |
|
467 | + foreach ($folder_paths as $folder_path) { |
|
468 | + $folder_path = self::standardise_and_end_with_directory_separator($folder_path); |
|
469 | 469 | // load WP_Filesystem and set file permissions |
470 | - $files_in_folder = glob( $folder_path . '*' ); |
|
470 | + $files_in_folder = glob($folder_path.'*'); |
|
471 | 471 | $class_to_folder_path = array(); |
472 | - if ( $files_in_folder ) { |
|
473 | - foreach( $files_in_folder as $file_path ){ |
|
472 | + if ($files_in_folder) { |
|
473 | + foreach ($files_in_folder as $file_path) { |
|
474 | 474 | //only add files, not folders |
475 | - if ( ! is_dir( $file_path )) { |
|
476 | - if ( $index_numerically ) { |
|
475 | + if ( ! is_dir($file_path)) { |
|
476 | + if ($index_numerically) { |
|
477 | 477 | $class_to_folder_path[] = $file_path; |
478 | 478 | } else { |
479 | - $classname = self::get_classname_from_filepath_with_standard_filename( $file_path ); |
|
479 | + $classname = self::get_classname_from_filepath_with_standard_filename($file_path); |
|
480 | 480 | $class_to_folder_path[$classname] = $file_path; |
481 | 481 | } |
482 | 482 | } |
@@ -496,24 +496,24 @@ discard block |
||
496 | 496 | * @return boolean success |
497 | 497 | * @throws EE_Error |
498 | 498 | */ |
499 | - public static function copy( $source_file, $destination_file, $overwrite = FALSE ){ |
|
500 | - $full_source_path = EEH_File::standardise_directory_separators( $source_file ); |
|
501 | - if( ! EEH_File::exists( $full_source_path ) ){ |
|
502 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
503 | - $msg = sprintf( __( 'The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso' ), $full_source_path ); |
|
504 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path ); |
|
505 | - throw new EE_Error( $msg ); |
|
499 | + public static function copy($source_file, $destination_file, $overwrite = FALSE) { |
|
500 | + $full_source_path = EEH_File::standardise_directory_separators($source_file); |
|
501 | + if ( ! EEH_File::exists($full_source_path)) { |
|
502 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
503 | + $msg = sprintf(__('The file located at "%2$s" is not readable or doesn\'t exist.', 'event_espresso'), $full_source_path); |
|
504 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path); |
|
505 | + throw new EE_Error($msg); |
|
506 | 506 | } |
507 | 507 | return FALSE; |
508 | 508 | } |
509 | 509 | |
510 | - $full_dest_path = EEH_File::standardise_directory_separators( $destination_file ); |
|
511 | - $folder = EEH_File::remove_filename_from_filepath( $full_dest_path ); |
|
512 | - if ( ! EEH_File::verify_is_writable( $folder, 'folder' )) { |
|
513 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
514 | - $msg = sprintf( __( 'The file located at "%2$s" is not writable.', 'event_espresso' ), $full_dest_path ); |
|
515 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_dest_path ); |
|
516 | - throw new EE_Error( $msg ); |
|
510 | + $full_dest_path = EEH_File::standardise_directory_separators($destination_file); |
|
511 | + $folder = EEH_File::remove_filename_from_filepath($full_dest_path); |
|
512 | + if ( ! EEH_File::verify_is_writable($folder, 'folder')) { |
|
513 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
514 | + $msg = sprintf(__('The file located at "%2$s" is not writable.', 'event_espresso'), $full_dest_path); |
|
515 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_dest_path); |
|
516 | + throw new EE_Error($msg); |
|
517 | 517 | } |
518 | 518 | return FALSE; |
519 | 519 | } |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | // load WP_Filesystem and set file permissions |
522 | 522 | $wp_filesystem = EEH_File::_get_wp_filesystem(); |
523 | 523 | // write the file |
524 | - if ( ! $wp_filesystem->copy( $full_source_path, $full_dest_path, $overwrite )) { |
|
525 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
526 | - $msg = sprintf( __( 'Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso' ), $full_source_path ); |
|
527 | - $msg .= EEH_File::_permissions_error_for_unreadable_filepath( $full_source_path, 'f' ); |
|
528 | - throw new EE_Error( $msg ); |
|
524 | + if ( ! $wp_filesystem->copy($full_source_path, $full_dest_path, $overwrite)) { |
|
525 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
526 | + $msg = sprintf(__('Attempted writing to file %1$s, but could not, probably because of permissions issues', 'event_espresso'), $full_source_path); |
|
527 | + $msg .= EEH_File::_permissions_error_for_unreadable_filepath($full_source_path, 'f'); |
|
528 | + throw new EE_Error($msg); |
|
529 | 529 | } |
530 | 530 | return FALSE; |
531 | 531 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |