@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
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 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * Loads all the hooks which make requests to old versions of the API |
88 | 88 | * appear the same as they always did |
89 | 89 | */ |
90 | - public static function set_hooks_for_changes(){ |
|
90 | + public static function set_hooks_for_changes() { |
|
91 | 91 | self::_set_hooks_for_changes(); |
92 | 92 | } |
93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | * replace it with application passwords. |
98 | 98 | */ |
99 | 99 | public static function maybe_notify_of_basic_auth_removal() { |
100 | - if( |
|
100 | + if ( |
|
101 | 101 | apply_filters( |
102 | 102 | 'FHEE__EED_Core_Rest_Api__maybe_notify_of_basic_auth_removal__override', |
103 | - ! isset( $_SERVER['PHP_AUTH_USER'] ) |
|
104 | - && ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) |
|
103 | + ! isset($_SERVER['PHP_AUTH_USER']) |
|
104 | + && ! isset($_SERVER['HTTP_AUTHORIZATION']) |
|
105 | 105 | ) |
106 | 106 | ) { |
107 | 107 | //sure it's a WP API request, but they aren't using basic auth, so don't bother them |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | } |
110 | 110 | //ok they're using the WP API with Basic Auth |
111 | 111 | $message = sprintf( |
112 | - __( 'We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso' ), |
|
112 | + __('We noticed you\'re using the WP API, which is used by the Event Espresso 4 mobile apps. Because of security and compatibility concerns, we will soon be removing our default authentication mechanism, WP API Basic Auth, from Event Espresso. It is recommended you instead install the %1$sWP Application Passwords plugin%2$s and use it with the EE4 Mobile apps. See %3$sour mobile app documentation%2$s for more information. %4$sIf you have installed the WP API Basic Auth plugin separately, or are not using the Event Espresso 4 mobile apps, you can disregard this message.%4$sThe Event Espresso Team', 'event_espresso'), |
|
113 | 113 | '<a href="https://wordpress.org/plugins/application-passwords/">', |
114 | 114 | '</a>', |
115 | 115 | '<a href="https://eventespresso.com/wiki/ee4-event-apps/#authentication">', |
116 | 116 | '<br/>' |
117 | 117 | ); |
118 | - EE_Error::add_persistent_admin_notice( 'using_basic_auth', $message ); |
|
119 | - if( ! get_option( 'ee_notified_admin_on_basic_auth_removal', false ) ) { |
|
120 | - add_option( 'ee_notified_admin_on_basic_auth_removal', true ); |
|
118 | + EE_Error::add_persistent_admin_notice('using_basic_auth', $message); |
|
119 | + if ( ! get_option('ee_notified_admin_on_basic_auth_removal', false)) { |
|
120 | + add_option('ee_notified_admin_on_basic_auth_removal', true); |
|
121 | 121 | //piggy back off EE_Error::set_content_type, which sets the content type to HTML |
122 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
122 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
123 | 123 | //and send the message to the site admin too |
124 | - wp_mail( get_option( 'admin_email' ), __( 'Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso' ), $message ); |
|
125 | - remove_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
124 | + wp_mail(get_option('admin_email'), __('Notice of Removal of WP API Basic Auth From Event Espresso 4', 'event_espresso'), $message); |
|
125 | + remove_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | /** |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | * appear the same as they always did |
131 | 131 | */ |
132 | 132 | protected static function _set_hooks_for_changes() { |
133 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
134 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
133 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
134 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
135 | 135 | //ignore the base parent class |
136 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
136 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
137 | 137 | continue; |
138 | 138 | } |
139 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
140 | - if ( class_exists( $full_classname )) { |
|
139 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
140 | + if (class_exists($full_classname)) { |
|
141 | 141 | $instance_of_class = new $full_classname; |
142 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
142 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
143 | 143 | $instance_of_class->set_hooks(); |
144 | 144 | } |
145 | 145 | } |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
153 | 153 | */ |
154 | 154 | public static function register_routes() { |
155 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
156 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
157 | - foreach( $routes as $route ) { |
|
155 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
156 | + foreach ($relative_urls as $endpoint => $routes) { |
|
157 | + foreach ($routes as $route) { |
|
158 | 158 | register_rest_route( |
159 | 159 | $namespace, |
160 | 160 | $endpoint, |
161 | 161 | array( |
162 | - 'callback' => $route[ 'callback' ], |
|
163 | - 'methods' => $route[ 'methods' ], |
|
164 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
162 | + 'callback' => $route['callback'], |
|
163 | + 'methods' => $route['methods'], |
|
164 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
165 | 165 | ) |
166 | 166 | ); |
167 | 167 | } |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | * next time the WP API is used |
176 | 176 | */ |
177 | 177 | public static function invalidate_cached_route_data_on_version_change() { |
178 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
178 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
179 | 179 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
180 | 180 | } |
181 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
182 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
181 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
182 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
183 | 183 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
184 | 184 | } |
185 | 185 | } |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public static function invalidate_cached_route_data() { |
192 | 192 | //delete the saved EE REST API routes |
193 | - foreach( EED_Core_Rest_Api::versions_served() as $version => $hidden ){ |
|
194 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names . $version ); |
|
193 | + foreach (EED_Core_Rest_Api::versions_served() as $version => $hidden) { |
|
194 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names.$version); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function get_ee_route_data() { |
207 | 207 | $ee_routes = array(); |
208 | - foreach( self::versions_served() as $version => $hidden_endpoints ) { |
|
209 | - $ee_routes[ self::ee_api_namespace . $version ] = self::_get_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
208 | + foreach (self::versions_served() as $version => $hidden_endpoints) { |
|
209 | + $ee_routes[self::ee_api_namespace.$version] = self::_get_ee_route_data_for_version($version, $hidden_endpoints); |
|
210 | 210 | } |
211 | 211 | return $ee_routes; |
212 | 212 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | * @param boolean $hidden_endpoints |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - protected static function _get_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
222 | - $ee_routes = get_option( self::saved_routes_option_names . $version , null ); |
|
223 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
224 | - $ee_routes = self::_save_ee_route_data_for_version( $version, $hidden_endpoints ); |
|
221 | + protected static function _get_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
222 | + $ee_routes = get_option(self::saved_routes_option_names.$version, null); |
|
223 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
224 | + $ee_routes = self::_save_ee_route_data_for_version($version, $hidden_endpoints); |
|
225 | 225 | } |
226 | 226 | return $ee_routes; |
227 | 227 | } |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param boolean $hidden_endpoints |
236 | 236 | * @return mixed|null|void |
237 | 237 | */ |
238 | - protected static function _save_ee_route_data_for_version( $version, $hidden_endpoints = false ) { |
|
238 | + protected static function _save_ee_route_data_for_version($version, $hidden_endpoints = false) { |
|
239 | 239 | $instance = self::instance(); |
240 | 240 | $routes = apply_filters( |
241 | 241 | 'EED_Core_Rest_Api__save_ee_route_data_for_version__routes', |
242 | 242 | array_replace_recursive( |
243 | - $instance->_get_config_route_data_for_version( $version, $hidden_endpoints ), |
|
244 | - $instance->_get_meta_route_data_for_version( $version, $hidden_endpoints ), |
|
245 | - $instance->_get_model_route_data_for_version( $version, $hidden_endpoints ), |
|
246 | - $instance->_get_rpc_route_data_for_version( $version, $hidden_endpoints ) |
|
243 | + $instance->_get_config_route_data_for_version($version, $hidden_endpoints), |
|
244 | + $instance->_get_meta_route_data_for_version($version, $hidden_endpoints), |
|
245 | + $instance->_get_model_route_data_for_version($version, $hidden_endpoints), |
|
246 | + $instance->_get_rpc_route_data_for_version($version, $hidden_endpoints) |
|
247 | 247 | ) |
248 | 248 | ); |
249 | - update_option( self::saved_routes_option_names . $version, $routes, true ); |
|
249 | + update_option(self::saved_routes_option_names.$version, $routes, true); |
|
250 | 250 | return $routes; |
251 | 251 | } |
252 | 252 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return void |
258 | 258 | */ |
259 | 259 | public static function save_ee_routes() { |
260 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
260 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
261 | 261 | $instance = self::instance(); |
262 | 262 | $routes = apply_filters( |
263 | 263 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $instance->_register_rpc_routes() |
269 | 269 | ) |
270 | 270 | ); |
271 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
271 | + update_option(self::saved_routes_option_names, $routes, true); |
|
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | */ |
280 | 280 | protected function _register_model_routes() { |
281 | 281 | $model_routes = array( ); |
282 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
283 | - $model_routes[ EED_Core_Rest_Api::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
282 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
283 | + $model_routes[EED_Core_Rest_Api::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
284 | 284 | } |
285 | 285 | return $model_routes; |
286 | 286 | } |
@@ -291,8 +291,8 @@ discard block |
||
291 | 291 | * @param boolean $hidden_endpoint |
292 | 292 | * @return array |
293 | 293 | */ |
294 | - protected function _get_model_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
295 | - $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info( $version ); |
|
294 | + protected function _get_model_route_data_for_version($version, $hidden_endpoint = false) { |
|
295 | + $model_version_info = new \EventEspresso\core\libraries\rest_api\Model_Version_Info($version); |
|
296 | 296 | $models_to_register = apply_filters( |
297 | 297 | 'FHEE__EED_Core_REST_API___register_model_routes', |
298 | 298 | $model_version_info->models_for_requested_version() |
@@ -301,21 +301,21 @@ discard block |
||
301 | 301 | unset($models_to_register['Extra_Meta']); |
302 | 302 | unset($models_to_register['Extra_Join']); |
303 | 303 | $model_routes = array(); |
304 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
305 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
304 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
305 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
306 | 306 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
307 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
308 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
309 | - $model_routes[ $plural_model_route ] = array( |
|
307 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
308 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
309 | + $model_routes[$plural_model_route] = array( |
|
310 | 310 | array( |
311 | 311 | 'callback' => array( |
312 | 312 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
313 | 313 | 'handle_request_get_all' ), |
314 | 314 | 'methods' => WP_REST_Server::READABLE, |
315 | 315 | 'hidden_endpoint' => $hidden_endpoint, |
316 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
316 | + 'args' => $this->_get_read_query_params($model, $version), |
|
317 | 317 | '_links' => array( |
318 | - 'self' => rest_url( EED_Core_Rest_Api::ee_api_namespace . $version . $singular_model_route ), |
|
318 | + 'self' => rest_url(EED_Core_Rest_Api::ee_api_namespace.$version.$singular_model_route), |
|
319 | 319 | ) |
320 | 320 | ), |
321 | 321 | // array( |
@@ -326,14 +326,14 @@ discard block |
||
326 | 326 | // 'hidden_endpoint' => $hidden_endpoint |
327 | 327 | // ) |
328 | 328 | ); |
329 | - $model_routes[ $singular_model_route ] = array( |
|
329 | + $model_routes[$singular_model_route] = array( |
|
330 | 330 | array( |
331 | 331 | 'callback' => array( |
332 | 332 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
333 | 333 | 'handle_request_get_one' ), |
334 | 334 | 'methods' => WP_REST_Server::READABLE, |
335 | 335 | 'hidden_endpoint' => $hidden_endpoint, |
336 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
336 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
337 | 337 | ), |
338 | 338 | // array( |
339 | 339 | // 'callback' => array( |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | // ), |
345 | 345 | ); |
346 | 346 | //@todo: also handle DELETE for a single item |
347 | - foreach ( $model_version_info->relation_settings( $model ) as $relation_name => $relation_obj ) { |
|
347 | + foreach ($model_version_info->relation_settings($model) as $relation_name => $relation_obj) { |
|
348 | 348 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
349 | 349 | $relation_name, |
350 | 350 | $relation_obj |
351 | 351 | ); |
352 | - $model_routes[ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
352 | + $model_routes[$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
353 | 353 | array( |
354 | 354 | 'callback' => array( |
355 | 355 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
356 | 356 | 'handle_request_get_related' ), |
357 | 357 | 'methods' => WP_REST_Server::READABLE, |
358 | 358 | 'hidden_endpoint' => $hidden_endpoint, |
359 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
359 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
360 | 360 | ), |
361 | 361 | // array( |
362 | 362 | // 'callback' => array( |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | */ |
380 | 380 | protected function _register_rpc_routes() { |
381 | 381 | $routes = array(); |
382 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
383 | - $routes[ self::ee_api_namespace . $version ] = $this->_get_rpc_route_data_for_version( $version, $hidden_endpoint ); |
|
382 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
383 | + $routes[self::ee_api_namespace.$version] = $this->_get_rpc_route_data_for_version($version, $hidden_endpoint); |
|
384 | 384 | } |
385 | 385 | return $routes; |
386 | 386 | } |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | * @param boolean $hidden_endpoint |
392 | 392 | * @return array |
393 | 393 | */ |
394 | - protected function _get_rpc_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
394 | + protected function _get_rpc_route_data_for_version($version, $hidden_endpoint = false) { |
|
395 | 395 | $this_versions_routes = array(); |
396 | 396 | //checkin endpoint |
397 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
397 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
398 | 398 | array( |
399 | 399 | 'callback' => array( |
400 | 400 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | 'force' => array( |
406 | 406 | 'required' => false, |
407 | 407 | 'default' => false, |
408 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
408 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
409 | 409 | ) |
410 | 410 | ) |
411 | 411 | ) |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $version |
425 | 425 | * @return array |
426 | 426 | */ |
427 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
427 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
428 | 428 | return apply_filters( |
429 | 429 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
430 | 430 | array( |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | 'calculate' => array( |
436 | 436 | 'required' => false, |
437 | 437 | 'default' => '', |
438 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
438 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | $model, |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | * @return array describing the args acceptable when querying this model |
454 | 454 | * @throws \EE_Error |
455 | 455 | */ |
456 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
456 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
457 | 457 | $default_orderby = array(); |
458 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
459 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
458 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
459 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
460 | 460 | } |
461 | 461 | return array_merge( |
462 | - $this->_get_response_selection_query_params( $model, $version ), |
|
462 | + $this->_get_response_selection_query_params($model, $version), |
|
463 | 463 | array( |
464 | 464 | 'where' => array( |
465 | 465 | 'required' => false, |
@@ -496,8 +496,8 @@ discard block |
||
496 | 496 | */ |
497 | 497 | protected function _register_config_routes() { |
498 | 498 | $config_routes = array(); |
499 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
500 | - $config_routes[ self::ee_api_namespace . $version ] = $this->_get_config_route_data_for_version( $version, $hidden_endpoint ); |
|
499 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
500 | + $config_routes[self::ee_api_namespace.$version] = $this->_get_config_route_data_for_version($version, $hidden_endpoint); |
|
501 | 501 | } |
502 | 502 | return $config_routes; |
503 | 503 | } |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * @param boolean $hidden_endpoint |
509 | 509 | * @return array |
510 | 510 | */ |
511 | - protected function _get_config_route_data_for_version( $version, $hidden_endpoint ) { |
|
511 | + protected function _get_config_route_data_for_version($version, $hidden_endpoint) { |
|
512 | 512 | return array( |
513 | 513 | 'config' => array( |
514 | 514 | array( |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | */ |
539 | 539 | protected function _register_meta_routes() { |
540 | 540 | $meta_routes = array(); |
541 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
542 | - $meta_routes[ self::ee_api_namespace . $version ] = $this->_get_meta_route_data_for_version( $version, $hidden_endpoint ); |
|
541 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
542 | + $meta_routes[self::ee_api_namespace.$version] = $this->_get_meta_route_data_for_version($version, $hidden_endpoint); |
|
543 | 543 | } |
544 | 544 | return $meta_routes; |
545 | 545 | } |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @param boolean $hidden_endpoint |
551 | 551 | * @return array |
552 | 552 | */ |
553 | - protected function _get_meta_route_data_for_version( $version, $hidden_endpoint = false ) { |
|
553 | + protected function _get_meta_route_data_for_version($version, $hidden_endpoint = false) { |
|
554 | 554 | return array( |
555 | 555 | 'resources' => array( |
556 | 556 | array( |
@@ -572,25 +572,25 @@ discard block |
||
572 | 572 | * @param array $route_data |
573 | 573 | * @return array |
574 | 574 | */ |
575 | - public static function hide_old_endpoints( $route_data ) { |
|
575 | + public static function hide_old_endpoints($route_data) { |
|
576 | 576 | //allow API clients to override which endpoints get hidden, in case |
577 | 577 | //they want to discover particular endpoints |
578 | 578 | //also, we don't have access to the request so we have to just grab it from the superglobal |
579 | 579 | $force_show_ee_namespace = ltrim( |
580 | - EEH_Array::is_set( $_REQUEST, 'force_show_ee_namespace', '' ), |
|
580 | + EEH_Array::is_set($_REQUEST, 'force_show_ee_namespace', ''), |
|
581 | 581 | '/' |
582 | 582 | ); |
583 | 583 | |
584 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
585 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
586 | - foreach( $routes as $route ) { |
|
584 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
585 | + foreach ($relative_urls as $endpoint => $routes) { |
|
586 | + foreach ($routes as $route) { |
|
587 | 587 | //by default, hide "hidden_endpoint"s, unless the request indicates |
588 | 588 | //to $force_show_ee_namespace, in which case only show that one |
589 | 589 | //namespace's endpoints (and hide all others) |
590 | - if( ( $route[ 'hidden_endpoint' ] && $force_show_ee_namespace === '' ) |
|
591 | - || ( $force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace ) ) { |
|
592 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
593 | - unset( $route_data[ $full_route ] ); |
|
590 | + if (($route['hidden_endpoint'] && $force_show_ee_namespace === '') |
|
591 | + || ($force_show_ee_namespace !== '' && $force_show_ee_namespace !== $namespace)) { |
|
592 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
593 | + unset($route_data[$full_route]); |
|
594 | 594 | } |
595 | 595 | } |
596 | 596 | } |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | */ |
630 | 630 | public static function latest_rest_api_version() { |
631 | 631 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
632 | - $versions_served_keys = array_keys( $versions_served ); |
|
633 | - return end( $versions_served_keys ); |
|
632 | + $versions_served_keys = array_keys($versions_served); |
|
633 | + return end($versions_served_keys); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -644,32 +644,32 @@ discard block |
||
644 | 644 | public static function versions_served() { |
645 | 645 | $versions_served = array(); |
646 | 646 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
647 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
648 | - reset( $possibly_served_versions ); |
|
649 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
650 | - $latest_version = end( $versions_served_historically ); |
|
651 | - reset( $versions_served_historically ); |
|
647 | + $lowest_compatible_version = end($possibly_served_versions); |
|
648 | + reset($possibly_served_versions); |
|
649 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
650 | + $latest_version = end($versions_served_historically); |
|
651 | + reset($versions_served_historically); |
|
652 | 652 | //for each version of core we have ever served: |
653 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
653 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
654 | 654 | //if it's not above the current core version, and it's compatible with the current version of core |
655 | - if( $key_versioned_endpoint == $latest_version ) { |
|
655 | + if ($key_versioned_endpoint == $latest_version) { |
|
656 | 656 | //don't hide the latest version in the index |
657 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
658 | - } else if( |
|
657 | + $versions_served[$key_versioned_endpoint] = false; |
|
658 | + } else if ( |
|
659 | 659 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
660 | 660 | && $key_versioned_endpoint >= $lowest_compatible_version |
661 | 661 | ) { |
662 | 662 | //include, but hide, previous versions which are still supported |
663 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
664 | - } elseif( |
|
663 | + $versions_served[$key_versioned_endpoint] = true; |
|
664 | + } elseif ( |
|
665 | 665 | apply_filters( |
666 | 666 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
667 | 667 | false, |
668 | 668 | $possibly_served_versions |
669 | 669 | ) |
670 | - ){ |
|
670 | + ) { |
|
671 | 671 | //if a version is no longer supported, don't include it in index or list of versions served |
672 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
672 | + $versions_served[$key_versioned_endpoint] = true; |
|
673 | 673 | } |
674 | 674 | } |
675 | 675 | return $versions_served; |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | * @return string |
683 | 683 | */ |
684 | 684 | public static function core_version() { |
685 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
685 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * @param WP $WP |
708 | 708 | * @return void |
709 | 709 | */ |
710 | - public function run( $WP ) { |
|
710 | + public function run($WP) { |
|
711 | 711 | |
712 | 712 | } |
713 | 713 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('ABSPATH')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | */ |
44 | 44 | |
45 | -if ( function_exists( 'espresso_version' ) ) { |
|
45 | +if (function_exists('espresso_version')) { |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | function espresso_duplicate_plugin_error() { |
52 | 52 | ?> |
53 | 53 | <div class="error"> |
54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
55 | 55 | </div> |
56 | 56 | <?php |
57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
58 | 58 | } |
59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
60 | 60 | |
61 | 61 | } else { |
62 | 62 | |
@@ -67,102 +67,102 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | */ |
69 | 69 | function espresso_version() { |
70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.17.rc.005' ); |
|
70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.17.rc.005'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // define versions |
74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
79 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
79 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
80 | 80 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
81 | - if ( ! defined( 'DS' ) ) { |
|
82 | - define( 'DS', '/' ); |
|
81 | + if ( ! defined('DS')) { |
|
82 | + define('DS', '/'); |
|
83 | 83 | } |
84 | - if ( ! defined( 'PS' ) ) { |
|
85 | - define( 'PS', PATH_SEPARATOR ); |
|
84 | + if ( ! defined('PS')) { |
|
85 | + define('PS', PATH_SEPARATOR); |
|
86 | 86 | } |
87 | - if ( ! defined( 'SP' ) ) { |
|
88 | - define( 'SP', ' ' ); |
|
87 | + if ( ! defined('SP')) { |
|
88 | + define('SP', ' '); |
|
89 | 89 | } |
90 | - if ( ! defined( 'EENL' ) ) { |
|
91 | - define( 'EENL', "\n" ); |
|
90 | + if ( ! defined('EENL')) { |
|
91 | + define('EENL', "\n"); |
|
92 | 92 | } |
93 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
93 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
94 | 94 | // define the plugin directory and URL |
95 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
96 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
97 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
95 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
96 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
97 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
98 | 98 | // main root folder paths |
99 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
100 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
101 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
102 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
103 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
104 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
105 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
106 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
99 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
100 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
101 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
102 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
103 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
104 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
105 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
106 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
107 | 107 | // core system paths |
108 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
109 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
110 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
111 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
112 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
113 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
114 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
115 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
116 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
117 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
118 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
119 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
108 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
109 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
110 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
111 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
112 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
113 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
114 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
115 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
116 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
117 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
118 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
119 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
120 | 120 | // gateways |
121 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
122 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
121 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
122 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
123 | 123 | // asset URL paths |
124 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
125 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
126 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
127 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
128 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
129 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
124 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
125 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
126 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
127 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
128 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
129 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
130 | 130 | // define upload paths |
131 | 131 | $uploads = wp_upload_dir(); |
132 | 132 | // define the uploads directory and URL |
133 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
134 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
133 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
134 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
135 | 135 | // define the templates directory and URL |
136 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
137 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
136 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
137 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
138 | 138 | // define the gateway directory and URL |
139 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
140 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
139 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
140 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
141 | 141 | // languages folder/path |
142 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
143 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
142 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
143 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
144 | 144 | //check for dompdf fonts in uploads |
145 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
146 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
145 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
146 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
147 | 147 | } |
148 | 148 | //ajax constants |
149 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
150 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
149 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
150 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
151 | 151 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
152 | 152 | //you're better to use this than its straight value (currently -1) in case you ever |
153 | 153 | //want to change its default value! or find when -1 means infinity |
154 | - define( 'EE_INF_IN_DB', -1 ); |
|
155 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
156 | - define( 'EE_DEBUG', false ); |
|
154 | + define('EE_INF_IN_DB', -1); |
|
155 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
156 | + define('EE_DEBUG', false); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * espresso_plugin_activation |
160 | 160 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
161 | 161 | */ |
162 | 162 | function espresso_plugin_activation() { |
163 | - update_option( 'ee_espresso_activation', true ); |
|
163 | + update_option('ee_espresso_activation', true); |
|
164 | 164 | } |
165 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
165 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // } |
177 | 177 | // |
178 | 178 | } |
179 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
179 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
180 | 180 | |
181 | 181 | |
182 | 182 | |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function espresso_load_error_handling() { |
188 | 188 | // load debugging tools |
189 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
190 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
189 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
190 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
191 | 191 | EEH_Debug_Tools::instance(); |
192 | 192 | } |
193 | 193 | // load error handling |
194 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
195 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
194 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
195 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
196 | 196 | } else { |
197 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
197 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @param string $full_path_to_file |
209 | 209 | * @throws EE_Error |
210 | 210 | */ |
211 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
211 | + function espresso_load_required($classname, $full_path_to_file) { |
|
212 | 212 | static $error_handling_loaded = false; |
213 | - if ( ! $error_handling_loaded ) { |
|
213 | + if ( ! $error_handling_loaded) { |
|
214 | 214 | espresso_load_error_handling(); |
215 | 215 | $error_handling_loaded = true; |
216 | 216 | } |
217 | - if ( is_readable( $full_path_to_file ) ) { |
|
218 | - require_once( $full_path_to_file ); |
|
217 | + if (is_readable($full_path_to_file)) { |
|
218 | + require_once($full_path_to_file); |
|
219 | 219 | } else { |
220 | - throw new EE_Error ( sprintf( |
|
221 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
220 | + throw new EE_Error(sprintf( |
|
221 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
222 | 222 | $classname |
223 | - ) ); |
|
223 | + )); |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
228 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
229 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
227 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
228 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
229 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
230 | 230 | new EE_Bootstrap(); |
231 | 231 | |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | |
237 | 237 | |
238 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
238 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
239 | 239 | /** |
240 | 240 | * deactivate_plugin |
241 | 241 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
245 | 245 | * @return void |
246 | 246 | */ |
247 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
248 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
249 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
247 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
248 | + if ( ! function_exists('deactivate_plugins')) { |
|
249 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
250 | 250 | } |
251 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
252 | - deactivate_plugins( $plugin_basename ); |
|
251 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
252 | + deactivate_plugins($plugin_basename); |
|
253 | 253 | } |
254 | 254 | } |