@@ -175,7 +175,7 @@ |
||
175 | 175 | * @param array $wpdb_row |
176 | 176 | * @param \WP_REST_Request $request |
177 | 177 | * @param Base $controller |
178 | - * @return int|null if permission denied |
|
178 | + * @return integer if permission denied |
|
179 | 179 | */ |
180 | 180 | public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){ |
181 | 181 | if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since $VID:$ |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Event extends Calculations_Base { |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | * @return int |
33 | 33 | * @throws \EE_Error |
34 | 34 | */ |
35 | - public static function optimum_sales_at_start( $wpdb_row, $request, $controller ){ |
|
36 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
37 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
35 | + public static function optimum_sales_at_start($wpdb_row, $request, $controller) { |
|
36 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
37 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
38 | 38 | } else { |
39 | 39 | $event_obj = null; |
40 | 40 | } |
41 | - if( $event_obj instanceof \EE_Event ) { |
|
42 | - return $event_obj->total_available_spaces( true ); |
|
41 | + if ($event_obj instanceof \EE_Event) { |
|
42 | + return $event_obj->total_available_spaces(true); |
|
43 | 43 | } else { |
44 | 44 | throw new \EE_Error( |
45 | 45 | sprintf( |
46 | - __( 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
47 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
48 | - print_r( $wpdb_row, true ) |
|
46 | + __('Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
47 | + $wpdb_row['Event_CPT.ID'], |
|
48 | + print_r($wpdb_row, true) |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | } |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @return int |
65 | 65 | * @throws \EE_Error |
66 | 66 | */ |
67 | - public static function optimum_sales_now( $wpdb_row, $request, $controller ){ |
|
68 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
69 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
67 | + public static function optimum_sales_now($wpdb_row, $request, $controller) { |
|
68 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
69 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
70 | 70 | } else { |
71 | 71 | $event_obj = null; |
72 | 72 | } |
73 | - if( $event_obj instanceof \EE_Event ) { |
|
74 | - return $event_obj->total_available_spaces( false ); |
|
73 | + if ($event_obj instanceof \EE_Event) { |
|
74 | + return $event_obj->total_available_spaces(false); |
|
75 | 75 | } else { |
76 | 76 | throw new \EE_Error( |
77 | 77 | sprintf( |
78 | - __( 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
79 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
80 | - print_r( $wpdb_row, true ) |
|
78 | + __('Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
79 | + $wpdb_row['Event_CPT.ID'], |
|
80 | + print_r($wpdb_row, true) |
|
81 | 81 | ) |
82 | 82 | ); |
83 | 83 | } |
@@ -95,20 +95,20 @@ discard block |
||
95 | 95 | * @return int |
96 | 96 | * @throws \EE_Error |
97 | 97 | */ |
98 | - public static function spaces_remaining( $wpdb_row, $request, $controller ){ |
|
99 | - if( is_array( $wpdb_row ) && isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
100 | - $event_obj = \EEM_Event::instance()->get_one_by_ID( $wpdb_row[ 'Event_CPT.ID' ] ); |
|
98 | + public static function spaces_remaining($wpdb_row, $request, $controller) { |
|
99 | + if (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID'])) { |
|
100 | + $event_obj = \EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
101 | 101 | } else { |
102 | 102 | $event_obj = null; |
103 | 103 | } |
104 | - if( $event_obj instanceof \EE_Event ) { |
|
104 | + if ($event_obj instanceof \EE_Event) { |
|
105 | 105 | return $event_obj->spaces_remaining_for_sale(); |
106 | 106 | } else { |
107 | 107 | throw new \EE_Error( |
108 | 108 | sprintf( |
109 | - __( 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso' ), |
|
110 | - $wpdb_row[ 'Event_CPT.ID' ], |
|
111 | - print_r( $wpdb_row, true ) |
|
109 | + __('Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', 'event_espresso'), |
|
110 | + $wpdb_row['Event_CPT.ID'], |
|
111 | + print_r($wpdb_row, true) |
|
112 | 112 | ) |
113 | 113 | ); |
114 | 114 | } |
@@ -126,19 +126,19 @@ discard block |
||
126 | 126 | * @return int |
127 | 127 | * @throws \EE_Error |
128 | 128 | */ |
129 | - public static function spots_taken( $wpdb_row, $request, $controller ){ |
|
130 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
129 | + public static function spots_taken($wpdb_row, $request, $controller) { |
|
130 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
131 | 131 | throw new \EE_Error( |
132 | 132 | sprintf( |
133 | - __( 'Cannot calculate spots_taken because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
134 | - print_r( $wpdb_row, true ) |
|
133 | + __('Cannot calculate spots_taken because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
134 | + print_r($wpdb_row, true) |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | } |
138 | 138 | return \EEM_Registration::instance()->count( |
139 | 139 | array( |
140 | 140 | array( |
141 | - 'EVT_ID' => $wpdb_row[ 'Event_CPT.ID' ], |
|
141 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
142 | 142 | 'STS_ID' => \EEM_Registration::status_id_approved |
143 | 143 | ) |
144 | 144 | ), |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | * @throws \EE_Error |
161 | 161 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
162 | 162 | */ |
163 | - public static function spots_taken_pending_payment( $wpdb_row, $request, $controller ){ |
|
164 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
163 | + public static function spots_taken_pending_payment($wpdb_row, $request, $controller) { |
|
164 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
165 | 165 | throw new \EE_Error( |
166 | 166 | sprintf( |
167 | - __( 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
168 | - print_r( $wpdb_row, true ) |
|
167 | + __('Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
168 | + print_r($wpdb_row, true) |
|
169 | 169 | ) |
170 | 170 | ); |
171 | 171 | } |
172 | - self::_verify_current_user_can( 'ee_read_registrations', 'spots_taken_pending_payment' ); |
|
172 | + self::_verify_current_user_can('ee_read_registrations', 'spots_taken_pending_payment'); |
|
173 | 173 | return \EEM_Registration::instance()->count( |
174 | 174 | array( |
175 | 175 | array( |
176 | - 'EVT_ID' => $wpdb_row[ 'Event_CPT.ID' ], |
|
176 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
177 | 177 | 'STS_ID' => \EEM_Registration::status_id_pending_payment |
178 | 178 | ) |
179 | 179 | ), |
@@ -195,17 +195,17 @@ discard block |
||
195 | 195 | * @throws \EE_Error |
196 | 196 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
197 | 197 | */ |
198 | - public static function registrations_checked_in_count( $wpdb_row, $request, $controller ){ |
|
199 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
198 | + public static function registrations_checked_in_count($wpdb_row, $request, $controller) { |
|
199 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
200 | 200 | throw new \EE_Error( |
201 | 201 | sprintf( |
202 | - __( 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
203 | - print_r( $wpdb_row, true ) |
|
202 | + __('Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
203 | + print_r($wpdb_row, true) |
|
204 | 204 | ) |
205 | 205 | ); |
206 | 206 | } |
207 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_in_count' ); |
|
208 | - return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], true ); |
|
207 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_in_count'); |
|
208 | + return \EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -221,17 +221,17 @@ discard block |
||
221 | 221 | * @throws \EE_Error |
222 | 222 | * @throws \EventEspresso\core\libraries\rest_api\Rest_Exception |
223 | 223 | */ |
224 | - public static function registrations_checked_out_count( $wpdb_row, $request, $controller ){ |
|
225 | - if( ! is_array( $wpdb_row ) || ! isset( $wpdb_row[ 'Event_CPT.ID' ] ) ) { |
|
224 | + public static function registrations_checked_out_count($wpdb_row, $request, $controller) { |
|
225 | + if ( ! is_array($wpdb_row) || ! isset($wpdb_row['Event_CPT.ID'])) { |
|
226 | 226 | throw new \EE_Error( |
227 | 227 | sprintf( |
228 | - __( 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso' ), |
|
229 | - print_r( $wpdb_row, true ) |
|
228 | + __('Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', 'event_espresso'), |
|
229 | + print_r($wpdb_row, true) |
|
230 | 230 | ) |
231 | 231 | ); |
232 | 232 | } |
233 | - self::_verify_current_user_can( 'ee_read_checkins', 'registrations_checked_out_count' ); |
|
234 | - return \EEM_Registration::instance()->count_registrations_checked_into_event( $wpdb_row[ 'Event_CPT.ID' ], false ); |
|
233 | + self::_verify_current_user_can('ee_read_checkins', 'registrations_checked_out_count'); |
|
234 | + return \EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @param Base $controller |
242 | 242 | * @return array |
243 | 243 | */ |
244 | - public static function image_thumbnail( $wpdb_row, $request, $controller ) { |
|
245 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'thumbnail' ); |
|
244 | + public static function image_thumbnail($wpdb_row, $request, $controller) { |
|
245 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'thumbnail'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @param Base $controller |
253 | 253 | * @return array |
254 | 254 | */ |
255 | - public static function image_medium( $wpdb_row, $request, $controller ) { |
|
256 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'medium' ); |
|
255 | + public static function image_medium($wpdb_row, $request, $controller) { |
|
256 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'medium'); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | * @param Base $controller |
264 | 264 | * @return array |
265 | 265 | */ |
266 | - public static function image_medium_large( $wpdb_row, $request, $controller ) { |
|
267 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'medium_large' ); |
|
266 | + public static function image_medium_large($wpdb_row, $request, $controller) { |
|
267 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'medium_large'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -274,8 +274,8 @@ discard block |
||
274 | 274 | * @param Base $controller |
275 | 275 | * @return array |
276 | 276 | */ |
277 | - public static function image_large( $wpdb_row, $request, $controller ) { |
|
278 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'large' ); |
|
277 | + public static function image_large($wpdb_row, $request, $controller) { |
|
278 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'large'); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | * @param Base $controller |
286 | 286 | * @return array |
287 | 287 | */ |
288 | - public static function image_post_thumbnail( $wpdb_row, $request, $controller ) { |
|
289 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'post-thumbnail' ); |
|
288 | + public static function image_post_thumbnail($wpdb_row, $request, $controller) { |
|
289 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'post-thumbnail'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,8 +296,8 @@ discard block |
||
296 | 296 | * @param Base $controller |
297 | 297 | * @return array |
298 | 298 | */ |
299 | - public static function image_full( $wpdb_row, $request, $controller ) { |
|
300 | - return self::_calculate_image_data($wpdb_row[ 'Event_CPT.ID' ], 'full' ); |
|
299 | + public static function image_full($wpdb_row, $request, $controller) { |
|
300 | + return self::_calculate_image_data($wpdb_row['Event_CPT.ID'], 'full'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -307,21 +307,21 @@ discard block |
||
307 | 307 | * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
308 | 308 | * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
309 | 309 | */ |
310 | - protected static function _calculate_image_data( $EVT_ID, $image_size ) { |
|
311 | - $attachment_id = get_post_thumbnail_id( $EVT_ID ); |
|
312 | - $data = wp_get_attachment_image_src( $attachment_id, $image_size ); |
|
313 | - if( ! $data ) { |
|
310 | + protected static function _calculate_image_data($EVT_ID, $image_size) { |
|
311 | + $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
312 | + $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
313 | + if ( ! $data) { |
|
314 | 314 | return false; |
315 | 315 | } |
316 | - if( isset( $data[ 3] ) ) { |
|
317 | - $generated = $data[ 3 ]; |
|
316 | + if (isset($data[3])) { |
|
317 | + $generated = $data[3]; |
|
318 | 318 | } else { |
319 | 319 | $generated = true; |
320 | 320 | } |
321 | 321 | return array( |
322 | - 'url' => $data[ 0 ], |
|
323 | - 'width' => $data[ 1 ], |
|
324 | - 'height' => $data[ 2 ], |
|
322 | + 'url' => $data[0], |
|
323 | + 'width' => $data[1], |
|
324 | + 'height' => $data[2], |
|
325 | 325 | 'generated' => $generated |
326 | 326 | ); |
327 | 327 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Prepares incoming data from the json or $_REQUEST parameters for the models' |
57 | 57 | * "$query_params". |
58 | - * @param EE_Model_Field_Base $field_obj |
|
58 | + * @param \EE_Model_Field_Base $field_obj |
|
59 | 59 | * @param mixed $original_value |
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
@@ -77,6 +77,7 @@ discard block |
||
77 | 77 | * Prepares a field's value for display in the API |
78 | 78 | * @param \EE_Model_Field_Base $field_obj |
79 | 79 | * @param mixed $original_value |
80 | + * @param string $requested_version |
|
80 | 81 | * @return mixed |
81 | 82 | */ |
82 | 83 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
@@ -131,6 +132,9 @@ discard block |
||
131 | 132 | return $query_param_for_models; |
132 | 133 | } |
133 | 134 | |
135 | + /** |
|
136 | + * @return string |
|
137 | + */ |
|
134 | 138 | public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
135 | 139 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 140 | if($pos_of_star === FALSE){ |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
25 | - exit( 'No direct script access allowed' ); |
|
24 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
25 | + exit('No direct script access allowed'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | class Model_Data_Translator { |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * @param string $requested_version |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public static function prepare_field_values_from_json( $field_obj, $original_value_maybe_array, $requested_version ) { |
|
44 | - if( is_array( $original_value_maybe_array ) ) { |
|
43 | + public static function prepare_field_values_from_json($field_obj, $original_value_maybe_array, $requested_version) { |
|
44 | + if (is_array($original_value_maybe_array)) { |
|
45 | 45 | $new_value_maybe_array = array(); |
46 | - foreach( $original_value_maybe_array as $array_key => $array_item ) { |
|
47 | - $new_value_maybe_array[ $array_key ] = self::prepare_field_value_from_json( $field_obj, $array_item, $requested_version ); |
|
46 | + foreach ($original_value_maybe_array as $array_key => $array_item) { |
|
47 | + $new_value_maybe_array[$array_key] = self::prepare_field_value_from_json($field_obj, $array_item, $requested_version); |
|
48 | 48 | } |
49 | 49 | } else { |
50 | - $new_value_maybe_array = self::prepare_field_value_from_json( $field_obj, $original_value_maybe_array, $requested_version ); |
|
50 | + $new_value_maybe_array = self::prepare_field_value_from_json($field_obj, $original_value_maybe_array, $requested_version); |
|
51 | 51 | } |
52 | 52 | return $new_value_maybe_array; |
53 | 53 | } |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param string $requested_version |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | - public static function prepare_field_value_from_json( $field_obj, $original_value, $requested_version ) { |
|
63 | + public static function prepare_field_value_from_json($field_obj, $original_value, $requested_version) { |
|
64 | 64 | $new_value = null; |
65 | - if( $field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | - && in_array( $original_value, array( null, '' ), true ) ) { |
|
65 | + if ($field_obj instanceof \EE_Infinite_Integer_Field |
|
66 | + && in_array($original_value, array(null, ''), true)) { |
|
67 | 67 | $new_value = EE_INF; |
68 | - } elseif( $field_obj instanceof \EE_Datetime_Field ) { |
|
69 | - $new_value = rest_parse_date( $original_value ); |
|
68 | + } elseif ($field_obj instanceof \EE_Datetime_Field) { |
|
69 | + $new_value = rest_parse_date($original_value); |
|
70 | 70 | } else { |
71 | 71 | $new_value = $original_value; |
72 | 72 | } |
@@ -79,17 +79,17 @@ discard block |
||
79 | 79 | * @param mixed $original_value |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
|
83 | - if( $original_value === EE_INF ) { |
|
82 | + public static function prepare_field_value_for_json($field_obj, $original_value, $requested_version) { |
|
83 | + if ($original_value === EE_INF) { |
|
84 | 84 | $new_value = self::ee_inf_in_rest; |
85 | - } elseif( $field_obj instanceof \EE_Datetime_Field && |
|
86 | - $original_value instanceof \DateTime ) { |
|
87 | - $new_value = $original_value->format( 'c' ); |
|
88 | - $new_value = mysql_to_rfc3339( $new_value ); |
|
85 | + } elseif ($field_obj instanceof \EE_Datetime_Field && |
|
86 | + $original_value instanceof \DateTime) { |
|
87 | + $new_value = $original_value->format('c'); |
|
88 | + $new_value = mysql_to_rfc3339($new_value); |
|
89 | 89 | } else { |
90 | 90 | $new_value = $original_value; |
91 | 91 | } |
92 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
92 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\Model_Data_Translator__prepare_field_for_rest_api', |
|
93 | 93 | $new_value, |
94 | 94 | $field_obj, |
95 | 95 | $original_value, |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | * @param string $requested_version |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - public static function prepare_conditions_query_params_for_models( $inputted_query_params_of_this_type, \EEM_Base $model, $requested_version ) { |
|
108 | + public static function prepare_conditions_query_params_for_models($inputted_query_params_of_this_type, \EEM_Base $model, $requested_version) { |
|
109 | 109 | $query_param_for_models = array(); |
110 | - foreach( $inputted_query_params_of_this_type as $query_param_key => $query_param_value ) { |
|
110 | + foreach ($inputted_query_params_of_this_type as $query_param_key => $query_param_value) { |
|
111 | 111 | $field = self::deduce_field_from_query_param( |
112 | - self::remove_stars_and_anything_after_from_condition_query_param_key( $query_param_key ), |
|
112 | + self::remove_stars_and_anything_after_from_condition_query_param_key($query_param_key), |
|
113 | 113 | $model |
114 | 114 | ); |
115 | - if( $field instanceof \EE_Model_Field_Base ) { |
|
115 | + if ($field instanceof \EE_Model_Field_Base) { |
|
116 | 116 | //did they specify an operator? |
117 | - if( is_array( $query_param_value ) ) { |
|
118 | - $op = $query_param_value[ 0 ]; |
|
119 | - $value = $query_param_value[ 1 ]; |
|
120 | - $new_value = self::prepare_field_values_from_json( $field, $value, $requested_version ); |
|
121 | - $translated_value = array( $op, $new_value ); |
|
117 | + if (is_array($query_param_value)) { |
|
118 | + $op = $query_param_value[0]; |
|
119 | + $value = $query_param_value[1]; |
|
120 | + $new_value = self::prepare_field_values_from_json($field, $value, $requested_version); |
|
121 | + $translated_value = array($op, $new_value); |
|
122 | 122 | } else { |
123 | - $translated_value = self::prepare_field_value_from_json( $field, $query_param_value, $requested_version ); |
|
123 | + $translated_value = self::prepare_field_value_from_json($field, $query_param_value, $requested_version); |
|
124 | 124 | } |
125 | - $query_param_for_models[ $query_param_key ] = $translated_value; |
|
125 | + $query_param_for_models[$query_param_key] = $translated_value; |
|
126 | 126 | } else { |
127 | 127 | //so it's not for a field, assume it's a logic query param key |
128 | - $query_param_for_models[ $query_param_key ] = self::prepare_conditions_query_params_for_models( $query_param_value, $model, $requested_version ); |
|
128 | + $query_param_for_models[$query_param_key] = self::prepare_conditions_query_params_for_models($query_param_value, $model, $requested_version); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | return $query_param_for_models; |
132 | 132 | } |
133 | 133 | |
134 | - public static function remove_stars_and_anything_after_from_condition_query_param_key( $condition_query_param_key ) { |
|
134 | + public static function remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) { |
|
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | - if($pos_of_star === FALSE){ |
|
136 | + if ($pos_of_star === FALSE) { |
|
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else { |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -147,26 +147,26 @@ discard block |
||
147 | 147 | * @throws EE_Error |
148 | 148 | * @return EE_Model_Field_Base |
149 | 149 | */ |
150 | - public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model){ |
|
150 | + public static function deduce_field_from_query_param($query_param_name, \EEM_Base $model) { |
|
151 | 151 | //ok, now proceed with deducing which part is the model's name, and which is the field's name |
152 | 152 | //which will help us find the database table and column |
153 | 153 | |
154 | - $query_param_parts = explode(".",$query_param_name); |
|
155 | - if(empty($query_param_parts)){ |
|
156 | - throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name)); |
|
154 | + $query_param_parts = explode(".", $query_param_name); |
|
155 | + if (empty($query_param_parts)) { |
|
156 | + throw new \EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name)); |
|
157 | 157 | } |
158 | 158 | $number_of_parts = count($query_param_parts); |
159 | - $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
|
160 | - if($number_of_parts == 1){ |
|
159 | + $last_query_param_part = $query_param_parts[count($query_param_parts) - 1]; |
|
160 | + if ($number_of_parts == 1) { |
|
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else {// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | - $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
|
165 | + $model = \EE_Registry::instance()->load_model($query_param_parts[$number_of_parts - 2]); |
|
166 | 166 | } |
167 | - try{ |
|
167 | + try { |
|
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch (\EE_Error $e) { |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | $pos_of_star = strpos($condition_query_param_key, '*'); |
136 | 136 | if($pos_of_star === FALSE){ |
137 | 137 | return $condition_query_param_key; |
138 | - }else{ |
|
138 | + } else{ |
|
139 | 139 | $condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star); |
140 | 140 | return $condition_query_param_sans_star; |
141 | 141 | } |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | $last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ]; |
160 | 160 | if($number_of_parts == 1){ |
161 | 161 | $field_name = $last_query_param_part; |
162 | - }else{// $number_of_parts >= 2 |
|
162 | + } else{// $number_of_parts >= 2 |
|
163 | 163 | //the last part is the column name, and there are only 2parts. therefore... |
164 | 164 | $field_name = $last_query_param_part; |
165 | 165 | $model = \EE_Registry::instance()->load_model( $query_param_parts[ $number_of_parts - 2 ]); |
166 | 166 | } |
167 | 167 | try{ |
168 | 168 | return $model->field_settings_for($field_name); |
169 | - }catch(\EE_Error $e){ |
|
169 | + } catch(\EE_Error $e){ |
|
170 | 170 | return null; |
171 | 171 | } |
172 | 172 | } |
@@ -1,24 +1,24 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api; |
3 | 3 | /** |
4 | - * |
|
5 | - * Class Model_Data_Translator |
|
6 | - * |
|
7 | - * Class for translating data between the EE4 models and JSON. |
|
8 | - * Some of this class needs to interpret an incoming array of query params from |
|
9 | - * the REST API and prepare it for use by the models. Some of this code seems duplicated |
|
10 | - * fromt he models but it's anticipated to diverge (because providing parameters |
|
11 | - * in the REST API is sometimes more difficult than in PHP directly. Eg, providing an array like |
|
12 | - * array( 'where' => array( 'EVT_ID' => array( '<', 100 ) ) ) in PHP is easy, but in a querystring it needs to look like |
|
13 | - * "where[EVT_ID][]=<&where[EVT_ID][]=100" is less intuitive, so we may want |
|
14 | - * to allow REST API query parameters to diverge from the format accepted by models) |
|
15 | - * |
|
16 | - * @package Event Espresso |
|
17 | - * @subpackage |
|
18 | - * @author Mike Nelson |
|
19 | - * @since 4.8.36 |
|
20 | - * |
|
21 | - */ |
|
4 | + * |
|
5 | + * Class Model_Data_Translator |
|
6 | + * |
|
7 | + * Class for translating data between the EE4 models and JSON. |
|
8 | + * Some of this class needs to interpret an incoming array of query params from |
|
9 | + * the REST API and prepare it for use by the models. Some of this code seems duplicated |
|
10 | + * fromt he models but it's anticipated to diverge (because providing parameters |
|
11 | + * in the REST API is sometimes more difficult than in PHP directly. Eg, providing an array like |
|
12 | + * array( 'where' => array( 'EVT_ID' => array( '<', 100 ) ) ) in PHP is easy, but in a querystring it needs to look like |
|
13 | + * "where[EVT_ID][]=<&where[EVT_ID][]=100" is less intuitive, so we may want |
|
14 | + * to allow REST API query parameters to diverge from the format accepted by models) |
|
15 | + * |
|
16 | + * @package Event Espresso |
|
17 | + * @subpackage |
|
18 | + * @author Mike Nelson |
|
19 | + * @since 4.8.36 |
|
20 | + * |
|
21 | + */ |
|
22 | 22 | |
23 | 23 | |
24 | 24 | if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * Prepares a field's value for display in the API |
|
78 | - * @param \EE_Model_Field_Base $field_obj |
|
79 | - * @param mixed $original_value |
|
80 | - * @return mixed |
|
81 | - */ |
|
77 | + * Prepares a field's value for display in the API |
|
78 | + * @param \EE_Model_Field_Base $field_obj |
|
79 | + * @param mixed $original_value |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | 82 | public static function prepare_field_value_for_json( $field_obj, $original_value, $requested_version ) { |
83 | 83 | if( $original_value === EE_INF ) { |
84 | 84 | $new_value = self::ee_inf_in_rest; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $original_value, |
96 | 96 | $requested_version |
97 | 97 | ); |
98 | - } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Prepares condition-query-parameters (like what's in where and having) from |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers\model; |
3 | 3 | use EventEspresso\core\libraries\rest_api\Model_Data_Translator; |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * @param \WP_REST_Request $request |
24 | 24 | * @return array|\WP_REST_Response |
25 | 25 | */ |
26 | - public static function handle_request_models_meta( \WP_REST_Request $request ) { |
|
26 | + public static function handle_request_models_meta(\WP_REST_Request $request) { |
|
27 | 27 | $controller = new Meta(); |
28 | - try{ |
|
28 | + try { |
|
29 | 29 | $matches = $controller->parse_route( |
30 | 30 | $request->get_route(), |
31 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . 'resources~', |
|
32 | - array( 'version' ) ); |
|
33 | - if( $matches instanceof \WP_REST_Response ) { |
|
31 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'resources~', |
|
32 | + array('version') ); |
|
33 | + if ($matches instanceof \WP_REST_Response) { |
|
34 | 34 | return $matches; |
35 | 35 | } |
36 | - $controller->set_requested_version( $matches[ 'version' ] ); |
|
37 | - return $controller->send_response( $controller->_get_models_metadata_entity() ); |
|
38 | - } catch( \Exception $e ) { |
|
39 | - return $controller->send_response( $e ); |
|
36 | + $controller->set_requested_version($matches['version']); |
|
37 | + return $controller->send_response($controller->_get_models_metadata_entity()); |
|
38 | + } catch (\Exception $e) { |
|
39 | + return $controller->send_response($e); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -44,22 +44,22 @@ discard block |
||
44 | 44 | * Gets the model metadata resource entity |
45 | 45 | * @return array for JSON response, describing all the models available in teh requested version |
46 | 46 | */ |
47 | - protected function _get_models_metadata_entity(){ |
|
47 | + protected function _get_models_metadata_entity() { |
|
48 | 48 | $response = array(); |
49 | - foreach( $this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname ){ |
|
50 | - $model = $this->get_model_version_info()->load_model( $model_name ); |
|
49 | + foreach ($this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname) { |
|
50 | + $model = $this->get_model_version_info()->load_model($model_name); |
|
51 | 51 | $fields_json = array(); |
52 | - foreach( $this->get_model_version_info()->fields_on_model_in_this_version( $model ) as $field_name => $field_obj ) { |
|
53 | - if( $this->get_model_version_info()->field_is_ignored( $field_obj ) ) { |
|
52 | + foreach ($this->get_model_version_info()->fields_on_model_in_this_version($model) as $field_name => $field_obj) { |
|
53 | + if ($this->get_model_version_info()->field_is_ignored($field_obj)) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | - if( $field_obj instanceof \EE_Boolean_Field ) { |
|
56 | + if ($field_obj instanceof \EE_Boolean_Field) { |
|
57 | 57 | $datatype = 'Boolean'; |
58 | - }elseif( $field_obj->get_wpdb_data_type() == '%d' ) { |
|
58 | + }elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
59 | 59 | $datatype = 'Number'; |
60 | - }elseif( $field_name instanceof \EE_Serialized_Text_Field ) { |
|
60 | + }elseif ($field_name instanceof \EE_Serialized_Text_Field) { |
|
61 | 61 | $datatype = 'Object'; |
62 | - }else{ |
|
62 | + } else { |
|
63 | 63 | $datatype = 'String'; |
64 | 64 | } |
65 | 65 | $default_value = Model_Data_Translator::prepare_field_value_for_json( |
@@ -70,30 +70,30 @@ discard block |
||
70 | 70 | $field_json = array( |
71 | 71 | 'name' => $field_name, |
72 | 72 | 'nicename' => $field_obj->get_nicename(), |
73 | - 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format( $field_obj ), |
|
74 | - 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format( $field_obj ), |
|
75 | - 'type' => str_replace('EE_', '', get_class( $field_obj ) ), |
|
73 | + 'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format($field_obj), |
|
74 | + 'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format($field_obj), |
|
75 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
76 | 76 | 'datatype' => $datatype, |
77 | 77 | 'nullable' => $field_obj->is_nullable(), |
78 | 78 | 'default' => $default_value, |
79 | 79 | 'table_alias' => $field_obj->get_table_alias(), |
80 | 80 | 'table_column' => $field_obj->get_table_column(), |
81 | 81 | ); |
82 | - $fields_json[ $field_json[ 'name' ] ] = $field_json; |
|
82 | + $fields_json[$field_json['name']] = $field_json; |
|
83 | 83 | |
84 | 84 | } |
85 | - $fields_json = array_merge( $fields_json, $this->get_model_version_info()->extra_resource_properties_for_model( $model ) ); |
|
86 | - $response[ $model_name ]['fields'] = apply_filters( 'FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model ); |
|
85 | + $fields_json = array_merge($fields_json, $this->get_model_version_info()->extra_resource_properties_for_model($model)); |
|
86 | + $response[$model_name]['fields'] = apply_filters('FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model); |
|
87 | 87 | $relations_json = array(); |
88 | - foreach( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
88 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
89 | 89 | $relation_json = array( |
90 | 90 | 'name' => $relation_name, |
91 | - 'type' => str_replace( 'EE_', '', get_class( $relation_obj ) ), |
|
91 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
92 | 92 | 'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false, |
93 | 93 | ); |
94 | - $relations_json[ $relation_name ] = $relation_json; |
|
94 | + $relations_json[$relation_name] = $relation_json; |
|
95 | 95 | } |
96 | - $response[ $model_name ][ 'relations' ] = apply_filters( 'FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model ); |
|
96 | + $response[$model_name]['relations'] = apply_filters('FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model); |
|
97 | 97 | } |
98 | 98 | return $response; |
99 | 99 | } |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @param \WP_REST_Response $rest_response_obj |
104 | 104 | * @return \WP_REST_Response |
105 | 105 | */ |
106 | - public static function filter_ee_metadata_into_index( \WP_REST_Response $rest_response_obj ) { |
|
106 | + public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj) { |
|
107 | 107 | $response_data = $rest_response_obj->get_data(); |
108 | 108 | $addons = array(); |
109 | - foreach( \EE_Registry::instance()->addons as $addon){ |
|
109 | + foreach (\EE_Registry::instance()->addons as $addon) { |
|
110 | 110 | $addon_json = array( |
111 | 111 | 'name' => $addon->name(), |
112 | 112 | 'version' => $addon->version() |
113 | 113 | ); |
114 | - $addons[ $addon_json[ 'name' ] ] = $addon_json; |
|
114 | + $addons[$addon_json['name']] = $addon_json; |
|
115 | 115 | } |
116 | - $response_data[ 'ee' ] = array( |
|
116 | + $response_data['ee'] = array( |
|
117 | 117 | 'version' => \EEM_System_Status::instance()->get_ee_version(), |
118 | 118 | 'addons' => $addons, |
119 | 119 | 'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(), |
120 | - 'served_core_versions' => array_keys( \EED_Core_Rest_Api::versions_served() ) |
|
120 | + 'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served()) |
|
121 | 121 | ); |
122 | - $rest_response_obj->set_data( $response_data ); |
|
122 | + $rest_response_obj->set_data($response_data); |
|
123 | 123 | return $rest_response_obj; |
124 | 124 | } |
125 | 125 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\controllers; |
3 | 3 | use EventEspresso\core\libraries\rest_api\Rest_Exception; |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | public function __construct() { |
52 | - $this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false; |
|
52 | + $this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Sets the version the user requested |
58 | 58 | * @param string $version eg '4.8' |
59 | 59 | */ |
60 | - public function set_requested_version( $version ) { |
|
60 | + public function set_requested_version($version) { |
|
61 | 61 | $this->_requested_version = $version; |
62 | 62 | } |
63 | 63 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @param string $key |
67 | 67 | * @param string|array $info |
68 | 68 | */ |
69 | - protected function _set_debug_info( $key, $info ){ |
|
70 | - $this->_debug_info[ $key ] = $info; |
|
69 | + protected function _set_debug_info($key, $info) { |
|
70 | + $this->_debug_info[$key] = $info; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @param boolean $use_ee_prefix whether to use the EE prefix on the header, or fallback to |
80 | 80 | * the standard WP one |
81 | 81 | */ |
82 | - protected function _set_response_header( $header_key, $value, $use_ee_prefix = true ) { |
|
83 | - if( is_array( $value ) ) { |
|
84 | - foreach( $value as $value_key => $value_value ) { |
|
85 | - $this->_set_response_header( $header_key . '[' . $value_key . ']', $value_value ); |
|
82 | + protected function _set_response_header($header_key, $value, $use_ee_prefix = true) { |
|
83 | + if (is_array($value)) { |
|
84 | + foreach ($value as $value_key => $value_value) { |
|
85 | + $this->_set_response_header($header_key.'['.$value_key.']', $value_value); |
|
86 | 86 | } |
87 | 87 | } else { |
88 | 88 | $prefix = $use_ee_prefix ? Base::header_prefix_for_ee : Base::header_prefix_for_wp; |
89 | - $this->_response_headers[ $prefix . $header_key ] = $value; |
|
89 | + $this->_response_headers[$prefix.$header_key] = $value; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return array |
96 | 96 | */ |
97 | 97 | protected function _get_response_headers() { |
98 | - return apply_filters( 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
98 | + return apply_filters('FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_response_headers', |
|
99 | 99 | $this->_response_headers, |
100 | 100 | $this, |
101 | 101 | $this->_requested_version |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | * @param \WP_Error $wp_error_response |
108 | 108 | * @return \WP_Error |
109 | 109 | */ |
110 | - protected function _add_ee_errors_to_response( \WP_Error $wp_error_response ) { |
|
110 | + protected function _add_ee_errors_to_response(\WP_Error $wp_error_response) { |
|
111 | 111 | $notices_during_checkin = \EE_Error::get_raw_notices(); |
112 | - if( ! empty( $notices_during_checkin[ 'errors' ] ) ) { |
|
113 | - foreach( $notices_during_checkin[ 'errors' ] as $error_code => $error_message ) { |
|
112 | + if ( ! empty($notices_during_checkin['errors'])) { |
|
113 | + foreach ($notices_during_checkin['errors'] as $error_code => $error_message) { |
|
114 | 114 | $wp_error_response->add( |
115 | - sanitize_key( $error_code ), |
|
116 | - strip_tags( $error_message ) ); |
|
115 | + sanitize_key($error_code), |
|
116 | + strip_tags($error_message) ); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | return $wp_error_response; |
@@ -131,27 +131,27 @@ discard block |
||
131 | 131 | * @param array|\WP_Error|\Exception $response |
132 | 132 | * @return \WP_REST_Response |
133 | 133 | */ |
134 | - public function send_response( $response ) { |
|
135 | - if( $response instanceof Rest_Exception ) { |
|
136 | - $response = new \WP_Error( $response->get_string_code(), $response->getMessage(), $response->get_data() ); |
|
134 | + public function send_response($response) { |
|
135 | + if ($response instanceof Rest_Exception) { |
|
136 | + $response = new \WP_Error($response->get_string_code(), $response->getMessage(), $response->get_data()); |
|
137 | 137 | } |
138 | - if( $response instanceof \Exception ) { |
|
138 | + if ($response instanceof \Exception) { |
|
139 | 139 | $code = $response->getCode() ? $response->getCode() : 'error_occurred'; |
140 | - $response = new \WP_Error( $code, $response->getMessage() ); |
|
140 | + $response = new \WP_Error($code, $response->getMessage()); |
|
141 | 141 | } |
142 | - if( $response instanceof \WP_Error ) { |
|
143 | - $response = $this->_add_ee_errors_to_response( $response ); |
|
144 | - $rest_response = $this->_create_rest_response_from_wp_error( $response ); |
|
145 | - }else{ |
|
146 | - $rest_response = new \WP_REST_Response( $response, 200 ); |
|
142 | + if ($response instanceof \WP_Error) { |
|
143 | + $response = $this->_add_ee_errors_to_response($response); |
|
144 | + $rest_response = $this->_create_rest_response_from_wp_error($response); |
|
145 | + } else { |
|
146 | + $rest_response = new \WP_REST_Response($response, 200); |
|
147 | 147 | } |
148 | 148 | $headers = array(); |
149 | - if( $this->_debug_mode && is_array( $this->_debug_info ) ) { |
|
150 | - foreach( $this->_debug_info as $debug_key => $debug_info ) { |
|
151 | - if( is_array( $debug_info ) ) { |
|
152 | - $debug_info = json_encode( $debug_info ); |
|
149 | + if ($this->_debug_mode && is_array($this->_debug_info)) { |
|
150 | + foreach ($this->_debug_info as $debug_key => $debug_info) { |
|
151 | + if (is_array($debug_info)) { |
|
152 | + $debug_info = json_encode($debug_info); |
|
153 | 153 | } |
154 | - $headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info; |
|
154 | + $headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info; |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | $headers = array_merge( |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $this->_get_headers_from_ee_notices() |
161 | 161 | ); |
162 | 162 | |
163 | - $rest_response->set_headers( $headers ); |
|
163 | + $rest_response->set_headers($headers); |
|
164 | 164 | return $rest_response; |
165 | 165 | } |
166 | 166 | |
@@ -171,31 +171,31 @@ discard block |
||
171 | 171 | * @param \WP_Error $wp_error |
172 | 172 | * @return \WP_REST_Response |
173 | 173 | */ |
174 | - protected function _create_rest_response_from_wp_error( \WP_Error $wp_error ) { |
|
174 | + protected function _create_rest_response_from_wp_error(\WP_Error $wp_error) { |
|
175 | 175 | $error_data = $wp_error->get_error_data(); |
176 | - if ( is_array( $error_data ) && isset( $error_data['status'] ) ) { |
|
176 | + if (is_array($error_data) && isset($error_data['status'])) { |
|
177 | 177 | $status = $error_data['status']; |
178 | 178 | } else { |
179 | 179 | $status = 500; |
180 | 180 | } |
181 | 181 | |
182 | 182 | $errors = array(); |
183 | - foreach ( (array) $wp_error->errors as $code => $messages ) { |
|
184 | - foreach ( (array) $messages as $message ) { |
|
183 | + foreach ((array) $wp_error->errors as $code => $messages) { |
|
184 | + foreach ((array) $messages as $message) { |
|
185 | 185 | $errors[] = array( |
186 | 186 | 'code' => $code, |
187 | 187 | 'message' => $message, |
188 | - 'data' => $wp_error->get_error_data( $code ) |
|
188 | + 'data' => $wp_error->get_error_data($code) |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | } |
192 | - $data = isset( $errors[0] ) ? $errors[0] : array(); |
|
193 | - if ( count( $errors ) > 1 ) { |
|
192 | + $data = isset($errors[0]) ? $errors[0] : array(); |
|
193 | + if (count($errors) > 1) { |
|
194 | 194 | // Remove the primary error. |
195 | - array_shift( $errors ); |
|
195 | + array_shift($errors); |
|
196 | 196 | $data['additional_errors'] = $errors; |
197 | 197 | } |
198 | - return new \WP_REST_Response( $data, $status ); |
|
198 | + return new \WP_REST_Response($data, $status); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | protected function _get_headers_from_ee_notices() { |
206 | 206 | $headers = array(); |
207 | 207 | $notices = \EE_Error::get_raw_notices(); |
208 | - foreach( $notices as $notice_type => $sub_notices ) { |
|
209 | - if( ! is_array( $sub_notices ) ) { |
|
208 | + foreach ($notices as $notice_type => $sub_notices) { |
|
209 | + if ( ! is_array($sub_notices)) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - foreach( $sub_notices as $notice_code => $sub_notice ) { |
|
213 | - $headers[ 'X-EE4-Notices-' . \EEH_Inflector::humanize( $notice_type ) . '[' . $notice_code . ']' ] = strip_tags( $sub_notice ); |
|
212 | + foreach ($sub_notices as $notice_code => $sub_notice) { |
|
213 | + $headers['X-EE4-Notices-'.\EEH_Inflector::humanize($notice_type).'['.$notice_code.']'] = strip_tags($sub_notice); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | return apply_filters( |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * @param string $route |
229 | 229 | * @return string |
230 | 230 | */ |
231 | - public function get_requested_version( $route = null ) { |
|
231 | + public function get_requested_version($route = null) { |
|
232 | 232 | $matches = $this->parse_route( |
233 | 233 | $route, |
234 | - '~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '~', |
|
235 | - array( 'version' ) |
|
234 | + '~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'~', |
|
235 | + array('version') |
|
236 | 236 | ); |
237 | - if( isset( $matches[ 'version' ] ) ) { |
|
238 | - return $matches[ 'version' ]; |
|
237 | + if (isset($matches['version'])) { |
|
238 | + return $matches['version']; |
|
239 | 239 | } else { |
240 | 240 | return \EED_Core_Rest_Api::latest_rest_api_version(); |
241 | 241 | } |
@@ -260,23 +260,23 @@ discard block |
||
260 | 260 | * array( 'model' => 'foo', 'id' => 'bar' ) |
261 | 261 | * @throws \EE_Error if it couldn't be parsed |
262 | 262 | */ |
263 | - public function parse_route( $route, $regex, $match_keys ) { |
|
263 | + public function parse_route($route, $regex, $match_keys) { |
|
264 | 264 | $indexed_matches = array(); |
265 | - $success = preg_match( $regex, $route, $matches ); |
|
266 | - if( |
|
267 | - is_array( $matches ) ) { |
|
265 | + $success = preg_match($regex, $route, $matches); |
|
266 | + if ( |
|
267 | + is_array($matches) ) { |
|
268 | 268 | //skip the overall regex match. Who cares |
269 | - for( $i = 1; $i <= count( $match_keys ); $i++ ) { |
|
270 | - if( ! isset( $matches[ $i ] ) ) { |
|
269 | + for ($i = 1; $i <= count($match_keys); $i++) { |
|
270 | + if ( ! isset($matches[$i])) { |
|
271 | 271 | $success = false; |
272 | 272 | } else { |
273 | - $indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ]; |
|
273 | + $indexed_matches[$match_keys[$i - 1]] = $matches[$i]; |
|
274 | 274 | } |
275 | 275 | } |
276 | 276 | } |
277 | - if( ! $success ) { |
|
277 | + if ( ! $success) { |
|
278 | 278 | throw new \EE_Error( |
279 | - __( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ), |
|
279 | + __('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'), |
|
280 | 280 | 'endpoint_parsing_error' |
281 | 281 | ); |
282 | 282 | } |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Base { |
21 | - protected static function _verify_current_user_can( $required_permission, $attempted_calculation ) { |
|
22 | - if( ! current_user_can( $required_permission ) ) { |
|
21 | + protected static function _verify_current_user_can($required_permission, $attempted_calculation) { |
|
22 | + if ( ! current_user_can($required_permission)) { |
|
23 | 23 | throw new Rest_Exception( |
24 | 24 | 'permission_denied', |
25 | 25 | sprintf( |
26 | - __( 'Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso' ), |
|
26 | + __('Permission denied, you cannot calculate %1$s on %2$s because you do not have the capability "%3$s"', 'event_espresso'), |
|
27 | 27 | $attempted_calculation, |
28 | - \EEH_Inflector::pluralize_and_lower( self::get_resource_name() ), |
|
28 | + \EEH_Inflector::pluralize_and_lower(self::get_resource_name()), |
|
29 | 29 | $required_permission |
30 | 30 | ) |
31 | 31 | ); |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public static function get_resource_name() { |
40 | 40 | $classname = get_called_class(); |
41 | - return substr( $classname, strrpos( $classname, '\\' ) + 1 ); |
|
41 | + return substr($classname, strrpos($classname, '\\') + 1); |
|
42 | 42 | } |
43 | 43 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | * @since 4.8.35.rc.001 |
16 | 16 | * |
17 | 17 | */ |
18 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
19 | - exit( 'No direct script access allowed' ); |
|
18 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
19 | + exit('No direct script access allowed'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class Calculated_Model_Fields { |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * the WP_Request object, |
39 | 39 | * the controller object |
40 | 40 | */ |
41 | - public function mapping( $refresh = false ) { |
|
42 | - if( ! $this->_mapping || $refresh ) { |
|
41 | + public function mapping($refresh = false) { |
|
42 | + if ( ! $this->_mapping || $refresh) { |
|
43 | 43 | $this->_mapping = $this->_generate_new_mapping(); |
44 | 44 | } |
45 | 45 | return $this->_mapping; |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | */ |
53 | 53 | protected function _generate_new_mapping() { |
54 | 54 | $rest_api_calculations_namespace = 'EventEspresso\core\libraries\rest_api\calculations\\'; |
55 | - $event_calculations_class = $rest_api_calculations_namespace . 'Event'; |
|
56 | - $datetime_calculations_class = $rest_api_calculations_namespace . 'Datetime'; |
|
55 | + $event_calculations_class = $rest_api_calculations_namespace.'Event'; |
|
56 | + $datetime_calculations_class = $rest_api_calculations_namespace.'Datetime'; |
|
57 | 57 | return apply_filters( |
58 | 58 | 'FHEE__EventEspresso\core\libraries\rest_api\Calculated_Model_Fields__mapping', |
59 | 59 | array( |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @param \EEM_Base $model |
82 | 82 | * @return array allowable values for this field |
83 | 83 | */ |
84 | - public function retrieve_calculated_fields_for_model( \EEM_Base $model ) { |
|
84 | + public function retrieve_calculated_fields_for_model(\EEM_Base $model) { |
|
85 | 85 | $mapping = $this->mapping(); |
86 | - if( isset( $mapping[ $model->get_this_model_name() ] ) ) { |
|
87 | - return array_keys( $mapping[ $model->get_this_model_name() ] ); |
|
86 | + if (isset($mapping[$model->get_this_model_name()])) { |
|
87 | + return array_keys($mapping[$model->get_this_model_name()]); |
|
88 | 88 | } else { |
89 | 89 | return array(); |
90 | 90 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @return mixed|null |
104 | 104 | * @throws \EE_Error |
105 | 105 | */ |
106 | - public function retrieve_calculated_field_value( \EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller ) { |
|
106 | + public function retrieve_calculated_field_value(\EEM_Base $model, $field_name, $wpdb_row, $rest_request, Base $controller) { |
|
107 | 107 | $mapping = $this->mapping(); |
108 | - if( isset( $mapping[ $model->get_this_model_name() ] ) |
|
109 | - && isset( $mapping[ $model->get_this_model_name() ][ $field_name ] ) ) { |
|
110 | - $classname = $mapping[ $model->get_this_model_name() ][ $field_name ]; |
|
111 | - return call_user_func( array( $classname, $field_name ), $wpdb_row, $rest_request, $controller ); |
|
108 | + if (isset($mapping[$model->get_this_model_name()]) |
|
109 | + && isset($mapping[$model->get_this_model_name()][$field_name])) { |
|
110 | + $classname = $mapping[$model->get_this_model_name()][$field_name]; |
|
111 | + return call_user_func(array($classname, $field_name), $wpdb_row, $rest_request, $controller); |
|
112 | 112 | } |
113 | 113 | throw new Rest_Exception( |
114 | 114 | 'calculated_field_does_not_exist', |
115 | 115 | sprintf( |
116 | - __( 'There is no calculated field %1$s on resource %2$s', 'event_espresso' ), |
|
116 | + __('There is no calculated field %1$s on resource %2$s', 'event_espresso'), |
|
117 | 117 | $field_name, |
118 | 118 | $model->get_this_model_name() |
119 | 119 | ) |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | * @since $VID:$ |
14 | 14 | * |
15 | 15 | */ |
16 | -if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
17 | - exit( 'No direct script access allowed' ); |
|
16 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
17 | + exit('No direct script access allowed'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | class Rest_Exception extends \EE_Error { |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | protected $_wp_error_data = array(); |
26 | 26 | protected $_wp_error_code = ''; |
27 | - public function __construct( $string_code, $message, $wp_error_data = array(), $previous = null ) { |
|
27 | + public function __construct($string_code, $message, $wp_error_data = array(), $previous = null) { |
|
28 | 28 | parent::__construct( |
29 | 29 | $message, |
30 | 30 | 500, |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\rest_api\helpers; |
3 | 3 | /** |
4 | - * |
|
5 | - * Class Exception |
|
6 | - * |
|
7 | - * similar to EE's EE_Error, except has space to hold the "data" we |
|
8 | - * want to eventually pass to WP_Error |
|
9 | - * |
|
10 | - * @package Event Espresso |
|
11 | - * @subpackage |
|
12 | - * @author Mike Nelson |
|
13 | - * @since $VID:$ |
|
14 | - * |
|
15 | - */ |
|
4 | + * |
|
5 | + * Class Exception |
|
6 | + * |
|
7 | + * similar to EE's EE_Error, except has space to hold the "data" we |
|
8 | + * want to eventually pass to WP_Error |
|
9 | + * |
|
10 | + * @package Event Espresso |
|
11 | + * @subpackage |
|
12 | + * @author Mike Nelson |
|
13 | + * @since $VID:$ |
|
14 | + * |
|
15 | + */ |
|
16 | 16 | if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
17 | 17 | exit( 'No direct script access allowed' ); |
18 | 18 | } |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | |
43 | 43 | public function __construct() { |
44 | 44 | // construct request stack and run middleware apps as soon as all WP plugins are loaded |
45 | - add_action( 'plugins_loaded', array( $this, 'run_request_stack' ), 0 ); |
|
45 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
46 | 46 | // set framework for the rest of EE to hook into when loading |
47 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_espresso_addons' ), 1 ); |
|
48 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'detect_activations_or_upgrades' ), 3 ); |
|
49 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'load_core_configuration' ), 5 ); |
|
50 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'register_shortcodes_modules_and_widgets' ), 7 ); |
|
51 | - add_action( 'plugins_loaded', array( 'EE_Bootstrap', 'brew_espresso' ), 9 ); |
|
47 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
48 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
49 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
50 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
51 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | new EE_Load_Espresso_Core() |
66 | 66 | ); |
67 | 67 | $this->_request_stack->handle_request( |
68 | - new EE_Request( $_GET, $_POST, $_COOKIE ), |
|
68 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
69 | 69 | new EE_Response() |
70 | 70 | ); |
71 | 71 | $this->_request_stack->handle_response(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | protected function load_autoloader() { |
80 | 80 | // load interfaces |
81 | - espresso_load_required( 'EEH_Autoloader', EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' ); |
|
81 | + espresso_load_required('EEH_Autoloader', EE_CORE.'helpers'.DS.'EEH_Autoloader.helper.php'); |
|
82 | 82 | EEH_Autoloader::instance(); |
83 | 83 | } |
84 | 84 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | */ |
90 | 90 | protected function set_autoloaders_for_required_files() { |
91 | 91 | // load interfaces |
92 | - espresso_load_required( 'EEI_Interfaces', EE_CORE . 'interfaces' . DS . 'EEI_Interfaces.php' ); |
|
92 | + espresso_load_required('EEI_Interfaces', EE_CORE.'interfaces'.DS.'EEI_Interfaces.php'); |
|
93 | 93 | // load helpers |
94 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_HELPERS ); |
|
94 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
95 | 95 | // load request stack |
96 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'request_stack' . DS ); |
|
96 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack'.DS); |
|
97 | 97 | // load middleware |
98 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_CORE . 'middleware' . DS ); |
|
98 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware'.DS); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -118,9 +118,9 @@ discard block |
||
118 | 118 | ) |
119 | 119 | ); |
120 | 120 | // load middleware onto stack : FILO (First In Last Out) |
121 | - foreach ( (array)$stack_apps as $stack_app ) { |
|
121 | + foreach ((array) $stack_apps as $stack_app) { |
|
122 | 122 | //$request_stack_builder->push( $stack_app ); |
123 | - $request_stack_builder->unshift( $stack_app ); |
|
123 | + $request_stack_builder->unshift($stack_app); |
|
124 | 124 | } |
125 | 125 | return apply_filters( |
126 | 126 | 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * no other logic should be performed at this point |
138 | 138 | */ |
139 | 139 | public static function load_espresso_addons() { |
140 | - do_action( 'AHEE__EE_Bootstrap__load_espresso_addons' ); |
|
140 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * we can determine if anything needs activating or upgrading |
150 | 150 | */ |
151 | 151 | public static function detect_activations_or_upgrades() { |
152 | - do_action( 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' ); |
|
152 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * we can load and set all of the system configurations |
162 | 162 | */ |
163 | 163 | public static function load_core_configuration() { |
164 | - do_action( 'AHEE__EE_Bootstrap__load_core_configuration' ); |
|
164 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * so that they are ready to be used throughout the system |
174 | 174 | */ |
175 | 175 | public static function register_shortcodes_modules_and_widgets() { |
176 | - do_action( 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' ); |
|
176 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * so let the fun begin... |
186 | 186 | */ |
187 | 187 | public static function brew_espresso() { |
188 | - do_action( 'AHEE__EE_Bootstrap__brew_espresso' ); |
|
188 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | * @param array $post |
61 | 61 | * @param array $cookie |
62 | 62 | */ |
63 | - public function __construct( $get, $post, $cookie ) { |
|
63 | + public function __construct($get, $post, $cookie) { |
|
64 | 64 | // grab request vars |
65 | 65 | $this->_get = $get; |
66 | 66 | $this->_post = $post; |
67 | 67 | $this->_cookie = $cookie; |
68 | - $this->_params = array_merge( $get, $post ); |
|
68 | + $this->_params = array_merge($get, $post); |
|
69 | 69 | // AJAX ??? |
70 | - $this->ajax = defined( 'DOING_AJAX' ) ? true : false; |
|
71 | - $this->front_ajax = $this->is_set( 'ee_front_ajax' ) && $this->get( 'ee_front_ajax' ) == 1 ? true : false; |
|
70 | + $this->ajax = defined('DOING_AJAX') ? true : false; |
|
71 | + $this->front_ajax = $this->is_set('ee_front_ajax') && $this->get('ee_front_ajax') == 1 ? true : false; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | * @param bool $override_ee |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function set( $key, $value, $override_ee = FALSE ) { |
|
122 | + public function set($key, $value, $override_ee = FALSE) { |
|
123 | 123 | // don't allow "ee" to be overwritten unless explicitly instructed to do so |
124 | - if ( $key != 'ee' || ( $key == 'ee' && empty( $this->_params['ee'] )) || ( $key == 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )) { |
|
125 | - $this->_params[ $key ] = $value; |
|
124 | + if ($key != 'ee' || ($key == 'ee' && empty($this->_params['ee'])) || ($key == 'ee' && ! empty($this->_params['ee']) && $override_ee)) { |
|
125 | + $this->_params[$key] = $value; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * @param null $default |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get( $key, $default = NULL ) { |
|
140 | - return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default; |
|
139 | + public function get($key, $default = NULL) { |
|
140 | + return isset($this->_params[$key]) ? $this->_params[$key] : $default; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | * @param $key |
150 | 150 | * @return boolean |
151 | 151 | */ |
152 | - public function is_set( $key ) { |
|
153 | - return isset( $this->_params[ $key ] ) ? TRUE : FALSE; |
|
152 | + public function is_set($key) { |
|
153 | + return isset($this->_params[$key]) ? TRUE : FALSE; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * @param $key |
163 | 163 | * @param bool $unset_from_global_too |
164 | 164 | */ |
165 | - public function un_set( $key, $unset_from_global_too = false ) { |
|
166 | - unset( $this->_params[ $key ] ); |
|
167 | - if ( $unset_from_global_too ) { |
|
168 | - unset( $_REQUEST[ $key ] ); |
|
165 | + public function un_set($key, $unset_from_global_too = false) { |
|
166 | + unset($this->_params[$key]); |
|
167 | + if ($unset_from_global_too) { |
|
168 | + unset($_REQUEST[$key]); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 |