Completed
Branch BUG-7537 (60d82a)
by
unknown
73:15 queued 56:23
created
core/libraries/plugin_api/EE_Register_Addon.lib.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -66,23 +66,23 @@  discard block
 block discarded – undo
66 66
 	 * @param string $min_core_version
67 67
 	 * @return string always like '4.3.0.rc.000'
68 68
 	 */
69
-	protected static function _effective_version( $min_core_version ) {
69
+	protected static function _effective_version($min_core_version) {
70 70
 		// versions: 4 . 3 . 1 . p . 123
71 71
 		// offsets:    0 . 1 . 2 . 3 . 4
72
-		$version_parts = explode( '.', $min_core_version );
72
+		$version_parts = explode('.', $min_core_version);
73 73
 		//check they specified the micro version (after 2nd period)
74
-		if( ! isset( $version_parts[ 2 ] ) ) {
75
-			$version_parts[ 2] = '0';
74
+		if ( ! isset($version_parts[2])) {
75
+			$version_parts[2] = '0';
76 76
 		}
77 77
 		//if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
78 78
 		//soon we can assume that's 'rc', but this current version is 'alpha'
79
-		if( ! isset( $version_parts[ 3 ] ) ) {
80
-			$version_parts[ 3 ] = 'dev';
79
+		if ( ! isset($version_parts[3])) {
80
+			$version_parts[3] = 'dev';
81 81
 		}
82
-		if( ! isset( $version_parts[ 4 ] ) ) {
83
-			$version_parts[ 4 ] = '000';
82
+		if ( ! isset($version_parts[4])) {
83
+			$version_parts[4] = '000';
84 84
 		}
85
-		return implode( '.', $version_parts );
85
+		return implode('.', $version_parts);
86 86
 
87 87
 	}
88 88
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @param string $actual_core_version the actual core version, optional
93 93
 	 * @return boolean
94 94
 	 */
95
-	public static  function _meets_min_core_version_requirement( $min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION ) {
96
-		return version_compare( self::_effective_version( $actual_core_version ), self::_effective_version( $min_core_version ), '>=' );
95
+	public static  function _meets_min_core_version_requirement($min_core_version, $actual_core_version = EVENT_ESPRESSO_VERSION) {
96
+		return version_compare(self::_effective_version($actual_core_version), self::_effective_version($min_core_version), '>=');
97 97
 	}
98 98
 
99 99
 
@@ -155,235 +155,235 @@  discard block
 block discarded – undo
155 155
 	 * @throws EE_Error
156 156
 	 * @return void
157 157
 	 */
158
-	public static function register( $addon_name = '', $setup_args = array()  ) {
158
+	public static function register($addon_name = '', $setup_args = array()) {
159 159
 		// required fields MUST be present, so let's make sure they are.
160
-		if ( empty( $addon_name ) || ! is_array( $setup_args )) {
161
-			throw new EE_Error( __( 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso' ));
160
+		if (empty($addon_name) || ! is_array($setup_args)) {
161
+			throw new EE_Error(__('In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', 'event_espresso'));
162 162
 		}
163
-		if ( ! isset($setup_args[ 'main_file_path' ]) || empty( $setup_args[ 'main_file_path' ] ) ){
164
-			throw new EE_Error( sprintf( __( 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso' ), implode(",", array_keys( $setup_args ) ) ) );
163
+		if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
164
+			throw new EE_Error(sprintf(__('When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', 'event_espresso'), implode(",", array_keys($setup_args))));
165 165
 		}
166 166
 		// check that addon has not already been registered with that name
167
-		if ( isset( self::$_settings[ $addon_name ] ) && ! did_action( 'activate_plugin' ) ) {
168
-			throw new EE_Error( sprintf( __( 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso' ), $addon_name ));
167
+		if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
168
+			throw new EE_Error(sprintf(__('An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', 'event_espresso'), $addon_name));
169 169
 		}
170 170
 
171 171
 
172 172
 		// no class name for addon?
173
-		if ( empty( $setup_args['class_name'] )) {
173
+		if (empty($setup_args['class_name'])) {
174 174
 			// generate one by first separating name with spaces
175
-			$class_name = str_replace( array( '-', '_' ), ' ', trim( $addon_name ));
175
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
176 176
 			//capitalize, then replace spaces with underscores
177
-			$class_name = str_replace( ' ', '_', ucwords( $class_name ));
177
+			$class_name = str_replace(' ', '_', ucwords($class_name));
178 178
 		} else {
179 179
 			$class_name = $setup_args['class_name'];
180 180
 		}
181
-		$class_name = strpos( $class_name, 'EE_' ) === 0 ? $class_name : 'EE_' . $class_name;
181
+		$class_name = strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name;
182 182
 		//setup $_settings array from incoming values.
183 183
 		$addon_settings = array(
184 184
 			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
185 185
 			'class_name' 						=> $class_name,
186 186
 			// the addon slug for use in URLs, etc
187
-			'plugin_slug' 						=> isset( $setup_args['plugin_slug'] ) ? (string)$setup_args['plugin_slug'] : '',
187
+			'plugin_slug' 						=> isset($setup_args['plugin_slug']) ? (string) $setup_args['plugin_slug'] : '',
188 188
 			// page slug to be used when generating the "Settings" link on the WP plugin page
189
-			'plugin_action_slug' 			=> isset( $setup_args[ 'plugin_action_slug' ] ) ? (string)$setup_args[ 'plugin_action_slug' ] : '',
189
+			'plugin_action_slug' 			=> isset($setup_args['plugin_action_slug']) ? (string) $setup_args['plugin_action_slug'] : '',
190 190
 			// the "software" version for the addon
191
-			'version' 								=> isset( $setup_args['version'] ) ? (string)$setup_args['version'] : '',
191
+			'version' 								=> isset($setup_args['version']) ? (string) $setup_args['version'] : '',
192 192
 			// the minimum version of EE Core that the addon will work with
193
-			'min_core_version' 			=> isset( $setup_args['min_core_version'] ) ? (string)$setup_args['min_core_version'] : '',
193
+			'min_core_version' 			=> isset($setup_args['min_core_version']) ? (string) $setup_args['min_core_version'] : '',
194 194
 			// full server path to main file (file loaded directly by WP)
195
-			'main_file_path' 					=> isset( $setup_args['main_file_path'] ) ? (string)$setup_args['main_file_path'] : '',
195
+			'main_file_path' 					=> isset($setup_args['main_file_path']) ? (string) $setup_args['main_file_path'] : '',
196 196
 			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
197
-			'admin_path' 						=> isset( $setup_args['admin_path'] ) ? (string)$setup_args['admin_path'] : '',
197
+			'admin_path' 						=> isset($setup_args['admin_path']) ? (string) $setup_args['admin_path'] : '',
198 198
 			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
199
-			'admin_callback' 				=> isset( $setup_args['admin_callback'] ) ? (string)$setup_args['admin_callback'] : '',
199
+			'admin_callback' 				=> isset($setup_args['admin_callback']) ? (string) $setup_args['admin_callback'] : '',
200 200
 			// the section name for this addon's configuration settings section (defaults to "addons")
201
-			'config_section' 					=> isset( $setup_args['config_section'] ) ? (string)$setup_args['config_section'] : 'addons',
201
+			'config_section' 					=> isset($setup_args['config_section']) ? (string) $setup_args['config_section'] : 'addons',
202 202
 			// the class name for this addon's configuration settings object
203
-			'config_class' 						=> isset( $setup_args['config_class'] ) ? (string)$setup_args['config_class'] : '',
203
+			'config_class' 						=> isset($setup_args['config_class']) ? (string) $setup_args['config_class'] : '',
204 204
 			//the name given to the config for this addons' configuration settings object (optional)
205
-			'config_name' 					=> isset( $setup_args['config_name'] ) ? (string) $setup_args['config_name']: '',
205
+			'config_name' 					=> isset($setup_args['config_name']) ? (string) $setup_args['config_name'] : '',
206 206
 			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
207
-			'autoloader_paths' 			=> isset( $setup_args['autoloader_paths'] ) ? (array)$setup_args['autoloader_paths'] : array(),
207
+			'autoloader_paths' 			=> isset($setup_args['autoloader_paths']) ? (array) $setup_args['autoloader_paths'] : array(),
208 208
 			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
209
-			'autoloader_folders' 			=> isset( $setup_args['autoloader_folders'] ) ? (array)$setup_args['autoloader_folders'] : array(),
209
+			'autoloader_folders' 			=> isset($setup_args['autoloader_folders']) ? (array) $setup_args['autoloader_folders'] : array(),
210 210
 			// array of full server paths to any EE_DMS data migration scripts used by the addon
211
-			'dms_paths' 						=> isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array(),
211
+			'dms_paths' 						=> isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array(),
212 212
 			// array of full server paths to any EED_Modules used by the addon
213
-			'module_paths' 					=> isset( $setup_args['module_paths'] ) ? (array)$setup_args['module_paths'] : array(),
213
+			'module_paths' 					=> isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : array(),
214 214
 			// array of full server paths to any EES_Shortcodes used by the addon
215
-			'shortcode_paths'			 	=> isset( $setup_args['shortcode_paths'] ) ? (array)$setup_args['shortcode_paths'] : array(),
215
+			'shortcode_paths'			 	=> isset($setup_args['shortcode_paths']) ? (array) $setup_args['shortcode_paths'] : array(),
216 216
 			// array of full server paths to any WP_Widgets used by the addon
217
-			'widget_paths' 					=> isset( $setup_args['widget_paths'] ) ? (array)$setup_args['widget_paths'] : array(),
217
+			'widget_paths' 					=> isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : array(),
218 218
 			// array of PUE options used by the addon
219
-			'pue_options' 						=> isset( $setup_args['pue_options'] ) ? (array)$setup_args['pue_options'] : array(),
220
-			'message_types' 				=> isset( $setup_args['message_types'] ) ? (array) $setup_args['message_types'] : array(),
221
-			'capabilities' 						=> isset( $setup_args['capabilities'] ) ? (array) $setup_args['capabilities'] : array(),
222
-			'capability_maps' 				=> isset( $setup_args['capability_maps'] ) ? (array) $setup_args['capability_maps'] : array(),
223
-			'model_paths' 					=> isset( $setup_args['model_paths'] ) ? (array) $setup_args['model_paths'] : array(),
224
-			'class_paths' 						=> isset( $setup_args['class_paths'] ) ? (array) $setup_args['class_paths'] : array(),
225
-			'model_extension_paths' 	=> isset( $setup_args['model_extension_paths'] ) ? (array) $setup_args['model_extension_paths'] : array(),
226
-			'class_extension_paths' 		=> isset( $setup_args['class_extension_paths'] ) ? (array) $setup_args['class_extension_paths'] : array(),
227
-			'custom_post_types' 			=> isset( $setup_args['custom_post_types'] ) ? (array) $setup_args['custom_post_types'] : array(),
228
-			'custom_taxonomies' 		=> isset( $setup_args['custom_taxonomies'] ) ? (array) $setup_args['custom_taxonomies'] : array(),
229
-			'payment_method_paths'	=> isset( $setup_args[ 'payment_method_paths' ] ) ? (array) $setup_args[ 'payment_method_paths' ] : array(),
230
-			'default_terms' 					=> isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array(),
219
+			'pue_options' 						=> isset($setup_args['pue_options']) ? (array) $setup_args['pue_options'] : array(),
220
+			'message_types' 				=> isset($setup_args['message_types']) ? (array) $setup_args['message_types'] : array(),
221
+			'capabilities' 						=> isset($setup_args['capabilities']) ? (array) $setup_args['capabilities'] : array(),
222
+			'capability_maps' 				=> isset($setup_args['capability_maps']) ? (array) $setup_args['capability_maps'] : array(),
223
+			'model_paths' 					=> isset($setup_args['model_paths']) ? (array) $setup_args['model_paths'] : array(),
224
+			'class_paths' 						=> isset($setup_args['class_paths']) ? (array) $setup_args['class_paths'] : array(),
225
+			'model_extension_paths' 	=> isset($setup_args['model_extension_paths']) ? (array) $setup_args['model_extension_paths'] : array(),
226
+			'class_extension_paths' 		=> isset($setup_args['class_extension_paths']) ? (array) $setup_args['class_extension_paths'] : array(),
227
+			'custom_post_types' 			=> isset($setup_args['custom_post_types']) ? (array) $setup_args['custom_post_types'] : array(),
228
+			'custom_taxonomies' 		=> isset($setup_args['custom_taxonomies']) ? (array) $setup_args['custom_taxonomies'] : array(),
229
+			'payment_method_paths'	=> isset($setup_args['payment_method_paths']) ? (array) $setup_args['payment_method_paths'] : array(),
230
+			'default_terms' 					=> isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array(),
231 231
 			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page that can be used for adding upgrading/marketing info
232
-			'plugins_page_row' 			=> isset( $setup_args['plugins_page_row'] ) ? $setup_args['plugins_page_row'] : '',
232
+			'plugins_page_row' 			=> isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '',
233 233
 		);
234 234
 
235 235
 		// if plugin_action_slug is NOT set, but an admin page path IS set, then let's just use the plugin_slug since that will be used for linking to the admin page
236
-		$addon_settings[ 'plugin_action_slug' ] = empty( $addon_settings[ 'plugin_action_slug' ] ) && ! empty( $addon_settings[ 'admin_path' ] ) ? $addon_settings[ 'plugin_slug' ] : $addon_settings[ 'plugin_action_slug' ];
236
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) && ! empty($addon_settings['admin_path']) ? $addon_settings['plugin_slug'] : $addon_settings['plugin_action_slug'];
237 237
 		// full server path to main file (file loaded directly by WP)
238
-		$addon_settings['plugin_basename'] = plugin_basename( $addon_settings[ 'main_file_path' ] );
238
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
239 239
 
240 240
 		//check whether this addon version is compatible with EE core
241
-		if ( isset( EE_Register_Addon::$_incompatible_addons[ $addon_name ] ) &&
242
-				! self::_meets_min_core_version_requirement( EE_Register_Addon::$_incompatible_addons[ $addon_name ], $addon_settings[ 'version' ] ) ) {
241
+		if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) &&
242
+				! self::_meets_min_core_version_requirement(EE_Register_Addon::$_incompatible_addons[$addon_name], $addon_settings['version'])) {
243 243
 			$incompatibility_message = sprintf(
244
-				__( 'The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso' ),
244
+				__('The Event Espresso "%1$s" addon was deactivated because it is incompatible with this version of core.%2$s Only version %3$s or higher of "%1$s" can run with this version of core. This can happen when attempting to run beta versions or release candidates with older versions of core, or running old versions of addons with a newer version of core.%2$sPlease upgrade Event Espresso Core and the "%1$s" addon, then re-attempt activating it.', 'event_espresso'),
245 245
 				$addon_name,
246 246
 				'<br />',
247
-				EE_Register_Addon::$_incompatible_addons[ $addon_name ]
247
+				EE_Register_Addon::$_incompatible_addons[$addon_name]
248 248
 			);
249
-		} else if ( ! self::_meets_min_core_version_requirement( $setup_args[ 'min_core_version' ], espresso_version() ) ) {
249
+		} else if ( ! self::_meets_min_core_version_requirement($setup_args['min_core_version'], espresso_version())) {
250 250
 			$incompatibility_message = sprintf(
251
-				__( 'The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', 'event_espresso' ),
251
+				__('The Event Espresso "%1$s" addon could not be activated because it requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-attempt activating "%1$s".', 'event_espresso'),
252 252
 				$addon_name,
253
-				self::_effective_version( $setup_args[ 'min_core_version' ] ),
254
-				self::_effective_version( espresso_version() ),
253
+				self::_effective_version($setup_args['min_core_version']),
254
+				self::_effective_version(espresso_version()),
255 255
 				'<br />'
256 256
 			);
257 257
 		} else {
258 258
 			$incompatibility_message = '';
259 259
 		}
260
-		if ( ! empty( $incompatibility_message ) ) {
260
+		if ( ! empty($incompatibility_message)) {
261 261
 			//remove 'activate' from the REQUEST so WP doesn't erroneously tell the user the
262 262
 			//plugin activated fine when it didn't
263
-			if( isset( $_GET[ 'activate' ]) ) {
264
-				unset( $_GET[ 'activate' ] );
263
+			if (isset($_GET['activate'])) {
264
+				unset($_GET['activate']);
265 265
 			}
266
-			if( isset( $_REQUEST[ 'activate' ] ) ){
267
-				unset( $_REQUEST[ 'activate' ] );
266
+			if (isset($_REQUEST['activate'])) {
267
+				unset($_REQUEST['activate']);
268 268
 			}
269 269
 			//and show an error message indicating the plugin didn't activate properly
270
-			EE_Error::add_error( $incompatibility_message, __FILE__, __FUNCTION__, __LINE__ );
271
-			if ( current_user_can( 'activate_plugins' )) {
272
-				require_once( ABSPATH.'wp-admin/includes/plugin.php' );
273
-				deactivate_plugins( plugin_basename( $addon_settings[ 'main_file_path' ] ), TRUE );
270
+			EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
271
+			if (current_user_can('activate_plugins')) {
272
+				require_once(ABSPATH.'wp-admin/includes/plugin.php');
273
+				deactivate_plugins(plugin_basename($addon_settings['main_file_path']), TRUE);
274 274
 			}
275 275
 			return;
276 276
 		}
277 277
 		//this is an activation request
278
-		if( did_action( 'activate_plugin' ) ){
278
+		if (did_action('activate_plugin')) {
279 279
 			//to find if THIS is the addon that was activated,
280 280
 			//just check if we have already registered it or not
281 281
 			//(as the newly-activated addon wasn't around the first time addons were registered)
282
-			if( ! isset( self::$_settings[ $addon_name ] ) ){
283
-				self::$_settings[ $addon_name ] = $addon_settings;
282
+			if ( ! isset(self::$_settings[$addon_name])) {
283
+				self::$_settings[$addon_name] = $addon_settings;
284 284
 				$addon = self::_load_and_init_addon_class($addon_name);
285 285
 				$addon->set_activation_indicator_option();
286 286
 				//dont bother setting up the rest of the addon.
287 287
 				//we know it was just activated and the request will end soon
288 288
 			}
289 289
 			return;
290
-		}else{
290
+		} else {
291 291
 			// make sure this was called in the right place!
292
-			if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) {
292
+			if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
293 293
 				EE_Error::doing_it_wrong(
294 294
 					__METHOD__,
295 295
 					sprintf(
296
-						__( 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.','event_espresso'),
296
+						__('An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', 'event_espresso'),
297 297
 						$addon_name
298 298
 					),
299 299
 					'4.3.0'
300 300
 				);
301 301
 			}
302
-			self::$_settings[ $addon_name ] = $addon_settings;
302
+			self::$_settings[$addon_name] = $addon_settings;
303 303
 		}
304 304
 		// we need cars
305
-		if ( ! empty( self::$_settings[ $addon_name ]['autoloader_paths'] )) {
305
+		if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
306 306
 			// setup autoloader for single file
307
-			EEH_Autoloader::instance()->register_autoloader( self::$_settings[ $addon_name ]['autoloader_paths'] );
307
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
308 308
 		}
309 309
 		// setup autoloaders for folders
310
-		if ( ! empty( self::$_settings[ $addon_name ]['autoloader_folders'] )) {
311
-			foreach ( self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder ) {
312
-				EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $autoloader_folder );
310
+		if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
311
+			foreach (self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
312
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
313 313
 			}
314 314
 		}
315 315
 		// register new models
316
-		if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_paths'] )) {
317
-			EE_Register_Model::register( $addon_name, array( 'model_paths' => self::$_settings[ $addon_name ]['model_paths'] , 'class_paths' => self::$_settings[ $addon_name ]['class_paths']));
316
+		if ( ! empty(self::$_settings[$addon_name]['model_paths']) || ! empty(self::$_settings[$addon_name]['class_paths'])) {
317
+			EE_Register_Model::register($addon_name, array('model_paths' => self::$_settings[$addon_name]['model_paths'], 'class_paths' => self::$_settings[$addon_name]['class_paths']));
318 318
 		}
319 319
 		// register model extensions
320
-		if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) || ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) {
321
-			EE_Register_Model_Extensions::register( $addon_name, array( 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'] , 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths']));
320
+		if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) || ! empty(self::$_settings[$addon_name]['class_extension_paths'])) {
321
+			EE_Register_Model_Extensions::register($addon_name, array('model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths']));
322 322
 		}
323 323
 		// setup DMS
324
-		if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) {
325
-			EE_Register_Data_Migration_Scripts::register( $addon_name, array( 'dms_paths' => self::$_settings[ $addon_name ]['dms_paths'] ));
324
+		if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
325
+			EE_Register_Data_Migration_Scripts::register($addon_name, array('dms_paths' => self::$_settings[$addon_name]['dms_paths']));
326 326
 		}
327 327
 		// if config_class is present let's register config.
328
-		if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) {
328
+		if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
329 329
 			EE_Register_Config::register(
330
-				self::$_settings[ $addon_name ]['config_class'],
330
+				self::$_settings[$addon_name]['config_class'],
331 331
 				array(
332
-					'config_section' => self::$_settings[ $addon_name ]['config_section'],
333
-					'config_name' => self::$_settings[ $addon_name ]['config_name']
332
+					'config_section' => self::$_settings[$addon_name]['config_section'],
333
+					'config_name' => self::$_settings[$addon_name]['config_name']
334 334
 				)
335 335
 			);
336 336
 		}
337 337
 		// register admin page
338
-		if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) {
339
-			EE_Register_Admin_Page::register( $addon_name, array( 'page_path' => self::$_settings[ $addon_name ]['admin_path'] ));
338
+		if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
339
+			EE_Register_Admin_Page::register($addon_name, array('page_path' => self::$_settings[$addon_name]['admin_path']));
340 340
 
341 341
 		}
342 342
 		// add to list of modules to be registered
343
-		if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) {
344
-			EE_Register_Module::register( $addon_name, array( 'module_paths' => self::$_settings[ $addon_name ]['module_paths'] ));
343
+		if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
344
+			EE_Register_Module::register($addon_name, array('module_paths' => self::$_settings[$addon_name]['module_paths']));
345 345
 		}
346 346
 		// add to list of shortcodes to be registered
347
-		if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) {
348
-			EE_Register_Shortcode::register( $addon_name, array( 'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] ));
347
+		if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
348
+			EE_Register_Shortcode::register($addon_name, array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths']));
349 349
 		}
350 350
 		// add to list of widgets to be registered
351
-		if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) {
352
-			EE_Register_Widget::register( $addon_name, array( 'widget_paths' => self::$_settings[ $addon_name ]['widget_paths'] ));
351
+		if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
352
+			EE_Register_Widget::register($addon_name, array('widget_paths' => self::$_settings[$addon_name]['widget_paths']));
353 353
 		}
354 354
 
355 355
 		//register capability related stuff.
356
-		if ( ! empty( self::$_settings[ $addon_name ]['capabilities'] ) ) {
357
-			EE_Register_Capabilities::register( $addon_name , array( 'capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps'] ) );
356
+		if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
357
+			EE_Register_Capabilities::register($addon_name, array('capabilities' => self::$_settings[$addon_name]['capabilities'], 'capability_maps' => self::$_settings[$addon_name]['capability_maps']));
358 358
 		}
359 359
 		//any message type to register?
360
-		if (  !empty( self::$_settings[$addon_name]['message_types'] ) ) {
361
-				add_action( 'EE_Brewing_Regular___messages_caf', array( 'EE_Register_Addon', 'register_message_types' ) );
360
+		if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
361
+				add_action('EE_Brewing_Regular___messages_caf', array('EE_Register_Addon', 'register_message_types'));
362 362
 		}
363 363
 
364 364
 		// if plugin update engine is being used for auto-updates (not needed if PUE is not being used)
365
-		if ( ! empty( $setup_args['pue_options'] )) {
366
-			self::$_settings[ $addon_name ]['pue_options'] = array(
367
-				'pue_plugin_slug' 	=> isset( $setup_args['pue_options']['pue_plugin_slug'] ) ? (string)$setup_args['pue_options']['pue_plugin_slug'] : 'espresso_' . strtolower( $class_name ),
368
-				'plugin_basename' => isset( $setup_args['pue_options']['plugin_basename'] ) ? (string)$setup_args['pue_options']['plugin_basename'] : plugin_basename( self::$_settings[ $addon_name ]['main_file_path'] ),
369
-				'checkPeriod' 			=> isset( $setup_args['pue_options']['checkPeriod'] ) ? (string)$setup_args['pue_options']['checkPeriod'] : '24',
370
-				'use_wp_update'		=> isset( $setup_args['pue_options']['use_wp_update'] ) ? (string)$setup_args['pue_options']['use_wp_update'] : FALSE
365
+		if ( ! empty($setup_args['pue_options'])) {
366
+			self::$_settings[$addon_name]['pue_options'] = array(
367
+				'pue_plugin_slug' 	=> isset($setup_args['pue_options']['pue_plugin_slug']) ? (string) $setup_args['pue_options']['pue_plugin_slug'] : 'espresso_'.strtolower($class_name),
368
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) ? (string) $setup_args['pue_options']['plugin_basename'] : plugin_basename(self::$_settings[$addon_name]['main_file_path']),
369
+				'checkPeriod' 			=> isset($setup_args['pue_options']['checkPeriod']) ? (string) $setup_args['pue_options']['checkPeriod'] : '24',
370
+				'use_wp_update'		=> isset($setup_args['pue_options']['use_wp_update']) ? (string) $setup_args['pue_options']['use_wp_update'] : FALSE
371 371
 			);
372
-			add_action( 'AHEE__EE_System__brew_espresso__after_pue_init', array( 'EE_Register_Addon', 'load_pue_update' ));
372
+			add_action('AHEE__EE_System__brew_espresso__after_pue_init', array('EE_Register_Addon', 'load_pue_update'));
373 373
 		}
374 374
 
375 375
 		//any custom post type/ custom capabilities or default terms to register
376
-		if ( !empty( self::$_settings[$addon_name]['custom_post_types'] ) || !empty( self::$_settings[$addon_name]['custom_taxonomies'] ) ) {
377
-			EE_Register_CPT::register( $addon_name, array( 'cpts' => self::$_settings[$addon_name]['custom_post_types'] , 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms'] ) );
376
+		if ( ! empty(self::$_settings[$addon_name]['custom_post_types']) || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])) {
377
+			EE_Register_CPT::register($addon_name, array('cpts' => self::$_settings[$addon_name]['custom_post_types'], 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], 'default_terms' => self::$_settings[$addon_name]['default_terms']));
378 378
 		}
379
-		if( ! empty( self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) ){
380
-			EE_Register_Payment_Method::register($addon_name, array( 'payment_method_paths' => self::$_settings[ $addon_name ][ 'payment_method_paths' ] ) );
379
+		if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
380
+			EE_Register_Payment_Method::register($addon_name, array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']));
381 381
 		}
382 382
 		// load and instantiate main addon class
383 383
 		$addon = self::_load_and_init_addon_class($addon_name);
384 384
 		// call any additional admin_callback functions during load_admin_controller hook
385
-		if ( ! empty( self::$_settings[ $addon_name ]['admin_callback'] )) {
386
-			add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $addon, self::$_settings[ $addon_name ]['admin_callback'] ));
385
+		if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
386
+			add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($addon, self::$_settings[$addon_name]['admin_callback']));
387 387
 		}
388 388
 	}
389 389
 
@@ -394,22 +394,22 @@  discard block
 block discarded – undo
394 394
 	 * @param string $addon_name
395 395
 	 * @return EE_Addon
396 396
 	 */
397
-	private static function _load_and_init_addon_class($addon_name){
398
-		$addon = EE_Registry::instance()->load_addon( dirname( self::$_settings[ $addon_name ]['main_file_path'] ), self::$_settings[ $addon_name ]['class_name'] );
399
-		$addon->set_name( $addon_name );
400
-		$addon->set_plugin_slug( self::$_settings[ $addon_name ][ 'plugin_slug' ] );
401
-		$addon->set_plugin_basename( self::$_settings[ $addon_name ][ 'plugin_basename' ] );
402
-		$addon->set_main_plugin_file( self::$_settings[ $addon_name ]['main_file_path'] );
403
-		$addon->set_plugin_action_slug( self::$_settings[ $addon_name ][ 'plugin_action_slug' ] );
404
-		$addon->set_plugins_page_row( self::$_settings[ $addon_name ][ 'plugins_page_row' ] );
405
-		$addon->set_version( self::$_settings[ $addon_name ]['version'] );
406
-		$addon->set_min_core_version( self::_effective_version( self::$_settings[ $addon_name ]['min_core_version'] ) );
407
-		$addon->set_config_section( self::$_settings[ $addon_name ]['config_section'] );
408
-		$addon->set_config_class( self::$_settings[ $addon_name ]['config_class'] );
409
-		$addon->set_config_name( self::$_settings[ $addon_name ]['config_name'] );
397
+	private static function _load_and_init_addon_class($addon_name) {
398
+		$addon = EE_Registry::instance()->load_addon(dirname(self::$_settings[$addon_name]['main_file_path']), self::$_settings[$addon_name]['class_name']);
399
+		$addon->set_name($addon_name);
400
+		$addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
401
+		$addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
402
+		$addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
403
+		$addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
404
+		$addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
405
+		$addon->set_version(self::$_settings[$addon_name]['version']);
406
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
407
+		$addon->set_config_section(self::$_settings[$addon_name]['config_section']);
408
+		$addon->set_config_class(self::$_settings[$addon_name]['config_class']);
409
+		$addon->set_config_name(self::$_settings[$addon_name]['config_name']);
410 410
 		//unfortunately this can't be hooked in upon construction, because we don't have
411 411
 		//the plugin mainfile's path upon construction.
412
-		register_deactivation_hook($addon->get_main_plugin_file(), array($addon,'deactivation'));
412
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
413 413
 		return $addon;
414 414
 	}
415 415
 
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	public static function load_pue_update() {
424 424
 		// load PUE client
425
-		require_once  EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
425
+		require_once  EE_THIRD_PARTY.'pue'.DS.'pue-client.php';
426 426
 		// cycle thru settings
427
-		foreach ( self::$_settings as $settings ) {
428
-			if ( ! empty( $settings['pue_options'] )) {
427
+		foreach (self::$_settings as $settings) {
428
+			if ( ! empty($settings['pue_options'])) {
429 429
 				// initiate the class and start the plugin update engine!
430 430
 				new PluginUpdateEngineChecker(
431 431
 				// host file URL
432 432
 					'https://eventespresso.com',
433 433
 					// plugin slug(s)
434 434
 					array(
435
-						'premium' => array( 'p' => $settings['pue_options']['pue_plugin_slug'] ),
436
-						'prerelease' => array( 'beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr' )
435
+						'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']),
436
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr')
437 437
 					),
438 438
 					// options
439 439
 					array(
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 	 * @return void
462 462
 	 */
463 463
 	public static function register_message_types() {
464
-		foreach ( self::$_settings as $settings ) {
465
-			foreach( $settings['message_types'] as $message_type => $message_type_settings ) {
466
-				EE_Register_Message_Type::register( $message_type, $message_type_settings );
464
+		foreach (self::$_settings as $settings) {
465
+			foreach ($settings['message_types'] as $message_type => $message_type_settings) {
466
+				EE_Register_Message_Type::register($message_type, $message_type_settings);
467 467
 			}
468 468
 		}
469 469
 	}
@@ -479,60 +479,60 @@  discard block
 block discarded – undo
479 479
 	 * @throws EE_Error
480 480
 	 * @return void
481 481
 	 */
482
-	public static function deregister( $addon_name = NULL ) {
483
-		if ( isset( self::$_settings[ $addon_name ] )) {
484
-			$class_name = self::$_settings[ $addon_name ]['class_name'];
485
-			if ( ! empty( self::$_settings[ $addon_name ]['dms_paths'] )) {
482
+	public static function deregister($addon_name = NULL) {
483
+		if (isset(self::$_settings[$addon_name])) {
484
+			$class_name = self::$_settings[$addon_name]['class_name'];
485
+			if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
486 486
 				// setup DMS
487
-				EE_Register_Data_Migration_Scripts::deregister( $addon_name );
487
+				EE_Register_Data_Migration_Scripts::deregister($addon_name);
488 488
 			}
489
-			if ( ! empty( self::$_settings[ $addon_name ]['admin_path'] )) {
489
+			if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
490 490
 				// register admin page
491
-				EE_Register_Admin_Page::deregister( $addon_name );
491
+				EE_Register_Admin_Page::deregister($addon_name);
492 492
 			}
493
-			if ( ! empty( self::$_settings[ $addon_name ]['module_paths'] )) {
493
+			if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
494 494
 				// add to list of modules to be registered
495
-				EE_Register_Module::deregister( $addon_name );
495
+				EE_Register_Module::deregister($addon_name);
496 496
 			}
497
-			if ( ! empty( self::$_settings[ $addon_name ]['shortcode_paths'] )) {
497
+			if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
498 498
 				// add to list of shortcodes to be registered
499
-				EE_Register_Shortcode::deregister( $addon_name );
499
+				EE_Register_Shortcode::deregister($addon_name);
500 500
 			}
501
-			if ( ! empty( self::$_settings[ $addon_name ]['config_class'] )) {
501
+			if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
502 502
 				// if config_class present let's register config.
503
-				EE_Register_Config::deregister( self::$_settings[ $addon_name ]['config_class']);
503
+				EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
504 504
 			}
505
-			if ( ! empty( self::$_settings[ $addon_name ]['widget_paths'] )) {
505
+			if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
506 506
 				// add to list of widgets to be registered
507
-				EE_Register_Widget::deregister( $addon_name );
507
+				EE_Register_Widget::deregister($addon_name);
508 508
 			}
509
-			if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] ) ||
510
-					! empty( self::$_settings[ $addon_name ]['class_paths'] )) {
509
+			if ( ! empty(self::$_settings[$addon_name]['model_paths']) ||
510
+					! empty(self::$_settings[$addon_name]['class_paths'])) {
511 511
 				// add to list of shortcodes to be registered
512
-				EE_Register_Model::deregister( $addon_name );
512
+				EE_Register_Model::deregister($addon_name);
513 513
 			}
514
-			if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] ) ||
515
-					! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )) {
514
+			if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) ||
515
+					! empty(self::$_settings[$addon_name]['class_extension_paths'])) {
516 516
 				// add to list of shortcodes to be registered
517
-				EE_Register_Model_Extensions::deregister( $addon_name );
517
+				EE_Register_Model_Extensions::deregister($addon_name);
518 518
 				}
519
-			if (  !empty( self::$_settings[$addon_name]['message_types'] ) ) {
520
-				foreach( self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings ) {
521
-					EE_Register_Message_Type::deregister( $message_type );
519
+			if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
520
+				foreach (self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
521
+					EE_Register_Message_Type::deregister($message_type);
522 522
 				}
523 523
 			}
524 524
 			//deregister capabilities for addon
525
-			if ( ! empty( self::$_settings[$addon_name]['capabilities'] ) || ! empty( self::$_settings[$addon_name]['capability_maps']) ) {
526
-				EE_Register_Capabilities::deregister( $addon_name );
525
+			if ( ! empty(self::$_settings[$addon_name]['capabilities']) || ! empty(self::$_settings[$addon_name]['capability_maps'])) {
526
+				EE_Register_Capabilities::deregister($addon_name);
527 527
 			}
528 528
 			//deregister custom_post_types for addon
529
-			if ( ! empty( self::$_settings[$addon_name]['custom_post_types'] ) ) {
530
-				EE_Register_CPT::deregister( $addon_name );
529
+			if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
530
+				EE_Register_CPT::deregister($addon_name);
531 531
 			}
532
-			remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),  array( EE_Registry::instance()->addons->{$class_name}, 'deactivation' ) );
533
-			remove_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required' ) );
532
+			remove_action('deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(), array(EE_Registry::instance()->addons->{$class_name}, 'deactivation'));
533
+			remove_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required'));
534 534
 			unset(EE_Registry::instance()->addons->{$class_name});
535
-			unset( self::$_settings[ $addon_name ] );
535
+			unset(self::$_settings[$addon_name]);
536 536
 		}
537 537
 	}
538 538
 
Please login to merge, or discard this patch.
core/libraries/qtips/EE_Qtip_Config.lib.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -177,8 +177,9 @@  discard block
 block discarded – undo
177 177
 	protected function _construct_tips() {
178 178
 		foreach ( $this->_qtipsa as $qt ) {
179 179
 			//make sure we have what we need.
180
-			if ( !isset( $qt['content_id'] ) || !isset( $qt['target'] ) || !isset( $qt['content'] ) )
181
-				throw new EE_Error( sprintf( __('There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.', 'event_espresso'), get_class($this), var_export($qt, true) ) );
180
+			if ( !isset( $qt['content_id'] ) || !isset( $qt['target'] ) || !isset( $qt['content'] ) ) {
181
+							throw new EE_Error( sprintf( __('There is something wrong with the _qtipsa property setup for the %s qtip config class.  The dump of the current array index is: %s.<br /><br />Please check that it is setup correctly.', 'event_espresso'), get_class($this), var_export($qt, true) ) );
182
+			}
182 183
 
183 184
 			//make sure the options include defaults and just override via set config.
184 185
 			$options_override = isset( $qt['options'] ) ? (array) $qt['options'] : array();
@@ -266,8 +267,9 @@  discard block
 block discarded – undo
266 267
 
267 268
 	public function __construct( $setup_array ) {
268 269
 		foreach ( $setup_array as $prop => $value ) {
269
-			if ( EEH_Class_Tools::has_property( $this, $prop ) )
270
-				$this->{$prop} = $value;
270
+			if ( EEH_Class_Tools::has_property( $this, $prop ) ) {
271
+							$this->{$prop} = $value;
272
+			}
271 273
 		}
272 274
 	}
273 275
 }
274 276
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/Changes_In_4_8_33.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,13 +13,13 @@  discard block
 block discarded – undo
13 13
 		//is for lower than 4.8.33
14 14
 		add_filter( 
15 15
 			'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
16
-			array( $this, 'remove_checkin_routes_earlier_than_4_8_33' ),
16
+			array($this, 'remove_checkin_routes_earlier_than_4_8_33'),
17 17
 			10,
18 18
 			2
19 19
 		);
20 20
 		add_filter( 
21 21
 			'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return',
22
-			array( $this, 'dont_add_headers_from_ee_notices' ),
22
+			array($this, 'dont_add_headers_from_ee_notices'),
23 23
 			10,
24 24
 			2
25 25
 		);
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 * @param string $version
33 33
 	 * @return array like $routes_on_this_version
34 34
 	 */
35
-	public function remove_checkin_routes_earlier_than_4_8_33( $routes_on_this_version, $version ) {
36
-		if( $this->applies_to_version(  $version ) ) {
37
-			unset( $routes_on_this_version[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] );
35
+	public function remove_checkin_routes_earlier_than_4_8_33($routes_on_this_version, $version) {
36
+		if ($this->applies_to_version($version)) {
37
+			unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']);
38 38
 		}
39 39
 		return $routes_on_this_version;
40 40
 	}
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	 * @param string $requested_version
46 46
 	 * @return array
47 47
 	 */
48
-	public function dont_add_headers_from_ee_notices( $headers_from_ee_notices, $requested_version ) {
49
-		if( $this->applies_to_version(  $requested_version ) ) {
48
+	public function dont_add_headers_from_ee_notices($headers_from_ee_notices, $requested_version) {
49
+		if ($this->applies_to_version($requested_version)) {
50 50
 			return array();
51 51
 		}
52 52
 		return $headers_from_ee_notices;
Please login to merge, or discard this patch.
core/libraries/rest_api/changes/Changes_In_Base.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @return boolean true: this class' name indicates its filters and actions
57 57
 	 * should take effect. False: this class' name indicates it shouldn't do anything
58 58
 	 */
59
-	public function applies_to_version( $requested_version ) {
60
-		if( $this->version() > $requested_version ) {
59
+	public function applies_to_version($requested_version) {
60
+		if ($this->version() > $requested_version) {
61 61
 			return true;
62 62
 		}
63 63
 		return false;
@@ -71,24 +71,24 @@  discard block
 block discarded – undo
71 71
 	 * @throws \EE_Error
72 72
 	 */
73 73
 	public function version() {
74
-		if( $this->_version === null ) {
74
+		if ($this->_version === null) {
75 75
 			$matches = array();
76 76
 			$regex = '~Changes_In_(.*)_(.*)_(.*)$~';
77 77
 			$success = preg_match(
78 78
 				$regex,
79
-				get_class( $this ),
79
+				get_class($this),
80 80
 				$matches
81 81
 			);
82
-			if( ! $success ) {
82
+			if ( ! $success) {
83 83
 				throw new \EE_Error(
84 84
 					sprintf(
85
-						__( 'The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso' ),
86
-						get_class( $this ),
85
+						__('The class %1$s was misnamed. It name should match the regex "%2$s"', 'event_espresso'),
86
+						get_class($this),
87 87
 						$regex
88 88
 					)
89 89
 				);
90 90
 			}
91
-			$this->_version = $matches[1] . '.' . $matches[2] . '.' . $matches[3];
91
+			$this->_version = $matches[1].'.'.$matches[2].'.'.$matches[3];
92 92
 		}
93 93
 		return $this->_version;
94 94
 	}
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/Base.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers;
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
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	protected $_requested_version;
37 37
 
38 38
 	public function __construct() {
39
-		$this->_debug_mode = defined( 'EE_REST_API_DEBUG_MODE' ) ? EE_REST_API_DEBUG_MODE : false;
39
+		$this->_debug_mode = defined('EE_REST_API_DEBUG_MODE') ? EE_REST_API_DEBUG_MODE : false;
40 40
 	}
41 41
 
42 42
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * Sets the version the user requested
45 45
 	 * @param string $version eg '4.8'
46 46
 	 */
47
-	public function set_requested_version( $version ) {
47
+	public function set_requested_version($version) {
48 48
 		$this->_requested_version = $version;
49 49
 	}
50 50
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 * @param string $key
54 54
 	 * @param string|array $info
55 55
 	 */
56
-	protected function _set_debug_info( $key, $info ){
57
-		$this->_debug_info[ $key ] = $info;
56
+	protected function _set_debug_info($key, $info) {
57
+		$this->_debug_info[$key] = $info;
58 58
 	}
59 59
 	
60 60
 	/**
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 	 * @param \WP_Error $wp_error_response
63 63
 	 * @return \WP_Error
64 64
 	 */
65
-	protected function _add_ee_errors_to_response( \WP_Error $wp_error_response ) {
65
+	protected function _add_ee_errors_to_response(\WP_Error $wp_error_response) {
66 66
 		$notices_during_checkin = \EE_Error::get_raw_notices();
67
-		if( ! empty( $notices_during_checkin[ 'errors' ] ) ) {	
68
-			foreach( $notices_during_checkin[ 'errors' ] as $error_code => $error_message ) {
67
+		if ( ! empty($notices_during_checkin['errors'])) {	
68
+			foreach ($notices_during_checkin['errors'] as $error_code => $error_message) {
69 69
 				$wp_error_response->add( 
70
-					sanitize_key( $error_code ), 
71
-					strip_tags( $error_message ) );
70
+					sanitize_key($error_code), 
71
+					strip_tags($error_message) );
72 72
 			}
73 73
 		}
74 74
 		return $wp_error_response;
@@ -86,28 +86,28 @@  discard block
 block discarded – undo
86 86
 	 * @param array|\WP_Error|\Exception $response
87 87
 	 * @return \WP_REST_Response
88 88
 	 */
89
-	public function send_response( $response ) {
90
-		if( $response instanceof \Exception ) {
91
-			$response = new \WP_Error( $response->getCode(), $response->getMessage() );
89
+	public function send_response($response) {
90
+		if ($response instanceof \Exception) {
91
+			$response = new \WP_Error($response->getCode(), $response->getMessage());
92 92
 		}
93
-		if( $response instanceof \WP_Error ) {
94
-			$response = $this->_add_ee_errors_to_response( $response );
95
-			$rest_response = $this->_create_rest_response_from_wp_error( $response );
96
-		}else{
97
-			$rest_response = new \WP_REST_Response( $response, 200 );
93
+		if ($response instanceof \WP_Error) {
94
+			$response = $this->_add_ee_errors_to_response($response);
95
+			$rest_response = $this->_create_rest_response_from_wp_error($response);
96
+		} else {
97
+			$rest_response = new \WP_REST_Response($response, 200);
98 98
 		}
99 99
 		$headers = array();
100
-		if( $this->_debug_mode && is_array( $this->_debug_info ) ) {
101
-			foreach( $this->_debug_info  as $debug_key => $debug_info ) {
102
-				if( is_array( $debug_info ) ) {
103
-					$debug_info = json_encode( $debug_info );
100
+		if ($this->_debug_mode && is_array($this->_debug_info)) {
101
+			foreach ($this->_debug_info  as $debug_key => $debug_info) {
102
+				if (is_array($debug_info)) {
103
+					$debug_info = json_encode($debug_info);
104 104
 				}
105
-				$headers[ 'X-EE4-Debug-' . ucwords( $debug_key ) ] = $debug_info;
105
+				$headers['X-EE4-Debug-'.ucwords($debug_key)] = $debug_info;
106 106
 			}
107 107
 		}
108
-		$headers = array_merge( $headers, $this->_get_headers_from_ee_notices() );
108
+		$headers = array_merge($headers, $this->_get_headers_from_ee_notices());
109 109
 		
110
-		$rest_response->set_headers( $headers );
110
+		$rest_response->set_headers($headers);
111 111
 		return $rest_response;
112 112
 	}
113 113
 	
@@ -118,31 +118,31 @@  discard block
 block discarded – undo
118 118
 	 * @param \WP_Error $wp_error
119 119
 	 * @return \WP_REST_Response
120 120
 	 */
121
-	protected function _create_rest_response_from_wp_error( \WP_Error $wp_error ) {
121
+	protected function _create_rest_response_from_wp_error(\WP_Error $wp_error) {
122 122
 		$error_data = $wp_error->get_error_data();
123
-		if ( is_array( $error_data ) && isset( $error_data['status'] ) ) {
123
+		if (is_array($error_data) && isset($error_data['status'])) {
124 124
 			$status = $error_data['status'];
125 125
 		} else {
126 126
 			$status = 500;
127 127
 		}
128 128
 
129 129
 		$errors = array();
130
-		foreach ( (array) $wp_error->errors as $code => $messages ) {
131
-			foreach ( (array) $messages as $message ) {
130
+		foreach ((array) $wp_error->errors as $code => $messages) {
131
+			foreach ((array) $messages as $message) {
132 132
 				$errors[] = array(
133 133
 					'code'    => $code,
134 134
 					'message' => $message,
135
-					'data'    => $wp_error->get_error_data( $code )
135
+					'data'    => $wp_error->get_error_data($code)
136 136
 				);
137 137
 			}
138 138
 		}
139
-		$data = isset( $errors[0] ) ? $errors[0] : array();
140
-		if ( count( $errors ) > 1 ) {
139
+		$data = isset($errors[0]) ? $errors[0] : array();
140
+		if (count($errors) > 1) {
141 141
 			// Remove the primary error.
142
-			array_shift( $errors );
142
+			array_shift($errors);
143 143
 			$data['additional_errors'] = $errors;
144 144
 		}
145
-		return new \WP_REST_Response( $data, $status );
145
+		return new \WP_REST_Response($data, $status);
146 146
 	}
147 147
 	
148 148
 	/**
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	protected function _get_headers_from_ee_notices() {
153 153
 		$headers = array();
154 154
 		$notices = \EE_Error::get_raw_notices();
155
-		foreach( $notices as $notice_type => $sub_notices ) {
156
-			if( ! is_array( $sub_notices ) ) {
155
+		foreach ($notices as $notice_type => $sub_notices) {
156
+			if ( ! is_array($sub_notices)) {
157 157
 				continue;
158 158
 			}
159
-			foreach( $sub_notices as $notice_code => $sub_notice ) {
160
-				$headers[ 'X-EE4-Notices-' . \EEH_Inflector::humanize( $notice_type ) . '[' . $notice_code . ']' ] = strip_tags( $sub_notice );
159
+			foreach ($sub_notices as $notice_code => $sub_notice) {
160
+				$headers['X-EE4-Notices-'.\EEH_Inflector::humanize($notice_type).'['.$notice_code.']'] = strip_tags($sub_notice);
161 161
 			}
162 162
 		}
163 163
 		return apply_filters( 
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 	 * @param string $route 
176 176
 	 * @return string
177 177
 	 */
178
-	public function get_requested_version( $route ) {
178
+	public function get_requested_version($route) {
179 179
 		$matches = $this->parse_route(
180 180
 			$route,
181
-			'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '~',
182
-			array( 'version' )
181
+			'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'~',
182
+			array('version')
183 183
 			);
184
-		if( isset( $matches[ 'version' ] ) ) {
185
-			return $matches[ 'version' ];
184
+		if (isset($matches['version'])) {
185
+			return $matches['version'];
186 186
 		} else {
187 187
 			return \EED_Core_Rest_Api::latest_rest_api_version();
188 188
 		}
@@ -207,23 +207,23 @@  discard block
 block discarded – undo
207 207
 	 * array( 'model' => 'foo', 'id' => 'bar' )
208 208
 	 * @throws \EE_Error if it couldn't be parsed
209 209
 	 */
210
-	public function parse_route( $route, $regex, $match_keys ) {
210
+	public function parse_route($route, $regex, $match_keys) {
211 211
 		$indexed_matches = array();
212
-		$success = preg_match( $regex, $route, $matches );
213
-		if(
214
-			is_array( $matches ) ) {
212
+		$success = preg_match($regex, $route, $matches);
213
+		if (
214
+			is_array($matches) ) {
215 215
 			//skip the overall regex match. Who cares
216
-			for( $i = 1; $i <= count( $match_keys ); $i++ ) {
217
-				if( ! isset( $matches[ $i ] ) ) {
216
+			for ($i = 1; $i <= count($match_keys); $i++) {
217
+				if ( ! isset($matches[$i])) {
218 218
 					$success = false;
219 219
 				} else {
220
-					$indexed_matches[ $match_keys[ $i - 1 ] ] = $matches[ $i ];
220
+					$indexed_matches[$match_keys[$i - 1]] = $matches[$i];
221 221
 				}
222 222
 			}
223 223
 		}
224
-		if( ! $success ) {
224
+		if ( ! $success) {
225 225
 			throw new \EE_Error(
226
-				__( 'We could not parse the URL. Please contact Event Espresso Support', 'event_espresso' ),
226
+				__('We could not parse the URL. Please contact Event Espresso Support', 'event_espresso'),
227 227
 				'endpoint_parsing_error'
228 228
 			);
229 229
 		}
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Meta.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\libraries\rest_api\controllers\model;
3
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
4
-	exit( 'No direct script access allowed' );
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 /**
@@ -22,20 +22,20 @@  discard block
 block discarded – undo
22 22
 	 * @param \WP_REST_Request $request
23 23
 	 * @return array|\WP_REST_Response
24 24
 	 */
25
-	public static function handle_request_models_meta( \WP_REST_Request $request ) {
25
+	public static function handle_request_models_meta(\WP_REST_Request $request) {
26 26
 		$controller = new Meta();
27
-		try{
27
+		try {
28 28
 			$matches = $controller->parse_route(
29 29
 				$request->get_route(),
30
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . 'resources~',
31
-				array( 'version' ) );
32
-			if( $matches instanceof \WP_REST_Response ) {
30
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'resources~',
31
+				array('version') );
32
+			if ($matches instanceof \WP_REST_Response) {
33 33
 				return $matches;
34 34
 			}
35
-			$controller->set_requested_version( $matches[ 'version' ] );
36
-			return $controller->send_response( $controller->_get_models_metadata_entity() );
37
-		} catch( \Exception $e ) {
38
-			return $controller->send_response( $e );
35
+			$controller->set_requested_version($matches['version']);
36
+			return $controller->send_response($controller->_get_models_metadata_entity());
37
+		} catch (\Exception $e) {
38
+			return $controller->send_response($e);
39 39
 		}
40 40
 	}
41 41
 
@@ -43,58 +43,58 @@  discard block
 block discarded – undo
43 43
 	 * Gets the model metadata resource entity
44 44
 	 * @return array for JSON response, describing all the models available in teh requested version
45 45
 	 */
46
-	protected function _get_models_metadata_entity(){
46
+	protected function _get_models_metadata_entity() {
47 47
 		$response = array();
48
-		foreach( $this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname ){
49
-			$model = $this->get_model_version_info()->load_model( $model_name );
48
+		foreach ($this->get_model_version_info()->models_for_requested_version() as $model_name => $model_classname) {
49
+			$model = $this->get_model_version_info()->load_model($model_name);
50 50
 			$fields_json = array();
51
-			foreach( $this->get_model_version_info()->fields_on_model_in_this_version( $model ) as $field_name => $field_obj ) {
52
-				if( $this->get_model_version_info()->field_is_ignored( $field_obj ) ) {
51
+			foreach ($this->get_model_version_info()->fields_on_model_in_this_version($model) as $field_name => $field_obj) {
52
+				if ($this->get_model_version_info()->field_is_ignored($field_obj)) {
53 53
 					continue;
54 54
 				}
55
-				if( $field_obj instanceof \EE_Boolean_Field ) {
55
+				if ($field_obj instanceof \EE_Boolean_Field) {
56 56
 					$datatype = 'Boolean';
57
-				}elseif( $field_obj->get_wpdb_data_type() == '%d' ) {
57
+				}elseif ($field_obj->get_wpdb_data_type() == '%d') {
58 58
 					$datatype = 'Number';
59
-				}elseif( $field_name instanceof \EE_Serialized_Text_Field ) {
59
+				}elseif ($field_name instanceof \EE_Serialized_Text_Field) {
60 60
 					$datatype = 'Object';
61
-				}else{
61
+				} else {
62 62
 					$datatype = 'String';
63 63
 				}
64 64
 				$default_value = $field_obj->get_default_value();
65
-				if( $default_value === EE_INF ) {
65
+				if ($default_value === EE_INF) {
66 66
 					$default_value = EE_INF_IN_DB;
67
-				} elseif( $field_obj instanceof \EE_Datetime_Field &&
68
-					$default_value instanceof \DateTime ) {
69
-					$default_value = $default_value->format( 'c' );
67
+				} elseif ($field_obj instanceof \EE_Datetime_Field &&
68
+					$default_value instanceof \DateTime) {
69
+					$default_value = $default_value->format('c');
70 70
 				}
71 71
 				$field_json = array(
72 72
 					'name' => $field_name,
73 73
 					'nicename' => $field_obj->get_nicename(),
74
-					'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format( $field_obj ),
75
-					'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format( $field_obj ),
76
-					'type' => str_replace('EE_', '', get_class( $field_obj ) ),
74
+					'has_rendered_format' => $this->get_model_version_info()->field_has_rendered_format($field_obj),
75
+					'has_pretty_format' => $this->get_model_version_info()->field_has_pretty_format($field_obj),
76
+					'type' => str_replace('EE_', '', get_class($field_obj)),
77 77
 					'datatype' => $datatype,
78 78
 					'nullable' => $field_obj->is_nullable(),
79 79
 					'default' => $default_value,
80 80
 					'table_alias' => $field_obj->get_table_alias(),
81 81
 					'table_column' => $field_obj->get_table_column(),
82 82
 				);
83
-				$fields_json[ $field_json[ 'name' ] ] = $field_json;
83
+				$fields_json[$field_json['name']] = $field_json;
84 84
 
85 85
 			}
86
-			$fields_json = array_merge( $fields_json, $this->get_model_version_info()->extra_resource_properties_for_model( $model ) );
87
-			$response[ $model_name ]['fields'] = apply_filters( 'FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model );
86
+			$fields_json = array_merge($fields_json, $this->get_model_version_info()->extra_resource_properties_for_model($model));
87
+			$response[$model_name]['fields'] = apply_filters('FHEE__Meta__handle_request_models_meta__fields', $fields_json, $model);
88 88
 			$relations_json = array();
89
-			foreach( $model->relation_settings()  as $relation_name => $relation_obj ) {
89
+			foreach ($model->relation_settings()  as $relation_name => $relation_obj) {
90 90
 				$relation_json = array(
91 91
 					'name' => $relation_name,
92
-					'type' => str_replace( 'EE_', '', get_class( $relation_obj ) ),
92
+					'type' => str_replace('EE_', '', get_class($relation_obj)),
93 93
 					'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false,
94 94
 				);
95
-				$relations_json[ $relation_name ] = $relation_json;
95
+				$relations_json[$relation_name] = $relation_json;
96 96
 			}
97
-			$response[ $model_name ][ 'relations' ] = apply_filters( 'FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model );
97
+			$response[$model_name]['relations'] = apply_filters('FHEE__Meta__handle_request_models_meta__relations', $relations_json, $model);
98 98
 		}
99 99
 		return $response;
100 100
 	}
@@ -104,23 +104,23 @@  discard block
 block discarded – undo
104 104
 	 * @param \WP_REST_Response $rest_response_obj
105 105
 	 * @return \WP_REST_Response
106 106
 	 */
107
-	public static function filter_ee_metadata_into_index( \WP_REST_Response $rest_response_obj ) {
107
+	public static function filter_ee_metadata_into_index(\WP_REST_Response $rest_response_obj) {
108 108
 		$response_data = $rest_response_obj->get_data();
109 109
 		$addons = array();
110
-		foreach( \EE_Registry::instance()->addons as $addon){
110
+		foreach (\EE_Registry::instance()->addons as $addon) {
111 111
 			$addon_json = array(
112 112
 				'name' => $addon->name(),
113 113
 				'version' => $addon->version()
114 114
 			);
115
-			$addons[ $addon_json[ 'name' ] ] = $addon_json;
115
+			$addons[$addon_json['name']] = $addon_json;
116 116
 		}
117
-		$response_data[ 'ee' ] = array(
117
+		$response_data['ee'] = array(
118 118
 			'version' => \EEM_System_Status::instance()->get_ee_version(),
119 119
 			'addons' => $addons,
120 120
 			'maintenance_mode' => \EE_Maintenance_Mode::instance()->real_level(),
121
-			'served_core_versions' => array_keys( \EED_Core_Rest_Api::versions_served() )
121
+			'served_core_versions' => array_keys(\EED_Core_Rest_Api::versions_served())
122 122
 		);
123
-		$rest_response_obj->set_data( $response_data );
123
+		$rest_response_obj->set_data($response_data);
124 124
 		return $rest_response_obj;
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/rpc/Checkin.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\libraries\rest_api\controllers\Base as Base;
3 3
 use EventEspresso\core\libraries\rest_api\controllers\model\Read;
4 4
 
5
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
6
-	exit( 'No direct script access allowed' );
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 /**
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	 * @param \WP_REST_Request $request
25 25
 	 * @return \WP_Error|\WP_REST_Response
26 26
 	 */
27
-	public static function handle_request_toggle_checkin( \WP_REST_Request $request ) {
27
+	public static function handle_request_toggle_checkin(\WP_REST_Request $request) {
28 28
 		$controller = new Checkin();
29
-		return $controller->_create_checkin_checkout_object( $request );
29
+		return $controller->_create_checkin_checkout_object($request);
30 30
 	}
31 31
 
32 32
 
@@ -37,47 +37,47 @@  discard block
 block discarded – undo
37 37
 	 * @param \WP_REST_Request $request
38 38
 	 * @return \WP_Error|\WP_REST_Response
39 39
 	 */
40
-	protected function _create_checkin_checkout_object( \WP_REST_Request $request ) {
41
-		$reg_id = $request->get_param( 'REG_ID' );
42
-		$dtt_id = $request->get_param( 'DTT_ID' );
43
-		$force = $request->get_param( 'force' );
44
-		if( $force == 'true' ) {
40
+	protected function _create_checkin_checkout_object(\WP_REST_Request $request) {
41
+		$reg_id = $request->get_param('REG_ID');
42
+		$dtt_id = $request->get_param('DTT_ID');
43
+		$force = $request->get_param('force');
44
+		if ($force == 'true') {
45 45
 			$force = true;
46 46
 		} else {
47 47
 			$force = false;
48 48
 		}
49
-		$reg = \EEM_Registration::instance()->get_one_by_ID( $reg_id );
50
-		if( ! $reg instanceof \EE_Registration ) {
49
+		$reg = \EEM_Registration::instance()->get_one_by_ID($reg_id);
50
+		if ( ! $reg instanceof \EE_Registration) {
51 51
 			return $this->send_response(
52 52
 				new \WP_Error(
53 53
 					'rest_registration_toggle_checkin_invalid_id',
54 54
 					sprintf(
55
-						__( 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso' ),
55
+						__('You cannot checkin registration with ID %1$s because it doesn\'t exist.', 'event_espresso'),
56 56
 						$reg_id
57 57
 					),
58
-					array( 'status' => 422 )
58
+					array('status' => 422)
59 59
 				)
60 60
 			);
61 61
 		}
62
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id ) ) {
62
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) {
63 63
 			return $this->send_response(
64 64
 				new \WP_Error(
65 65
 					'rest_user_cannot_toggle_checkin',
66 66
 					sprintf(
67
-						__( 'You are not allowed to checkin registration with ID %1$s.', 'event_espresso' ),
67
+						__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'),
68 68
 						$reg_id
69 69
 					),
70
-					array( 'status' => 403 )
70
+					array('status' => 403)
71 71
 				)
72 72
 			);
73 73
 		}
74
-		$success = $reg->toggle_checkin_status( $dtt_id, ! $force );
75
-		if( $success === false ) {
74
+		$success = $reg->toggle_checkin_status($dtt_id, ! $force);
75
+		if ($success === false) {
76 76
 			//rely on EE_Error::add_error messages to have been added to give more data about hwy it failed
77 77
 			return $this->send_response(
78 78
 				new \WP_Error(
79 79
 					'rest_toggle_checkin_failed',
80
-					__( 'Registration checkin failed. Please see additional error data.', 'event_espresso' )
80
+					__('Registration checkin failed. Please see additional error data.', 'event_espresso')
81 81
 				)
82 82
 			);
83 83
 		}
@@ -92,28 +92,28 @@  discard block
 block discarded – undo
92 92
 				)
93 93
 			)
94 94
 		);
95
-		if( ! $checkin instanceof \EE_Checkin ) {
95
+		if ( ! $checkin instanceof \EE_Checkin) {
96 96
 			return $this->send_response(
97 97
 				new \WP_Error(
98 98
 					'rest_toggle_checkin_error',
99 99
 					sprintf(
100
-						__( 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso' ),
100
+						__('Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', 'event_espresso'),
101 101
 						$reg_id,
102 102
 						$dtt_id
103 103
 					)
104 104
 				)
105 105
 			);
106 106
 		}
107
-		$requested_version = $this->get_requested_version( $request->get_route() );
107
+		$requested_version = $this->get_requested_version($request->get_route());
108 108
 		$get_request = new \WP_REST_Request(
109 109
 			'GET',
110
-			\EED_Core_Rest_Api::ee_api_namespace . $requested_version . '/checkins/' . $checkin->ID()
110
+			\EED_Core_Rest_Api::ee_api_namespace.$requested_version.'/checkins/'.$checkin->ID()
111 111
 		);
112 112
 		$get_request->set_url_params(
113 113
 			array(
114 114
 				'id' => $checkin->ID()
115 115
 			)
116 116
 		);
117
-		return Read::handle_request_get_one( $get_request );
117
+		return Read::handle_request_get_one($get_request);
118 118
 	}
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.
core/middleware/EE_Recommended_Versions.core.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -22,35 +22,35 @@  discard block
 block discarded – undo
22 22
 	 * @param 	EE_Response $response
23 23
 	 * @return 	EE_Response
24 24
 	 */
25
-	public function handle_request( EE_Request $request, EE_Response $response ) {
25
+	public function handle_request(EE_Request $request, EE_Response $response) {
26 26
 		$this->_request = $request;
27 27
 		$this->_response = $response;
28 28
 		//$this->_response->add_output( "\n\t IN >>  " . __CLASS__ );
29 29
 		//$this->_response->set_notice( 1, 'hey look at this' );
30 30
 		// check required WP version
31
-		if ( ! $this->_minimum_wp_version_required() ) {
32
-			$this->_request->un_set( 'activate', true );
33
-			add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 );
31
+		if ( ! $this->_minimum_wp_version_required()) {
32
+			$this->_request->un_set('activate', true);
33
+			add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1);
34 34
 			//$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' );
35 35
 			$this->_response->terminate_request();
36 36
 		}
37 37
 		// check required PHP version
38
-		if ( ! $this->_minimum_php_version_required() ) {
39
-			$this->_request->un_set( 'activate', true );
40
-			add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 );
38
+		if ( ! $this->_minimum_php_version_required()) {
39
+			$this->_request->un_set('activate', true);
40
+			add_action('admin_notices', array($this, 'minimum_php_version_error'), 1);
41 41
 			//$this->_response->add_output( "\n<br />" . 'minimum_php_version_error' );
42 42
 			$this->_response->terminate_request();
43 43
 		}
44 44
 		// check recommended WP version
45
-		if ( ! $this->_minimum_wp_version_recommended() ) {
45
+		if ( ! $this->_minimum_wp_version_recommended()) {
46 46
 			$this->_display_minimum_recommended_wp_version_notice();
47 47
 		}
48 48
 		// check recommended PHP version
49
-		if ( ! $this->_minimum_php_version_recommended() ) {
49
+		if ( ! $this->_minimum_php_version_recommended()) {
50 50
 			$this->_display_minimum_recommended_php_version_notice();
51 51
 		}
52 52
 		$this->_test_for_php_version_7();
53
-		$this->_response = $this->process_request_stack( $this->_request, $this->_response );
53
+		$this->_response = $this->process_request_stack($this->_request, $this->_response);
54 54
 		//$this->_response->add_output( "\n\t OUT << " . __CLASS__ );
55 55
 		return $this->_response;
56 56
 	}
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 	 * @param string $min_version
65 65
 	 * @return boolean
66 66
 	 */
67
-	private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) {
67
+	private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) {
68 68
 		global $wp_version;
69
-		return version_compare( $wp_version, $min_version, '>=' ) ? true : false;
69
+		return version_compare($wp_version, $min_version, '>=') ? true : false;
70 70
 	}
71 71
 
72 72
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return boolean
79 79
 	 */
80 80
 	private function _minimum_wp_version_required() {
81
-		return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED );
81
+		return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED);
82 82
 	}
83 83
 
84 84
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @return boolean
91 91
 	 */
92 92
 	private function _minimum_wp_version_recommended() {
93
-		return $this->_check_wp_version( EE_MIN_WP_VER_RECOMMENDED );
93
+		return $this->_check_wp_version(EE_MIN_WP_VER_RECOMMENDED);
94 94
 	}
95 95
 
96 96
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @param string $min_version
103 103
 	 * @return boolean
104 104
 	 */
105
-	private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) {
106
-		return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false;
105
+	private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) {
106
+		return version_compare(PHP_VERSION, $min_version, '>=') ? true : false;
107 107
 	}
108 108
 
109 109
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @return boolean
116 116
 	 */
117 117
 	private function _minimum_php_version_required() {
118
-		return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED );
118
+		return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED);
119 119
 	}
120 120
 
121 121
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return boolean
128 128
 	 */
129 129
 	private function _minimum_php_version_recommended() {
130
-		return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED );
130
+		return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED);
131 131
 	}
132 132
 
133 133
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			<p>
145 145
 				<?php
146 146
 				printf(
147
-					__( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ),
147
+					__('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'),
148 148
 					EE_MIN_WP_VER_REQUIRED,
149 149
 					$wp_version,
150 150
 					'<br/>',
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			<p>
170 170
 				<?php
171 171
 				printf(
172
-					__( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ),
172
+					__('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'),
173 173
 					EE_MIN_PHP_VER_REQUIRED,
174 174
 					PHP_VERSION,
175 175
 					'<br/>',
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	private function _display_minimum_recommended_wp_version_notice() {
193 193
 		global $wp_version;
194 194
 		EE_Error::add_persistent_admin_notice(
195
-			'wp_version_' . str_replace( '.', '-', EE_MIN_WP_VER_RECOMMENDED ) . '_recommended',
195
+			'wp_version_'.str_replace('.', '-', EE_MIN_WP_VER_RECOMMENDED).'_recommended',
196 196
 			sprintf(
197
-				__( 'Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ),
197
+				__('Event Espresso recommends WordPress version %1$s or greater in order for everything to operate properly. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'),
198 198
 				EE_MIN_WP_VER_RECOMMENDED,
199 199
 				$wp_version,
200 200
 				'<br/>',
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 	 */
214 214
 	private function _display_minimum_recommended_php_version_notice() {
215 215
 		EE_Error::add_persistent_admin_notice(
216
-			'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended',
216
+			'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended',
217 217
 			sprintf(
218
-				__( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ),
218
+				__('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'),
219 219
 				EE_MIN_PHP_VER_RECOMMENDED,
220 220
 				PHP_VERSION,
221 221
 				'<br/>',
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 	 * @access private
233 233
 	 */
234 234
 	private function _test_for_php_version_7() {
235
-		if ( $this->_check_php_version( '7' ) ) {
236
-			define( 'EE_PHP_7', true );
235
+		if ($this->_check_php_version('7')) {
236
+			define('EE_PHP_7', true);
237 237
 		} else {
238
-			define( 'EE_PHP_7', false );
238
+			define('EE_PHP_7', false);
239 239
 		}
240 240
 	}
241 241
 
Please login to merge, or discard this patch.
modules/core_rest_api/EED_Core_Rest_Api.module.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @return EED_Core_Rest_Api
28 28
 	 */
29 29
 	public static function instance() {
30
-		return parent::get_instance( __CLASS__ );
30
+		return parent::get_instance(__CLASS__);
31 31
 	}
32 32
 
33 33
 
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
 	public static function set_hooks_both() {
60
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 );
61
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 );
62
-		add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 );
63
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
60
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10);
61
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5);
62
+		add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2);
63
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
64 64
 	}
65 65
 
66 66
 	/**
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 	}
74 74
 
75 75
 	protected static function _set_hooks_for_changes() {
76
-		$folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false );
77
-		foreach( $folder_contents as $classname_in_namespace => $filepath ) {
76
+		$folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false);
77
+		foreach ($folder_contents as $classname_in_namespace => $filepath) {
78 78
 			//ignore the base parent class
79
-			if( $classname_in_namespace === 'Changes_In_Base' ) {
79
+			if ($classname_in_namespace === 'Changes_In_Base') {
80 80
 				continue;
81 81
 			}
82
-			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
83
-			if ( class_exists( $full_classname )) {
82
+			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace;
83
+			if (class_exists($full_classname)) {
84 84
 				$instance_of_class = new $full_classname;
85
-				if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) {
85
+				if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) {
86 86
 					$instance_of_class->set_hooks();
87 87
 				}
88 88
 			}
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
96 96
 	 */
97 97
 	public static function register_routes() {
98
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
99
-			foreach( $relative_urls as $endpoint => $routes ) {
100
-				foreach( $routes as $route ) {
98
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
99
+			foreach ($relative_urls as $endpoint => $routes) {
100
+				foreach ($routes as $route) {
101 101
 					register_rest_route(
102 102
 						$namespace,
103 103
 						$endpoint,
104 104
 						array(
105
-							'callback' => $route[ 'callback' ],
106
-							'methods' => $route[ 'methods' ],
107
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
105
+							'callback' => $route['callback'],
106
+							'methods' => $route['methods'],
107
+							'args' => isset($route['args']) ? $route['args'] : array(),
108 108
 						)
109 109
 					);
110 110
 				}
@@ -121,10 +121,10 @@  discard block
 block discarded – undo
121 121
 	 * }
122 122
 	 */
123 123
 	public static function get_ee_route_data() {
124
-		$ee_routes = get_option( self::saved_routes_option_names, null );
125
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
124
+		$ee_routes = get_option(self::saved_routes_option_names, null);
125
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
126 126
 			self::save_ee_routes();
127
-			$ee_routes = get_option( self::saved_routes_option_names, array() );
127
+			$ee_routes = get_option(self::saved_routes_option_names, array());
128 128
 		}
129 129
 		return $ee_routes;
130 130
 	}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return void
136 136
 	 */
137 137
 	public static function save_ee_routes() {
138
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
138
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
139 139
 			$instance = self::instance();
140 140
 			$routes = apply_filters(
141 141
 				'EED_Core_Rest_Api__save_ee_routes__routes',
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 					$instance->_register_rpc_routes()
147 147
 				)
148 148
 			);
149
-			update_option( self::saved_routes_option_names, $routes, true );
149
+			update_option(self::saved_routes_option_names, $routes, true);
150 150
 		}
151 151
 	}
152 152
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @return array @see get_ee_route_data
156 156
 	 */
157 157
 	protected function _register_model_routes() {
158
-		EE_Registry::instance()->load_helper( 'Inflector' );
158
+		EE_Registry::instance()->load_helper('Inflector');
159 159
 		$models_to_register = apply_filters(
160 160
 			'FHEE__EED_Core_REST_API___register_model_routes',
161 161
 			EE_Registry::instance()->non_abstract_db_models
@@ -164,23 +164,23 @@  discard block
 block discarded – undo
164 164
 		unset($models_to_register['Extra_Meta']);
165 165
 		unset($models_to_register['Extra_Join']);
166 166
 		$model_routes = array( );
167
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
167
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
168 168
 
169
-			foreach ( $models_to_register as $model_name => $model_classname ) {
169
+			foreach ($models_to_register as $model_name => $model_classname) {
170 170
 				//yes we could just register one route for ALL models, but then they wouldn't show up in the index
171
-				$ee_namespace = self::ee_api_namespace . $version;
172
-				$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
173
-				$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
174
-				$model_routes[ $ee_namespace ][ $plural_model_route ] = array(
171
+				$ee_namespace = self::ee_api_namespace.$version;
172
+				$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
173
+				$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
174
+				$model_routes[$ee_namespace][$plural_model_route] = array(
175 175
 						array(
176 176
 							'callback' => array(
177 177
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
178 178
 								'handle_request_get_all' ),
179 179
 							'methods' => WP_REST_Server::READABLE,
180 180
 							'hidden_endpoint' => $hidden_endpoint,
181
-							'args' => $this->_get_read_query_params( $model_name ),
181
+							'args' => $this->_get_read_query_params($model_name),
182 182
 							'_links' => array(
183
-								'self' => rest_url( $ee_namespace . $singular_model_route ),
183
+								'self' => rest_url($ee_namespace.$singular_model_route),
184 184
 							)
185 185
 						),
186 186
 //						array(
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 //							'hidden_endpoint' => $hidden_endpoint
192 192
 //						)
193 193
 					);
194
-				$model_routes[ $ee_namespace ][ $singular_model_route ] = array(
194
+				$model_routes[$ee_namespace][$singular_model_route] = array(
195 195
 						array(
196 196
 							'callback' => array(
197 197
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 								'include' => array(
203 203
 									'required' => false,
204 204
 									'default' => '*',
205
-									'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
205
+									'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
206 206
 								),
207 207
 							)
208 208
 						),
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 //							),
216 216
 				);
217 217
 				//@todo: also handle  DELETE for a single item
218
-				$model = EE_Registry::instance()->load_model( $model_classname );
219
-				foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
218
+				$model = EE_Registry::instance()->load_model($model_classname);
219
+				foreach ($model->relation_settings() as $relation_name => $relation_obj) {
220 220
 					$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
221 221
 						$relation_name,
222 222
 						$relation_obj
223 223
 					);
224
-					$model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
224
+					$model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
225 225
 							array(
226 226
 								'callback' => array(
227 227
 									'EventEspresso\core\libraries\rest_api\controllers\model\Read',
228 228
 									'handle_request_get_related' ),
229 229
 								'methods' => WP_REST_Server::READABLE,
230 230
 								'hidden_endpoint' => $hidden_endpoint,
231
-								'args' => $this->_get_read_query_params( $relation_name ),
231
+								'args' => $this->_get_read_query_params($relation_name),
232 232
 							),
233 233
 //							array(
234 234
 //								'callback' => array(
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	protected function _register_rpc_routes() {
254 254
 		$routes = array();
255
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
256
-			$ee_namespace = self::ee_api_namespace . $version;
255
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
256
+			$ee_namespace = self::ee_api_namespace.$version;
257 257
 			$this_versions_routes = array();
258 258
 			//checkin endpoint
259
-			$this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array(
259
+			$this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array(
260 260
 				array(
261 261
 					'callback' => array(
262 262
 						'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 						'force' => array(
268 268
 							'required' => false,
269 269
 							'default' => false,
270
-							'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' )
270
+							'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso')
271 271
 						)
272 272
 					)
273 273
 				)
274 274
 			);
275
-			$routes[ $ee_namespace ] = apply_filters(
275
+			$routes[$ee_namespace] = apply_filters(
276 276
 				'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
277 277
 				$this_versions_routes,
278 278
 				$version,
@@ -287,47 +287,47 @@  discard block
 block discarded – undo
287 287
 	 * @param string $model_name eg 'Event' or 'Venue'
288 288
 	 * @return array describing the args acceptable when querying this model
289 289
 	 */
290
-	protected function _get_read_query_params( $model_name ) {
291
-		$model = EE_Registry::instance()->load_model( $model_name );
290
+	protected function _get_read_query_params($model_name) {
291
+		$model = EE_Registry::instance()->load_model($model_name);
292 292
 		$default_orderby = array();
293
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
294
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
293
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
294
+			$default_orderby[$key_field->get_name()] = 'ASC';
295 295
 		}
296 296
 		return array(
297 297
 			'where' => array(
298 298
 				'required' => false,
299 299
 				'default' => array(),
300
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ),
300
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'),
301 301
 				),
302 302
 			'limit' => array(
303 303
 				'required' => false,
304 304
 				'default' => 50,
305
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' )
305
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso')
306 306
 			),
307 307
 			'order_by' => array(
308 308
 				'required' => false,
309 309
 				'default' => $default_orderby,
310
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' )
310
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso')
311 311
 			),
312 312
 			'group_by' => array(
313 313
 				'required' => false,
314 314
 				'default' => null,
315
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' )
315
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso')
316 316
 			),
317 317
 			'having' => array(
318 318
 				'required' => false,
319 319
 				'default' => null,
320
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' )
320
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso')
321 321
 			),
322 322
 			'caps' => array(
323 323
 				'required' => false,
324 324
 				'default' => EEM_Base::caps_read,
325
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' )
325
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso')
326 326
 			),
327 327
 			'include' => array(
328 328
 				'required' => false,
329 329
 				'default' => '*',
330
-				'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
330
+				'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
331 331
 			),
332 332
 		);
333 333
 	}
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	protected function _register_config_routes() {
340 340
 		$config_routes = array();
341
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
342
-			$config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array(
341
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
342
+			$config_routes[self::ee_api_namespace.$version]['config'] = array(
343 343
 					array(
344 344
 						'callback' => array(
345 345
 							'EventEspresso\core\libraries\rest_api\controllers\config\Read',
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 */
359 359
 	protected function _register_meta_routes() {
360 360
 		$meta_routes = array();
361
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
362
-			$meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array(
361
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
362
+			$meta_routes[self::ee_api_namespace.$version]['/resources'] = array(
363 363
 				array(
364 364
 					'callback' => array(
365 365
 						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	 * @param array $route_data
381 381
 	 * @return array
382 382
 	 */
383
-	public static function hide_old_endpoints( $route_data ) {
384
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
385
-			foreach( $relative_urls as $endpoint => $routes ) {
386
-				foreach( $routes as $route ) {
387
-					if( $route[ 'hidden_endpoint' ] ) {
388
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
389
-						unset( $route_data[ $full_route ] );
383
+	public static function hide_old_endpoints($route_data) {
384
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
385
+			foreach ($relative_urls as $endpoint => $routes) {
386
+				foreach ($routes as $route) {
387
+					if ($route['hidden_endpoint']) {
388
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
389
+						unset($route_data[$full_route]);
390 390
 					}
391 391
 				}
392 392
 			}
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	public static function latest_rest_api_version() {
425 425
 		$versions_served = \EED_Core_Rest_Api::versions_served();
426
-		return end( array_keys( $versions_served ) );
426
+		return end(array_keys($versions_served));
427 427
 	}
428 428
 
429 429
 	/**
@@ -437,32 +437,32 @@  discard block
 block discarded – undo
437 437
 	public static function versions_served() {
438 438
 		$versions_served = array();
439 439
 		$possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
440
-		$lowest_compatible_version = end( $possibly_served_versions);
441
-		reset( $possibly_served_versions );
442
-		$versions_served_historically = array_keys( $possibly_served_versions );
443
-		$latest_version = end( $versions_served_historically );
444
-		reset( $versions_served_historically );
440
+		$lowest_compatible_version = end($possibly_served_versions);
441
+		reset($possibly_served_versions);
442
+		$versions_served_historically = array_keys($possibly_served_versions);
443
+		$latest_version = end($versions_served_historically);
444
+		reset($versions_served_historically);
445 445
 		//for each version of core we have ever served:
446
-		foreach ( $versions_served_historically as $key_versioned_endpoint ) {
446
+		foreach ($versions_served_historically as $key_versioned_endpoint) {
447 447
 			//if it's not above the current core version, and it's compatible with the current version of core
448
-			if( $key_versioned_endpoint == $latest_version ) {
448
+			if ($key_versioned_endpoint == $latest_version) {
449 449
 				//don't hide the latest version in the index
450
-				$versions_served[ $key_versioned_endpoint ] = false;
451
-			} else if(
450
+				$versions_served[$key_versioned_endpoint] = false;
451
+			} else if (
452 452
 				$key_versioned_endpoint < EED_Core_Rest_Api::core_version()
453 453
 				&& $key_versioned_endpoint >= $lowest_compatible_version
454 454
 			) {
455 455
 				//include, but hide, previous versions which are still supported
456
-				$versions_served[ $key_versioned_endpoint ] = true;
457
-			} elseif(
456
+				$versions_served[$key_versioned_endpoint] = true;
457
+			} elseif (
458 458
 				apply_filters(
459 459
 					'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
460 460
 					false,
461 461
 					$possibly_served_versions
462 462
 				)
463
-			){
463
+			) {
464 464
 				//if a version is no longer supported, don't include it in index or list of versions served
465
-				$versions_served[ $key_versioned_endpoint ] = true;
465
+				$versions_served[$key_versioned_endpoint] = true;
466 466
 			}
467 467
 		}
468 468
 		return $versions_served;
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 	 * @return string
476 476
 	 */
477 477
 	public static function core_version() {
478
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
478
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
479 479
 	}
480 480
 
481 481
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 	 * @param  WP $WP
488 488
 	 * @return    void
489 489
 	 */
490
-	public function run( $WP ) {
490
+	public function run($WP) {
491 491
 
492 492
 	}
493 493
 
Please login to merge, or discard this patch.