Completed
Branch BUG-9804-double-click-spco-sub... (c2cac1)
by
unknown
42:11 queued 32:59
created
core/libraries/plugin_api/EE_Register_Addon.lib.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@
 block discarded – undo
275 275
 				//we know it was just activated and the request will end soon
276 276
 			}
277 277
 			return;
278
-		}else{
278
+		} else{
279 279
 			// make sure this was called in the right place!
280 280
 			if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) {
281 281
 				EE_Error::doing_it_wrong(
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -138,10 +138,10 @@
 block discarded – undo
138 138
 	 *       		 An array of message types with the key as the message type name and the values as below:
139 139
 	 *        		@type string $mtfilename The filename of the message type being registered.  This will be the main
140 140
 	 *                                       EE_{Messagetype_Name}_message_type class. (eg. EE_Declined_Registration_message_type.class.php). Required.
141
-	*               @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required.
142
-	*               @type array $messengers_to_activate_with An array of messengers that this message
143
-	*                           type should activate with. Each value in the array should match the name property of a EE_messenger. Optional.
144
-	*               @type array $messengers_to_validate_with An array of messengers that this message
141
+	 *               @type array $autoloadpaths An array of paths to add to the messages autoloader for the new message type. Required.
142
+	 *               @type array $messengers_to_activate_with An array of messengers that this message
143
+	 *                           type should activate with. Each value in the array should match the name property of a EE_messenger. Optional.
144
+	 *               @type array $messengers_to_validate_with An array of messengers that this message
145 145
 	 *                          type should validate with. Each value in the array should match the name property of an EE_messenger. Optional.
146 146
 	 *       	}
147 147
 	 *			@type array $custom_post_types
Please login to merge, or discard this 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/plugin_api/EE_Register_Admin_Page.lib.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
 class EE_Register_Admin_Page implements EEI_Plugin_API {
19 19
 
20 20
 
21
-    /**
22
-     * Holds registered EE_Admin_Pages
23
-     * @var array
24
-     */
25
-    protected static $_ee_admin_page_registry = array();
21
+	/**
22
+	 * Holds registered EE_Admin_Pages
23
+	 * @var array
24
+	 */
25
+	protected static $_ee_admin_page_registry = array();
26 26
 
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system).
32
-     *
33
-     * @since 4.3.0
34
-     *
30
+	/**
31
+	 * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE Admin Page loader system).
32
+	 *
33
+	 * @since 4.3.0
34
+	 *
35 35
 	 * @param  string $page_basename 	This string represents the basename of the Admin Page init.
36 36
 	 *                                                        		The init file must use this basename in its name and class (i.e. {page_basename}_Admin_Page_Init.core.php).
37
-     * @param  array  $config  {              An array of configuration options that will be used in different circumstances
37
+	 * @param  array  $config  {              An array of configuration options that will be used in different circumstances
38 38
 	 *
39 39
 	 *		@type  string $page_path             This is the path where the registered admin pages reside ( used to setup autoloaders).
40 40
 	 *
41 41
 	 * 	}
42
-     * @return void
43
-     */
44
-    public static function register( $page_basename = NULL, $config = array() ) {
42
+	 * @return void
43
+	 */
44
+	public static function register( $page_basename = NULL, $config = array() ) {
45 45
 
46 46
 		// check that an admin_page has not already been registered with that name
47 47
 		if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 
61 61
 		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) {
62
-            EE_Error::doing_it_wrong(
62
+			EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64 64
 				sprintf(
65 65
 					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'),
@@ -67,36 +67,36 @@  discard block
 block discarded – undo
67 67
 				),
68 68
 				'4.3'
69 69
 			);
70
-        }
70
+		}
71 71
 
72
-        //add incoming stuff to our registry property
73
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
74
-            'page_path' => $config['page_path'],
75
-            'config' => $config
76
-            );
72
+		//add incoming stuff to our registry property
73
+		self::$_ee_admin_page_registry[ $page_basename ] = array(
74
+			'page_path' => $config['page_path'],
75
+			'config' => $config
76
+			);
77 77
 
78
-       //add filters
78
+	   //add filters
79 79
 
80
-       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
-       add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
80
+	   add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
+	   add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
82 82
 
83
-    }
83
+	}
84 84
 
85 85
 
86 86
 
87
-    /**
88
-     * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
89
-     * page being deregistered is loaded.
90
-     *
91
-     * @since    4.3.0
92
-     *
93
-     * @param  string $page_basename Use whatever string was used to register the admin page.
94
-     * @return  void
95
-     */
96
-    public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
99
-    }
87
+	/**
88
+	 * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
89
+	 * page being deregistered is loaded.
90
+	 *
91
+	 * @since    4.3.0
92
+	 *
93
+	 * @param  string $page_basename Use whatever string was used to register the admin page.
94
+	 * @return  void
95
+	 */
96
+	public static function deregister( $page_basename = NULL ) {
97
+		if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
+			unset( self::$_ee_admin_page_registry[$page_basename] );
99
+	}
100 100
 
101 101
 
102 102
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 				$installed_refs[ $basename ] = $args['page_path'];
113 113
 			}
114 114
 		}
115
-        return $installed_refs;
116
-    }
115
+		return $installed_refs;
116
+	}
117 117
 
118 118
 
119 119
 
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 	 * @return mixed
125 125
 	 */
126 126
 	public static function set_page_path( $paths ) {
127
-        foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
-            $paths[ $basename ] = $args['page_path'];
129
-        }
130
-        return $paths;
131
-    }
127
+		foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
+			$paths[ $basename ] = $args['page_path'];
129
+		}
130
+		return $paths;
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -41,28 +41,28 @@  discard block
 block discarded – undo
41 41
 	 * 	}
42 42
      * @return void
43 43
      */
44
-    public static function register( $page_basename = NULL, $config = array() ) {
44
+    public static function register($page_basename = NULL, $config = array()) {
45 45
 
46 46
 		// check that an admin_page has not already been registered with that name
47
-		if ( isset(self::$_ee_admin_page_registry[ $page_basename ] )) {
48
-			throw new EE_Error( sprintf( __( 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso' ), $page_basename ));
47
+		if (isset(self::$_ee_admin_page_registry[$page_basename])) {
48
+			throw new EE_Error(sprintf(__('An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', 'event_espresso'), $page_basename));
49 49
 		}
50 50
 
51 51
 		// required fields MUST be present, so let's make sure they are.
52
-		if ( empty( $page_basename ) || ! is_array( $config ) || empty( $config['page_path'] )) {
53
-			throw new EE_Error( __( 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso' ));
52
+		if (empty($page_basename) || ! is_array($config) || empty($config['page_path'])) {
53
+			throw new EE_Error(__('In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', 'event_espresso'));
54 54
 		}
55 55
 
56 56
 		//make sure we don't register twice
57
-		if( isset( self::$_ee_admin_page_registry[ $page_basename ] ) ){
57
+		if (isset(self::$_ee_admin_page_registry[$page_basename])) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_Admin__loaded' )) {
61
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
62 62
             EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64 64
 				sprintf(
65
-					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.','event_espresso'),
65
+					__('An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', 'event_espresso'),
66 66
 					$page_basename
67 67
 				),
68 68
 				'4.3'
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
         }
71 71
 
72 72
         //add incoming stuff to our registry property
73
-        self::$_ee_admin_page_registry[ $page_basename ] = array(
73
+        self::$_ee_admin_page_registry[$page_basename] = array(
74 74
             'page_path' => $config['page_path'],
75 75
             'config' => $config
76 76
             );
77 77
 
78 78
        //add filters
79 79
 
80
-       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array( 'EE_Register_Admin_Page', 'set_page_basename' ), 10 );
81
-       add_filter('FHEE__EEH_Autoloader__load_admin_core', array( 'EE_Register_Admin_Page', 'set_page_path' ), 10 );
80
+       add_filter('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', array('EE_Register_Admin_Page', 'set_page_basename'), 10);
81
+       add_filter('FHEE__EEH_Autoloader__load_admin_core', array('EE_Register_Admin_Page', 'set_page_path'), 10);
82 82
 
83 83
     }
84 84
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      * @param  string $page_basename Use whatever string was used to register the admin page.
94 94
      * @return  void
95 95
      */
96
-    public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
96
+    public static function deregister($page_basename = NULL) {
97
+    	if ( ! empty(self::$_ee_admin_page_registry[$page_basename]))
98
+    		unset(self::$_ee_admin_page_registry[$page_basename]);
99 99
     }
100 100
 
101 101
 
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
 	 * @param $installed_refs
107 107
 	 * @return mixed
108 108
 	 */
109
-	public static function set_page_basename( $installed_refs ) {
110
-		if ( ! empty( self::$_ee_admin_page_registry )) {
111
-			foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
112
-				$installed_refs[ $basename ] = $args['page_path'];
109
+	public static function set_page_basename($installed_refs) {
110
+		if ( ! empty(self::$_ee_admin_page_registry)) {
111
+			foreach (self::$_ee_admin_page_registry as $basename => $args) {
112
+				$installed_refs[$basename] = $args['page_path'];
113 113
 			}
114 114
 		}
115 115
         return $installed_refs;
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	 * @param $paths
124 124
 	 * @return mixed
125 125
 	 */
126
-	public static function set_page_path( $paths ) {
127
-        foreach ( self::$_ee_admin_page_registry as $basename => $args ) {
128
-            $paths[ $basename ] = $args['page_path'];
126
+	public static function set_page_path($paths) {
127
+        foreach (self::$_ee_admin_page_registry as $basename => $args) {
128
+            $paths[$basename] = $args['page_path'];
129 129
         }
130 130
         return $paths;
131 131
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister an EE Admin Page.
@@ -94,8 +96,9 @@  discard block
 block discarded – undo
94 96
      * @return  void
95 97
      */
96 98
     public static function deregister( $page_basename = NULL ) {
97
-    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) )
98
-    		unset( self::$_ee_admin_page_registry[$page_basename] );
99
+    	if ( !empty( self::$_ee_admin_page_registry[$page_basename] ) ) {
100
+    	    		unset( self::$_ee_admin_page_registry[$page_basename] );
101
+    	}
99 102
     }
100 103
 
101 104
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_CPT.lib.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -66,33 +66,33 @@  discard block
 block discarded – undo
66 66
 	 * @throws  EE_Error
67 67
 	 * @return void
68 68
 	 */
69
-	public static function register( $cpt_ref = NULL, $setup_args = array() ) {
69
+	public static function register($cpt_ref = NULL, $setup_args = array()) {
70 70
 
71 71
 		//check for requred params
72
-		if ( empty( $cpt_ref ) ) {
72
+		if (empty($cpt_ref)) {
73 73
 			throw new EE_Error(
74
-				__('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso' )
74
+				__('In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered', 'event_espresso')
75 75
 				);
76 76
 		}
77 77
 
78
-		if ( ! is_array( $setup_args ) || ( empty( $setup_args['cpts'] ) && empty( $setup_args['cts'] ) ) ) {
78
+		if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
79 79
 			throw new EE_Error(
80
-				__( 'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso' )
80
+				__('In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.', 'event_espresso')
81 81
 				);
82 82
 		}
83 83
 
84 84
 		//make sure we don't register twice
85
-		if( isset( self::$_registry[ $cpt_ref ] ) ){
85
+		if (isset(self::$_registry[$cpt_ref])) {
86 86
 			return;
87 87
 		}
88 88
 
89 89
 		//make sure cpt ref is unique.
90
-		if ( isset( self::$_registry[$cpt_ref] ) ) {
91
-			$cpt_ref = uniqid() . '_' . $cpt_ref;
90
+		if (isset(self::$_registry[$cpt_ref])) {
91
+			$cpt_ref = uniqid().'_'.$cpt_ref;
92 92
 		}
93 93
 
94 94
 		//make sure this was called in the right place!
95
-		if ( did_action( 'AHEE__EE_System__load_CPTs_and_session__complete' ) ) {
95
+		if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) {
96 96
 			EE_Error::doing_it_wrong(
97 97
 				__METHOD__,
98 98
 				sprintf(
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 
106 106
 		//validate incoming args
107 107
 		$validated = array(
108
-			'cpts' => isset( $setup_args['cpts'] ) ? (array) $setup_args['cpts'] : array(),
109
-			'cts' => isset( $setup_args['cts'] ) ? (array) $setup_args['cts'] : array(),
110
-			'default_terms' => isset( $setup_args['default_terms'] ) ? (array) $setup_args['default_terms'] : array()
108
+			'cpts' => isset($setup_args['cpts']) ? (array) $setup_args['cpts'] : array(),
109
+			'cts' => isset($setup_args['cts']) ? (array) $setup_args['cts'] : array(),
110
+			'default_terms' => isset($setup_args['default_terms']) ? (array) $setup_args['default_terms'] : array()
111 111
 			);
112 112
 
113 113
 		self::$_registry[$cpt_ref] = $validated;
114 114
 
115 115
 		//hook into to cpt system
116
-		add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( __CLASS__, 'filter_cpts' ), 5 );
117
-		add_filter( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( __CLASS__, 'filter_cts' ), 5 );
118
-		add_action( 'AHEE__EE_Register_CPTs__construct_end', array( __CLASS__, 'default_terms'), 5 );
116
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array(__CLASS__, 'filter_cpts'), 5);
117
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array(__CLASS__, 'filter_cts'), 5);
118
+		add_action('AHEE__EE_Register_CPTs__construct_end', array(__CLASS__, 'default_terms'), 5);
119 119
 	}
120 120
 
121 121
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return array new array of cpts and their registration information
131 131
 	 */
132
-	public static function filter_cpts( $cpts ) {
133
-		foreach( self::$_registry as  $registries ) {
134
-			foreach ( $registries['cpts'] as $cpt_name => $cpt_settings ) {
132
+	public static function filter_cpts($cpts) {
133
+		foreach (self::$_registry as  $registries) {
134
+			foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
135 135
 				$cpts[$cpt_name] = $cpt_settings;
136 136
 			}
137 137
 		}
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array new array of cts and their registration information.
150 150
 	 */
151
-	public static function filter_cts( $cts ) {
152
-		foreach( self::$_registry as $registries ) {
153
-			foreach( $registries['cts'] as $ct_name => $ct_settings ) {
151
+	public static function filter_cts($cts) {
152
+		foreach (self::$_registry as $registries) {
153
+			foreach ($registries['cts'] as $ct_name => $ct_settings) {
154 154
 				$cts[$ct_name] = $ct_settings;
155 155
 			}
156 156
 		}
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return void
169 169
 	 */
170
-	public static function default_terms( EE_Register_CPTs $cpt_class ) {
171
-		foreach( self::$_registry as $registries ) {
172
-			foreach( $registries['default_terms'] as $taxonomy => $terms ) {
173
-				foreach ( $terms as $term => $cpts ) {
174
-					$cpt_class->set_default_term( $taxonomy, $term, $cpts );
170
+	public static function default_terms(EE_Register_CPTs $cpt_class) {
171
+		foreach (self::$_registry as $registries) {
172
+			foreach ($registries['default_terms'] as $taxonomy => $terms) {
173
+				foreach ($terms as $term => $cpts) {
174
+					$cpt_class->set_default_term($taxonomy, $term, $cpts);
175 175
 				}
176 176
 			}
177 177
 		}
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return void
190 190
 	 */
191
-	public static function deregister( $cpt_ref = null ) {
192
-		if ( !empty( self::$_registry[$cpt_ref] ) ) {
193
-			unset( self::$_registry[$cpt_ref] );
191
+	public static function deregister($cpt_ref = null) {
192
+		if ( ! empty(self::$_registry[$cpt_ref])) {
193
+			unset(self::$_registry[$cpt_ref]);
194 194
 		}
195 195
 	}
196 196
 } //end class EE_Register_CPT
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, custom post type, custom taxonomy
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new custom post type or custom taxonomy for the EE CPT system.
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Capabilities.lib.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -47,33 +47,33 @@  discard block
 block discarded – undo
47 47
 	 * @throws EE_Error
48 48
 	 * @return void
49 49
 	 */
50
-	public static function register( $cap_reference = NULL, $setup_args = array() ) {
50
+	public static function register($cap_reference = NULL, $setup_args = array()) {
51 51
 		//required fields MUST be present, so let's make sure they are.
52
-		if ( ! isset( $cap_reference ) || ! is_array( $setup_args ) || empty( $setup_args['capabilities'] ) ) {
52
+		if ( ! isset($cap_reference) || ! is_array($setup_args) || empty($setup_args['capabilities'])) {
53 53
 			throw new EE_Error(
54
-				__( 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso' )
54
+				__('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', 'event_espresso')
55 55
 			);
56 56
 		}
57 57
 		//make sure we don't register twice
58
-		if( isset( self::$_registry[ $cap_reference ] ) ){
58
+		if (isset(self::$_registry[$cap_reference])) {
59 59
 			return;
60 60
 		}
61 61
 		//make sure this is not registered too late or too early.
62
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' ) ) {
63
-			EE_Error::doing_it_wrong( __METHOD__, sprintf( __('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference ), '4.5.0' );
62
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
63
+			EE_Error::doing_it_wrong(__METHOD__, sprintf(__('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', 'event_espresso'), $cap_reference), '4.5.0');
64 64
 		}
65 65
 		//some preliminary sanitization and setting to the $_registry property
66 66
 		self::$_registry[$cap_reference] = array(
67
-			'caps' => isset( $setup_args['capabilities'] ) && is_array( $setup_args['capabilities'] ) ? $setup_args['capabilities'] : array(),
68
-			'cap_maps' => isset( $setup_args['capability_maps'] ) ? $setup_args['capability_maps'] : array()
67
+			'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) ? $setup_args['capabilities'] : array(),
68
+			'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : array()
69 69
 		);
70 70
 		//set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once)
71
-		add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( 'EE_Register_Capabilities', 'register_capabilities' ), 10 );
71
+		add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array('EE_Register_Capabilities', 'register_capabilities'), 10);
72 72
 		//add filter for cap maps
73
-		add_filter( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', array( 'EE_Register_Capabilities', 'register_cap_maps' ), 10 );
73
+		add_filter('FHEE__EE_Capabilities___set_meta_caps__meta_caps', array('EE_Register_Capabilities', 'register_cap_maps'), 10);
74 74
 		//init_role_caps to register new capabilities
75
-		if ( is_admin() ) {
76
-			EE_Registry::instance()->load_core( 'Capabilities' );
75
+		if (is_admin()) {
76
+			EE_Registry::instance()->load_core('Capabilities');
77 77
 			EE_Capabilities::instance()->init_caps();
78 78
 		}
79 79
 	}
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return array merged in new caps.
90 90
 	 */
91
-	public static function register_capabilities( $incoming_caps ) {
92
-		foreach ( self::$_registry as $ref => $caps_and_cap_map ) {
93
-			$incoming_caps = array_merge_recursive( $incoming_caps, $caps_and_cap_map[ 'caps' ] );
91
+	public static function register_capabilities($incoming_caps) {
92
+		foreach (self::$_registry as $ref => $caps_and_cap_map) {
93
+			$incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']);
94 94
 		}
95 95
 		return $incoming_caps;
96 96
 	}
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	 * @return EE_Meta_Capability_Map[]
106 106
 	 * @throws EE_Error
107 107
 	 */
108
-	public static function register_cap_maps( $cap_maps ) {
108
+	public static function register_cap_maps($cap_maps) {
109 109
 		//loop through and instantiate cap maps.
110
-		foreach ( self::$_registry as $cap_reference => $setup ) {
111
-			if ( ! isset( $setup['cap_maps'] ) ) {
110
+		foreach (self::$_registry as $cap_reference => $setup) {
111
+			if ( ! isset($setup['cap_maps'])) {
112 112
 				continue;
113 113
 			}
114
-			foreach ( $setup['cap_maps'] as $cap_class => $args ) {
114
+			foreach ($setup['cap_maps'] as $cap_class => $args) {
115 115
 
116 116
 				/**
117 117
 				 * account for cases where capability maps may be indexed
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 				 * 	...
139 139
 				 * )
140 140
 				 */
141
-				if ( is_numeric( $cap_class ) ) {
142
-					$cap_class = key( $args );
141
+				if (is_numeric($cap_class)) {
142
+					$cap_class = key($args);
143 143
 					$args = $args[$cap_class];
144 144
 				}
145 145
 
146
-				if ( ! class_exists( $cap_class ) ) {
147
-					throw new EE_Error( sprintf( __( 'An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso' ), $cap_reference ) );
146
+				if ( ! class_exists($cap_class)) {
147
+					throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments', 'event_espresso'), $cap_reference));
148 148
 				}
149 149
 
150
-				if ( count( $args ) !== 2 ) {
151
-					throw new EE_Error( sprintf( __('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.', 'event_espresso' ), $cap_reference ) );
150
+				if (count($args) !== 2) {
151
+					throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.', 'event_espresso'), $cap_reference));
152 152
 				}
153
-				$cap_maps[] = new $cap_class( $args[0], $args[1] );
153
+				$cap_maps[] = new $cap_class($args[0], $args[1]);
154 154
 			}
155 155
 		}
156 156
 		return $cap_maps;
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 
160 160
 
161 161
 
162
-	public static function deregister( $cap_reference = NULL ) {
163
-		if ( !empty( self::$_registry[$cap_reference] ) ) {
164
-			unset( self::$_registry[ $cap_reference ] );
162
+	public static function deregister($cap_reference = NULL) {
163
+		if ( ! empty(self::$_registry[$cap_reference])) {
164
+			unset(self::$_registry[$cap_reference]);
165 165
 		}
166 166
 
167 167
 		//re init caps to grab the changes due to removed caps.
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, capabilities
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register new capabilities for the EE capabilities system.
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Config.lib.php 3 patches
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new config with the EE_Registry::instance->CFG property.
@@ -111,7 +113,8 @@  discard block
 block discarded – undo
111 113
 	 * @param mixed $config_class_name
112 114
 	 */
113 115
 	public static function deregister( $config_class_name = NULL ) {
114
-		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
115
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
116
+		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] )) {
117
+		    			unset( self::$_ee_config_registry[ $config_class_name ] );
118
+		}
116 119
 	}
117 120
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
42 42
 	 *                       		}
43 43
 	 * @return void
44 44
 	 */
45
-	public static function register( $config_class = NULL, $setup_args = array() ) {
45
+	public static function register($config_class = NULL, $setup_args = array()) {
46 46
 
47
-		$setup_args['config_name'] = isset( $setup_args['config_name'] ) && ! empty( $setup_args['config_name'] ) ? $setup_args['config_name'] : $config_class;
48
-		$setup_args['config_section'] = isset( $setup_args['config_section'] ) && ! empty( $setup_args['config_section'] ) ? $setup_args['config_section'] : 'addons';
47
+		$setup_args['config_name'] = isset($setup_args['config_name']) && ! empty($setup_args['config_name']) ? $setup_args['config_name'] : $config_class;
48
+		$setup_args['config_section'] = isset($setup_args['config_section']) && ! empty($setup_args['config_section']) ? $setup_args['config_section'] : 'addons';
49 49
 
50 50
 		//required fields MUST be present, so let's make sure they are.
51
-		if ( empty( $config_class ) || ! is_array( $setup_args ) || empty( $setup_args['config_name'] )) {
52
-			throw new EE_Error( __( 'In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso' ));
51
+		if (empty($config_class) || ! is_array($setup_args) || empty($setup_args['config_name'])) {
52
+			throw new EE_Error(__('In order to register a Config Class with EE_Register_Config::register(), you must include a "config_class" (the actual class name for this config class). As well, you can supply an array containing the following keys: "config_section" the main section of the config object the settings will be saved under (by default the new config will be registered under EE_Config::instance()->modules or EE_Config::instance()->addons depending on what type of class is calling this), "config_name" (by default the new config will be registered to EE_Config::instance()->{config_section}->{config_class}, but supplying a "config_name" will set the property name that this variable is accessible by. ie: EE_Config::instance()->{config_section}->{config_name})', 'event_espresso'));
53 53
 		}
54 54
 
55 55
 		//make sure we don't register twice
56
-		if( isset( self::$_ee_config_registry[ $config_class ] ) ){
56
+		if (isset(self::$_ee_config_registry[$config_class])) {
57 57
 			return;
58 58
 		}
59 59
 
60 60
 
61 61
 		//first find out if this happened too late.
62
-		if ( did_action( 'AHEE__EE_System__load_core_configuration__begin' ) ) {
62
+		if (did_action('AHEE__EE_System__load_core_configuration__begin')) {
63 63
 			EE_Error::doing_it_wrong(
64 64
 				__METHOD__,
65 65
 				sprintf(
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 				);
71 71
 		}
72 72
 		//add incoming stuff to our registry property
73
-		self::$_ee_config_registry[ $config_class ] = array(
73
+		self::$_ee_config_registry[$config_class] = array(
74 74
 			'section' => $setup_args['config_section'],
75 75
 			'name' => $setup_args['config_name']
76 76
 		);
77 77
 
78
-		add_action( 'AHEE__EE_Config___load_core_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 );
79
-		add_action( 'AHEE__EE_Config__update_espresso_config__end', array( 'EE_Register_Config', 'set_config' ), 15, 1 );
78
+		add_action('AHEE__EE_Config___load_core_config__end', array('EE_Register_Config', 'set_config'), 15, 1);
79
+		add_action('AHEE__EE_Config__update_espresso_config__end', array('EE_Register_Config', 'set_config'), 15, 1);
80 80
 	}
81 81
 
82 82
 
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
 	 * @param \EE_Config $EE_Config
91 91
 	 * @return \StdClass
92 92
 	 */
93
-	public static function set_config( EE_Config $EE_Config ) {
94
-		foreach ( self::$_ee_config_registry as $config_class => $settings ) {
93
+	public static function set_config(EE_Config $EE_Config) {
94
+		foreach (self::$_ee_config_registry as $config_class => $settings) {
95 95
 			//first some validation of our incoming class_name.  We'll throw an error early if its' not registered correctly
96
-			if ( ! class_exists( $config_class )) {
96
+			if ( ! class_exists($config_class)) {
97 97
 				throw new EE_Error(
98 98
 					sprintf(
99
-						__( 'The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class', 'event_espresso' ),
99
+						__('The "%s" config class can not be registered with EE_Config because it does not exist.  Verify that an autoloader has been set for this class', 'event_espresso'),
100 100
 						$config_class
101 101
 					)
102 102
 				 );
103 103
 			}
104
-			$EE_Config->get_config( $settings['section'], $settings['name'], $config_class );
104
+			$EE_Config->get_config($settings['section'], $settings['name'], $config_class);
105 105
 		}
106 106
 	}
107 107
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	/**
112 112
 	 * @param mixed $config_class_name
113 113
 	 */
114
-	public static function deregister( $config_class_name = NULL ) {
115
-		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
116
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
114
+	public static function deregister($config_class_name = NULL) {
115
+		if ( ! empty(self::$_ee_config_registry[$config_class_name]))
116
+    			unset(self::$_ee_config_registry[$config_class_name]);
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,6 +113,6 @@
 block discarded – undo
113 113
 	 */
114 114
 	public static function deregister( $config_class_name = NULL ) {
115 115
 		if ( ! empty( self::$_ee_config_registry[ $config_class_name ] ))
116
-    			unset( self::$_ee_config_registry[ $config_class_name ] );
116
+				unset( self::$_ee_config_registry[ $config_class_name ] );
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Data_Migration_Scripts.lib.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
 	 * @throws EE_Error
46 46
 	 * @return void
47 47
 	 */
48
-	public static function register( $dms_id = NULL, $setup_args = array()  ) {
48
+	public static function register($dms_id = NULL, $setup_args = array()) {
49 49
 
50 50
 		//required fields MUST be present, so let's make sure they are.
51
-		if ( empty( $dms_id ) || ! is_array( $setup_args ) || empty( $setup_args['dms_paths'] )) {
52
-			throw new EE_Error( __( 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and  an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso' ));
51
+		if (empty($dms_id) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) {
52
+			throw new EE_Error(__('In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include a "dms_id" (a unique identifier for this set of data migration scripts), and  an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', 'event_espresso'));
53 53
 		}
54 54
 
55 55
 		//make sure we don't register twice
56
-		if( isset( self::$_settings[ $dms_id ] ) ){
56
+		if (isset(self::$_settings[$dms_id])) {
57 57
 			return;
58 58
 		}
59 59
 
60 60
 		//make sure this was called in the right place!
61
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' ) || did_action( 'AHEE__EE_System___detect_if_activation_or_upgrade__begin' )) {
61
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
62 62
 			EE_Error::doing_it_wrong(
63 63
 				__METHOD__,
64
-					__( 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.','event_espresso'),
64
+					__('An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', 'event_espresso'),
65 65
 				'4.3.0'
66 66
 			);
67 67
 		}
68 68
 		//setup $_settings array from incoming values.
69
-		self::$_settings[ $dms_id ] = array(
70
-			'dms_paths' =>isset( $setup_args['dms_paths'] ) ? (array)$setup_args['dms_paths'] : array()
69
+		self::$_settings[$dms_id] = array(
70
+			'dms_paths' =>isset($setup_args['dms_paths']) ? (array) $setup_args['dms_paths'] : array()
71 71
 		);
72 72
 		// setup DMS
73
-		add_filter( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array( 'EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders' ));
73
+		add_filter('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'));
74 74
 	}
75 75
 
76 76
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @param array $dms_paths
81 81
 	 * @return array
82 82
 	 */
83
-	public static function add_data_migration_script_folders( $dms_paths = array() ){
84
-		foreach( self::$_settings as $settings ) {
85
-			$dms_paths = array_merge( $dms_paths, $settings['dms_paths'] );
83
+	public static function add_data_migration_script_folders($dms_paths = array()) {
84
+		foreach (self::$_settings as $settings) {
85
+			$dms_paths = array_merge($dms_paths, $settings['dms_paths']);
86 86
 		}
87 87
 		return $dms_paths;
88 88
 	}
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param mixed $dms_id  unique identifier for the set of Data Migration Scripts that were previously registered
98 98
 	 * @return void
99 99
 	 */
100
-	public static function deregister( $dms_id = NULL ) {
101
-		if ( isset( self::$_settings[ $dms_id ] )) {
102
-			unset( self::$_settings[ $dms_id ] );
100
+	public static function deregister($dms_id = NULL) {
101
+		if (isset(self::$_settings[$dms_id])) {
102
+			unset(self::$_settings[$dms_id]);
103 103
 		}
104 104
 	}
105 105
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Shortcode_Library.lib.php 3 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -62,44 +62,44 @@  discard block
 block discarded – undo
62 62
      * }
63 63
      * @return void
64 64
      */
65
-    public static function register( $name = NULL, $setup_args = array() ) {
65
+    public static function register($name = NULL, $setup_args = array()) {
66 66
 
67 67
         //required fields MUST be present, so let's make sure they are.
68
-        if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) {
69
-            throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) );
68
+        if (empty($name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
69
+            throw new EE_Error(__('In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso'));
70 70
         }
71 71
 
72 72
 		//make sure we don't register twice
73
-		if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){
73
+		if (isset(self::$_ee_messages_shortcode_registry[$name])) {
74 74
 			return;
75 75
 		}
76 76
 
77 77
 		//make sure this was called in the right place!
78
-		if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
79
-			EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' );
78
+		if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
79
+			EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', 'event_espresso'), $name), '4.3.0');
80 80
 		}
81 81
 
82 82
         $name = (string) $name;
83 83
         self::$_ee_messages_shortcode_registry[$name] = array(
84 84
             'autoloadpaths' => (array) $setup_args['autoloadpaths'],
85
-            'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array()
85
+            'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) ? (array) $setup_args['list_type_shortcodes'] : array()
86 86
             );
87 87
 
88 88
          //add filters
89
-         add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 );
89
+         add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10);
90 90
 
91 91
         //add below filters if the required callback is provided.
92
-        if ( !empty( $setup_args['msgr_validator_callback'] ) )
93
-            add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 );
92
+        if ( ! empty($setup_args['msgr_validator_callback']))
93
+            add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
94 94
 
95
-        if ( !empty( $setup_args['msgr_template_fields_callback'] ) )
96
-            add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 );
95
+        if ( ! empty($setup_args['msgr_template_fields_callback']))
96
+            add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
97 97
 
98
-        if ( !empty( $setup_args['valid_shortcodes_callback'] ) )
99
-            add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 );
98
+        if ( ! empty($setup_args['valid_shortcodes_callback']))
99
+            add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
100 100
 
101
-        if ( !empty( $setup_args['list_type_shortcodes'] ) )
102
-            add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 );
101
+        if ( ! empty($setup_args['list_type_shortcodes']))
102
+            add_filter('FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array('EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10);
103 103
     }
104 104
 
105 105
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
      * @param  string $name name used to register the shortcode library.
113 113
      * @return  void
114 114
      */
115
-    public static function deregister( $name = NULL ) {
116
-    	if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) )
117
-    		unset( self::$_ee_messages_shortcode_registry[$name] );
115
+    public static function deregister($name = NULL) {
116
+    	if ( ! empty(self::$_ee_messages_shortcode_registry[$name]))
117
+    		unset(self::$_ee_messages_shortcode_registry[$name]);
118 118
     }
119 119
 
120 120
 
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
      * @param array $paths array of paths to be checked by EE_messages autoloader.
128 128
      * @return array
129 129
      */
130
-    public static function register_msgs_autoload_paths( $paths  ) {
130
+    public static function register_msgs_autoload_paths($paths) {
131 131
 
132
-        if ( !empty( self::$_ee_messages_shortcode_registry ) ) {
133
-             foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) {
134
-                if ( empty( $st_reg['autoloadpaths'] ) )
132
+        if ( ! empty(self::$_ee_messages_shortcode_registry)) {
133
+             foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
134
+                if (empty($st_reg['autoloadpaths']))
135 135
                     continue;
136
-                $paths = array_merge( $paths, $st_reg['autoloadpaths'] );
136
+                $paths = array_merge($paths, $st_reg['autoloadpaths']);
137 137
             }
138 138
         }
139 139
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
      * @param  array $original_shortcodes
152 152
      * @return  array                                   Modifications to original shortcodes.
153 153
      */
154
-    public static function register_list_type_shortcodes( $original_shortcodes ) {
155
-        if ( empty( self::$_ee_messages_shortcode_registry ) )
154
+    public static function register_list_type_shortcodes($original_shortcodes) {
155
+        if (empty(self::$_ee_messages_shortcode_registry))
156 156
             return $original_shortcodes;
157 157
 
158
-        foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) {
159
-            if ( !empty( $sc_reg['list_type_shortcodes'] ) )
160
-                $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] );
158
+        foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
159
+            if ( ! empty($sc_reg['list_type_shortcodes']))
160
+                $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
161 161
         }
162 162
 
163 163
         return $original_shortcodes;
Please login to merge, or discard this patch.
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new shortcode library for the EE messages system.
@@ -89,17 +91,21 @@  discard block
 block discarded – undo
89 91
          add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 );
90 92
 
91 93
         //add below filters if the required callback is provided.
92
-        if ( !empty( $setup_args['msgr_validator_callback'] ) )
93
-            add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 );
94
+        if ( !empty( $setup_args['msgr_validator_callback'] ) ) {
95
+                    add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 );
96
+        }
94 97
 
95
-        if ( !empty( $setup_args['msgr_template_fields_callback'] ) )
96
-            add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 );
98
+        if ( !empty( $setup_args['msgr_template_fields_callback'] ) ) {
99
+                    add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 );
100
+        }
97 101
 
98
-        if ( !empty( $setup_args['valid_shortcodes_callback'] ) )
99
-            add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 );
102
+        if ( !empty( $setup_args['valid_shortcodes_callback'] ) ) {
103
+                    add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 );
104
+        }
100 105
 
101
-        if ( !empty( $setup_args['list_type_shortcodes'] ) )
102
-            add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 );
106
+        if ( !empty( $setup_args['list_type_shortcodes'] ) ) {
107
+                    add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 );
108
+        }
103 109
     }
104 110
 
105 111
 
@@ -113,8 +119,9 @@  discard block
 block discarded – undo
113 119
      * @return  void
114 120
      */
115 121
     public static function deregister( $name = NULL ) {
116
-    	if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) )
117
-    		unset( self::$_ee_messages_shortcode_registry[$name] );
122
+    	if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) ) {
123
+    	    		unset( self::$_ee_messages_shortcode_registry[$name] );
124
+    	}
118 125
     }
119 126
 
120 127
 
@@ -131,8 +138,9 @@  discard block
 block discarded – undo
131 138
 
132 139
         if ( !empty( self::$_ee_messages_shortcode_registry ) ) {
133 140
              foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) {
134
-                if ( empty( $st_reg['autoloadpaths'] ) )
135
-                    continue;
141
+                if ( empty( $st_reg['autoloadpaths'] ) ) {
142
+                                    continue;
143
+                }
136 144
                 $paths = array_merge( $paths, $st_reg['autoloadpaths'] );
137 145
             }
138 146
         }
@@ -152,12 +160,14 @@  discard block
 block discarded – undo
152 160
      * @return  array                                   Modifications to original shortcodes.
153 161
      */
154 162
     public static function register_list_type_shortcodes( $original_shortcodes ) {
155
-        if ( empty( self::$_ee_messages_shortcode_registry ) )
156
-            return $original_shortcodes;
163
+        if ( empty( self::$_ee_messages_shortcode_registry ) ) {
164
+                    return $original_shortcodes;
165
+        }
157 166
 
158 167
         foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) {
159
-            if ( !empty( $sc_reg['list_type_shortcodes'] ) )
160
-                $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] );
168
+            if ( !empty( $sc_reg['list_type_shortcodes'] ) ) {
169
+                            $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] );
170
+            }
161 171
         }
162 172
 
163 173
         return $original_shortcodes;
Please login to merge, or discard this patch.
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -18,56 +18,56 @@  discard block
 block discarded – undo
18 18
 class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API {
19 19
 
20 20
 
21
-    /**
22
-     * holds values for registered messages shortcode libraries
23
-     * @var array
24
-     */
25
-    protected static $_ee_messages_shortcode_registry = array();
26
-
27
-
28
-
29
-
30
-    /**
31
-     * Helper method for registring a new shortcodes library class for the messages system.
32
-     *
33
-     * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
34
-     * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
35
-     *
36
-     * @since    4.3.0
37
-     *
38
-     * @param  array  $setup_args {
39
-     *       An array of arguments provided for registering the new messages shortcode library.
40
-     *
41
-     *       @type string $name                                         What is the name of this shortcode library
42
-     *                                                                              (e.g. 'question_list');
43
-     *       @type array  $autoloadpaths                          An array of paths to add to the messages
44
-     *                                                                              autoloader for the new shortcode library
45
-     *                                                                              class file.
46
-     *       @type string $msgr_validator_callback            Callback for a method that will register the
47
-     *                                                                              library with the messenger
48
-     *                                                                              _validator_config. Optional.
49
-     *       @type string $msgr_template_fields_callback  Callback for changing adding the
50
-     *                                                                              _template_fields property for messenger.
51
-     *                                                                              For example, the shortcode library may add
52
-     *                                                                              a new field to the message templates.
53
-     *                                                                              Optional.
54
-     *       @type string $valid_shortcodes_callback         Callback for message types
55
-     *                                                                              _valid_shortcodes array setup. Optional.
56
-     *       @type array  $list_type_shortcodes                 If there are any specific shortcodes with this
57
-     *                                                                             message shortcode library that should be
58
-     *                                                                             considered "list type" then include them in an
59
-     *                                                                             array.  List Type shortcodes are shortcodes that
60
-     *                                                                             have a corresponding field that indicates how
61
-     *                                                                             they are parsed. Optional.
62
-     * }
63
-     * @return void
64
-     */
65
-    public static function register( $name = NULL, $setup_args = array() ) {
66
-
67
-        //required fields MUST be present, so let's make sure they are.
68
-        if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) {
69
-            throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) );
70
-        }
21
+	/**
22
+	 * holds values for registered messages shortcode libraries
23
+	 * @var array
24
+	 */
25
+	protected static $_ee_messages_shortcode_registry = array();
26
+
27
+
28
+
29
+
30
+	/**
31
+	 * Helper method for registring a new shortcodes library class for the messages system.
32
+	 *
33
+	 * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
34
+	 * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
35
+	 *
36
+	 * @since    4.3.0
37
+	 *
38
+	 * @param  array  $setup_args {
39
+	 *       An array of arguments provided for registering the new messages shortcode library.
40
+	 *
41
+	 *       @type string $name                                         What is the name of this shortcode library
42
+	 *                                                                              (e.g. 'question_list');
43
+	 *       @type array  $autoloadpaths                          An array of paths to add to the messages
44
+	 *                                                                              autoloader for the new shortcode library
45
+	 *                                                                              class file.
46
+	 *       @type string $msgr_validator_callback            Callback for a method that will register the
47
+	 *                                                                              library with the messenger
48
+	 *                                                                              _validator_config. Optional.
49
+	 *       @type string $msgr_template_fields_callback  Callback for changing adding the
50
+	 *                                                                              _template_fields property for messenger.
51
+	 *                                                                              For example, the shortcode library may add
52
+	 *                                                                              a new field to the message templates.
53
+	 *                                                                              Optional.
54
+	 *       @type string $valid_shortcodes_callback         Callback for message types
55
+	 *                                                                              _valid_shortcodes array setup. Optional.
56
+	 *       @type array  $list_type_shortcodes                 If there are any specific shortcodes with this
57
+	 *                                                                             message shortcode library that should be
58
+	 *                                                                             considered "list type" then include them in an
59
+	 *                                                                             array.  List Type shortcodes are shortcodes that
60
+	 *                                                                             have a corresponding field that indicates how
61
+	 *                                                                             they are parsed. Optional.
62
+	 * }
63
+	 * @return void
64
+	 */
65
+	public static function register( $name = NULL, $setup_args = array() ) {
66
+
67
+		//required fields MUST be present, so let's make sure they are.
68
+		if ( empty( $name ) || ! is_array( $setup_args ) || empty( $setup_args['autoloadpaths'] ) ) {
69
+			throw new EE_Error( __( 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', 'event_espresso' ) );
70
+		}
71 71
 
72 72
 		//make sure we don't register twice
73 73
 		if( isset( self::$_ee_messages_shortcode_registry[ $name ] ) ){
@@ -79,88 +79,88 @@  discard block
 block discarded – undo
79 79
 			EE_Error::doing_it_wrong(__METHOD__, sprintf( __('Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).','event_espresso'), $name ), '4.3.0' );
80 80
 		}
81 81
 
82
-        $name = (string) $name;
83
-        self::$_ee_messages_shortcode_registry[$name] = array(
84
-            'autoloadpaths' => (array) $setup_args['autoloadpaths'],
85
-            'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array()
86
-            );
87
-
88
-         //add filters
89
-         add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 );
90
-
91
-        //add below filters if the required callback is provided.
92
-        if ( !empty( $setup_args['msgr_validator_callback'] ) )
93
-            add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 );
94
-
95
-        if ( !empty( $setup_args['msgr_template_fields_callback'] ) )
96
-            add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 );
97
-
98
-        if ( !empty( $setup_args['valid_shortcodes_callback'] ) )
99
-            add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 );
100
-
101
-        if ( !empty( $setup_args['list_type_shortcodes'] ) )
102
-            add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 );
103
-    }
104
-
105
-
106
-
107
-
108
-    /**
109
-     * This deregisters any messages shortcode library previously registered with the given name.
110
-     *
111
-     * @since    4.3.0
112
-     * @param  string $name name used to register the shortcode library.
113
-     * @return  void
114
-     */
115
-    public static function deregister( $name = NULL ) {
116
-    	if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) )
117
-    		unset( self::$_ee_messages_shortcode_registry[$name] );
118
-    }
119
-
120
-
121
-
122
-     /**
123
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
124
-     *
125
-     * @since    4.3.0
126
-     *
127
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
128
-     * @return array
129
-     */
130
-    public static function register_msgs_autoload_paths( $paths  ) {
131
-
132
-        if ( !empty( self::$_ee_messages_shortcode_registry ) ) {
133
-             foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) {
134
-                if ( empty( $st_reg['autoloadpaths'] ) )
135
-                    continue;
136
-                $paths = array_merge( $paths, $st_reg['autoloadpaths'] );
137
-            }
138
-        }
139
-
140
-        return $paths;
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
147
-     * filter which is used to add additional list type shortcodes.
148
-     *
149
-     * @since 4.3.0
150
-     *
151
-     * @param  array $original_shortcodes
152
-     * @return  array                                   Modifications to original shortcodes.
153
-     */
154
-    public static function register_list_type_shortcodes( $original_shortcodes ) {
155
-        if ( empty( self::$_ee_messages_shortcode_registry ) )
156
-            return $original_shortcodes;
157
-
158
-        foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) {
159
-            if ( !empty( $sc_reg['list_type_shortcodes'] ) )
160
-                $original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] );
161
-        }
162
-
163
-        return $original_shortcodes;
164
-    }
82
+		$name = (string) $name;
83
+		self::$_ee_messages_shortcode_registry[$name] = array(
84
+			'autoloadpaths' => (array) $setup_args['autoloadpaths'],
85
+			'list_type_shortcodes' => !empty( $setup_args['list_type_shortcodes'] ) ? (array) $setup_args['list_type_shortcodes'] : array()
86
+			);
87
+
88
+		 //add filters
89
+		 add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'), 10 );
90
+
91
+		//add below filters if the required callback is provided.
92
+		if ( !empty( $setup_args['msgr_validator_callback'] ) )
93
+			add_filter( 'FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2 );
94
+
95
+		if ( !empty( $setup_args['msgr_template_fields_callback'] ) )
96
+			add_filter( 'FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2 );
97
+
98
+		if ( !empty( $setup_args['valid_shortcodes_callback'] ) )
99
+			add_filter( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2 );
100
+
101
+		if ( !empty( $setup_args['list_type_shortcodes'] ) )
102
+			add_filter( 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', array( 'EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'), 10 );
103
+	}
104
+
105
+
106
+
107
+
108
+	/**
109
+	 * This deregisters any messages shortcode library previously registered with the given name.
110
+	 *
111
+	 * @since    4.3.0
112
+	 * @param  string $name name used to register the shortcode library.
113
+	 * @return  void
114
+	 */
115
+	public static function deregister( $name = NULL ) {
116
+		if ( !empty( self::$_ee_messages_shortcode_registry[$name] ) )
117
+			unset( self::$_ee_messages_shortcode_registry[$name] );
118
+	}
119
+
120
+
121
+
122
+	 /**
123
+	  * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
124
+	  *
125
+	  * @since    4.3.0
126
+	  *
127
+	  * @param array $paths array of paths to be checked by EE_messages autoloader.
128
+	  * @return array
129
+	  */
130
+	public static function register_msgs_autoload_paths( $paths  ) {
131
+
132
+		if ( !empty( self::$_ee_messages_shortcode_registry ) ) {
133
+			 foreach ( self::$_ee_messages_shortcode_registry as $st_reg ) {
134
+				if ( empty( $st_reg['autoloadpaths'] ) )
135
+					continue;
136
+				$paths = array_merge( $paths, $st_reg['autoloadpaths'] );
137
+			}
138
+		}
139
+
140
+		return $paths;
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
147
+	 * filter which is used to add additional list type shortcodes.
148
+	 *
149
+	 * @since 4.3.0
150
+	 *
151
+	 * @param  array $original_shortcodes
152
+	 * @return  array                                   Modifications to original shortcodes.
153
+	 */
154
+	public static function register_list_type_shortcodes( $original_shortcodes ) {
155
+		if ( empty( self::$_ee_messages_shortcode_registry ) )
156
+			return $original_shortcodes;
157
+
158
+		foreach ( self::$_ee_messages_shortcode_registry as $sc_reg ) {
159
+			if ( !empty( $sc_reg['list_type_shortcodes'] ) )
160
+				$original_shortcodes = array_merge( $original_shortcodes, $sc_reg['list_type_shortcodes'] );
161
+		}
162
+
163
+		return $original_shortcodes;
164
+	}
165 165
 
166 166
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Template_Pack.lib.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
 	 */
186 186
 	public static function deregister( $variation_ref = NULL ) {
187 187
 		if ( !empty( self::$_registry[$variation_ref] ) ) {
188
-    			unset( self::$_registry[$variation_ref] );
189
-    		}
188
+				unset( self::$_registry[$variation_ref] );
189
+			}
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return void
56 56
 	 */
57
-	public static function register( $ref = NULL, $setup_args = array() ) {
57
+	public static function register($ref = NULL, $setup_args = array()) {
58 58
 
59 59
 		//check for required params
60
-		if ( empty( $ref ) || empty( $setup_args['path'] ) || empty( $setup_args['classname'] ) ) {
60
+		if (empty($ref) || empty($setup_args['path']) || empty($setup_args['classname'])) {
61 61
 			throw new EE_Error(
62 62
 				__('In order to register a new template pack for the EE Messages system, you must include a value to reference the template pack being registered and the setup_args must have the path for the new template pack class as well as the classname for the new Template Pack Class. ', 'event_espresso')
63 63
 				);
64 64
 		}
65 65
 
66 66
 		//make sure we don't register twice
67
-		if( isset( self::$_registry[ $ref ] ) ){
67
+		if (isset(self::$_registry[$ref])) {
68 68
 			return;
69 69
 		}
70 70
 
71 71
 		//check that incoming $ref doesn't already exist. If it does then we'll create a unique reference for this template pack.
72
-		if ( isset( self::$_registry[$ref] ) ) {
73
-			$ref = uniqid() . '_' . $ref;
72
+		if (isset(self::$_registry[$ref])) {
73
+			$ref = uniqid().'_'.$ref;
74 74
 		}
75 75
 
76 76
 
77 77
 		//make sure this was called in the right place!
78
-		 if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
78
+		 if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
79 79
 			EE_Error::doing_it_wrong(
80 80
 				__METHOD__,
81 81
 				sprintf(
82
-					__('A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.','event_espresso'),
82
+					__('A EE Messages Template Pack given the reference "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', 'event_espresso'),
83 83
 					$ref
84 84
 				),
85 85
 				'4.5.0'
86 86
 			);
87 87
 		}
88 88
 
89
-		if ( self::_verify_class_not_exist( $setup_args['classname'] ) ) {
89
+		if (self::_verify_class_not_exist($setup_args['classname'])) {
90 90
 			self::$_registry[$ref] = array(
91 91
 				'path' => (string) $setup_args['path'],
92 92
 				'classname' => (string) $setup_args['classname']
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 		}
95 95
 
96 96
 		//hook into the system
97
-		add_filter( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array( 'EE_Register_Messages_Template_Pack', 'set_template_pack_path'), 10 );
98
-		add_filter( 'FHEE__EED_Messages__get_template_packs__template_packs', array( 'EE_Register_Messages_Template_Pack', 'set_template_pack' ), 10 );
97
+		add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array('EE_Register_Messages_Template_Pack', 'set_template_pack_path'), 10);
98
+		add_filter('FHEE__EED_Messages__get_template_packs__template_packs', array('EE_Register_Messages_Template_Pack', 'set_template_pack'), 10);
99 99
 
100 100
 	}
101 101
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return array
114 114
 	 */
115
-	public static function set_template_pack_path( $paths ) {
116
-		foreach( self::$_registry as $ref => $args ) {
115
+	public static function set_template_pack_path($paths) {
116
+		foreach (self::$_registry as $ref => $args) {
117 117
 			$paths[] = $args['path'];
118 118
 		}
119 119
 		return $paths;
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 	 * @param EE_Messages_Template_Pack[] $template_packs
131 131
 	 * @return EE_Messages_Template_Pack[]
132 132
 	 */
133
-	public static function set_template_pack( $template_packs ) {
134
-		foreach( self::$_registry as $ref => $args ) {
133
+	public static function set_template_pack($template_packs) {
134
+		foreach (self::$_registry as $ref => $args) {
135 135
 			//verify class_exists
136
-			if ( ! class_exists( $args['classname'] ) ) {
137
-				require_once( $args['path'] . '/' . $args['classname'] . '.class.php' );
136
+			if ( ! class_exists($args['classname'])) {
137
+				require_once($args['path'].'/'.$args['classname'].'.class.php');
138 138
 			}
139 139
 
140 140
 			//check again!
141
-			if ( class_exists( $args['classname'] ) ) {
141
+			if (class_exists($args['classname'])) {
142 142
 				$template_pack = new $args['classname'];
143 143
 				$template_packs[$template_pack->dbref] = $template_pack;
144 144
 			}
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return bool
161 161
 	 */
162
-	private static function _verify_class_not_exist( $classname ) {
162
+	private static function _verify_class_not_exist($classname) {
163 163
 
164 164
 		//loop through the existing registry and see if the classname is already present.
165
-		foreach ( self::$_registry as $ref => $args ) {
166
-			if ( $args['classname'] == $classname ) {
167
-				EE_Error::add_error( sprintf( __('The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.', 'event_espresso' ), (string) $setup_args['classname'] ), __FILE__, __LINE__, __FUNCTION__ );
165
+		foreach (self::$_registry as $ref => $args) {
166
+			if ($args['classname'] == $classname) {
167
+				EE_Error::add_error(sprintf(__('The %s template pack that you just activated cannot be registered with the messages system because there is already a template pack active using the same classname.  Contact the author of this template pack to let them know of the conflict.  To stop seeing this message you will need to deactivate this template pack.', 'event_espresso'), (string) $setup_args['classname']), __FILE__, __LINE__, __FUNCTION__);
168 168
 				return false;
169 169
 			}
170 170
 		}
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return void
185 185
 	 */
186
-	public static function deregister( $variation_ref = NULL ) {
187
-		if ( !empty( self::$_registry[$variation_ref] ) ) {
188
-    			unset( self::$_registry[$variation_ref] );
186
+	public static function deregister($variation_ref = NULL) {
187
+		if ( ! empty(self::$_registry[$variation_ref])) {
188
+    			unset(self::$_registry[$variation_ref]);
189 189
     		}
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message template pack for the EE messages system.
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Template_Variations.lib.php 3 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
 	 * @throws EE_Error
69 69
 	 * @return void
70 70
 	 */
71
-	public static function register( $variation_ref = NULL,  $setup_args = array() ) {
71
+	public static function register($variation_ref = NULL, $setup_args = array()) {
72 72
 
73 73
 		//check for required params
74
-		if ( empty( $variation_ref ) ) {
74
+		if (empty($variation_ref)) {
75 75
 			throw new EE_Error(
76 76
 				__('In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', 'event_espresso')
77 77
 				);
78 78
 		}
79 79
 
80
-		if ( ! is_array( $setup_args ) || empty( $setup_args['variations'] ) || empty( $setup_args['base_path'] ) || empty( $setup_args['base_url'] ) ) {
80
+		if ( ! is_array($setup_args) || empty($setup_args['variations']) || empty($setup_args['base_path']) || empty($setup_args['base_url'])) {
81 81
 			throw new EE_Error(
82 82
 				__('In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', 'event_espresso')
83 83
 				);
84 84
 		}
85 85
 
86 86
 		//make sure we don't register twice
87
-		if( isset( self::$_registry[ $variation_ref ] ) ){
87
+		if (isset(self::$_registry[$variation_ref])) {
88 88
 			return;
89 89
 		}
90 90
 
91 91
 		//make sure variation ref is unique.
92
-		if ( isset( self::$_registry[$variation_ref] ) ) {
93
-			$variation_ref = uniqid() . '_' . $variation_ref;
92
+		if (isset(self::$_registry[$variation_ref])) {
93
+			$variation_ref = uniqid().'_'.$variation_ref;
94 94
 		}
95 95
 
96 96
 
97 97
 		//make sure this was called in the right place!
98
-		 if ( ! did_action( 'EE_Brewing_Regular___messages_caf' ) || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )) {
98
+		 if ( ! did_action('EE_Brewing_Regular___messages_caf') || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')) {
99 99
 			EE_Error::doing_it_wrong(
100 100
 				__METHOD__,
101 101
 				sprintf(
102
-					__('Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.','event_espresso'),
102
+					__('Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System.  It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', 'event_espresso'),
103 103
 					$variation_ref
104 104
 				),
105 105
 				'4.5.0'
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
 
116 116
 
117 117
 		//check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack.  The former will throw an error.  The latter will remove the conflicting variation name but still register the others and will add EE_Error notice.
118
-		$validated = self::_verify_variations( $variation_ref, $validated );
118
+		$validated = self::_verify_variations($variation_ref, $validated);
119 119
 		self::$_registry[$variation_ref] = $validated;
120 120
 
121
-		add_filter( 'FHEE__EE_Messages_Template_Pack__get_variations', array( 'EE_Register_Messages_Template_Variations', 'get_variations' ), 10, 4 );
122
-		add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( 'EE_Register_Messages_Template_Variations', 'get_variation' ), 10, 8 );
121
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variations', array('EE_Register_Messages_Template_Variations', 'get_variations'), 10, 4);
122
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array('EE_Register_Messages_Template_Variations', 'get_variation'), 10, 8);
123 123
 	}
124 124
 
125 125
 
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
 	 * @throws EE_Error
137 137
 	 * @return bool
138 138
 	 */
139
-	private static function _verify_variations( $variation_ref, $validated_variations ) {
140
-		foreach ( self::$_registry as $variation_ref => $settings ) {
141
-			foreach ( $settings['variations'] as $template_pack => $messenger ) {
142
-				foreach ( $messenger as $all_variations ) {
143
-					if ( isset( $all_variations['default'] ) ) {
139
+	private static function _verify_variations($variation_ref, $validated_variations) {
140
+		foreach (self::$_registry as $variation_ref => $settings) {
141
+			foreach ($settings['variations'] as $template_pack => $messenger) {
142
+				foreach ($messenger as $all_variations) {
143
+					if (isset($all_variations['default'])) {
144 144
 						throw new EE_Error(
145
-							sprintf( __('Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template.  Please check the code registering variations with this reference, "%s" and modify.', 'event_espresso' ), $variation_ref )
145
+							sprintf(__('Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template.  Please check the code registering variations with this reference, "%s" and modify.', 'event_espresso'), $variation_ref)
146 146
 							);
147 147
 					}
148 148
 				}
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 
152 152
 		//is there already a variation registered with a given variation slug?
153
-		foreach ( $validated_variations['variations'] as $template_pack => $messenger  ) {
154
-			foreach ( $messenger as $message_type => $variations ) {
155
-				foreach( $variations as $slug => $label ) {
156
-					foreach ( self::$_registry as $registered_var => $reg_settings ) {
157
-						if ( isset( $reg_settings['variations'][$template_pack][$messenger][$message_type][$slug] ) ) {
158
-							unset( $validated_variations['variations'][$template_pack][$messenger][$message_type][$slug] );
159
-							EE_Error::add_error( sprintf( __('Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', 'event_espresso' ), $label, $template_pack, $messenger, $message_type, $registered_var  ) );
153
+		foreach ($validated_variations['variations'] as $template_pack => $messenger) {
154
+			foreach ($messenger as $message_type => $variations) {
155
+				foreach ($variations as $slug => $label) {
156
+					foreach (self::$_registry as $registered_var => $reg_settings) {
157
+						if (isset($reg_settings['variations'][$template_pack][$messenger][$message_type][$slug])) {
158
+							unset($validated_variations['variations'][$template_pack][$messenger][$message_type][$slug]);
159
+							EE_Error::add_error(sprintf(__('Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', 'event_espresso'), $label, $template_pack, $messenger, $message_type, $registered_var));
160 160
 						}
161 161
 					}
162 162
 				}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return string                    The path to the requested variation.
187 187
 	 */
188
-	public static function get_variation( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) {
188
+	public static function get_variation($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) {
189 189
 
190 190
 		//so let's loop through our registered variations and then pull any details matching the request.
191
-		foreach ( self::$_registry as $registry_slug => $registry_settings ) {
191
+		foreach (self::$_registry as $registry_slug => $registry_settings) {
192 192
 			$base = $url ? $registry_settings['base_url'] : $registry_settings['base_path'];
193
-			$file_string = $messenger . '_' . $type. '_' . $variation . $file_extension;
193
+			$file_string = $messenger.'_'.$type.'_'.$variation.$file_extension;
194 194
 			//see if this file exists
195
-			if ( is_readable( $registry_settings['base_path'] . $file_string ) ) {
196
-				return $base . $file_string;
195
+			if (is_readable($registry_settings['base_path'].$file_string)) {
196
+				return $base.$file_string;
197 197
 			}
198 198
 		}
199 199
 
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @return array                   new variations array (or existing one if nothing registered)
219 219
 	 */
220
-	public static function get_variations( $variations, $messenger,  $message_type, EE_Messages_Template_Pack $template_pack ) {
220
+	public static function get_variations($variations, $messenger, $message_type, EE_Messages_Template_Pack $template_pack) {
221 221
 		//first let's check if we even have registered variations and get out early.
222
-		if ( empty( self::$_registry ) ) {
222
+		if (empty(self::$_registry)) {
223 223
 			return $variations;
224 224
 		}
225 225
 
226 226
 		//do we have any new variations for the given messenger, $message_type, and template packs
227
-		foreach ( self::$_registry as $registry_slug => $registry_settings ) {
227
+		foreach (self::$_registry as $registry_slug => $registry_settings) {
228 228
 			//allow for different conditions.
229
-			if ( empty( $messenger) ) {
230
-				$variations =  array_merge( $registry_settings['variations'], $variations );
231
-			} else if ( ! empty( $messenger ) && empty( $message_type ) && ! empty( $registry_settings['variations'][$template_pack->dbref][$messenger] ) ) {
232
-				$variations =  array_merge( $registry_settings['variations'][$template_pack->dbref][$messenger], $variations );
233
-			} else if ( ! empty( $messenger ) && ! empty( $message_type ) && ! empty( $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type] ) ) {
234
-				$variations = array_merge( $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], $variations );
229
+			if (empty($messenger)) {
230
+				$variations = array_merge($registry_settings['variations'], $variations);
231
+			} else if ( ! empty($messenger) && empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger])) {
232
+				$variations = array_merge($registry_settings['variations'][$template_pack->dbref][$messenger], $variations);
233
+			} else if ( ! empty($messenger) && ! empty($message_type) && ! empty($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type])) {
234
+				$variations = array_merge($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], $variations);
235 235
 			}
236 236
 		}
237 237
 		return $variations;
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return void
252 252
 	 */
253
-	public static function deregister( $variation_ref = NULL ) {
254
-		if ( !empty( self::$_registry[$variation_ref] ) ) {
255
-    			unset( self::$_registry[$variation_ref] );
253
+	public static function deregister($variation_ref = NULL) {
254
+		if ( ! empty(self::$_registry[$variation_ref])) {
255
+    			unset(self::$_registry[$variation_ref]);
256 256
     		}
257 257
 	}
258 258
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message template pack variation for the EE messages system.
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -185,7 +185,7 @@
 block discarded – undo
185 185
 	 */
186 186
 	public static function deregister( $variation_ref = NULL ) {
187 187
 		if ( !empty( self::$_registry[$variation_ref] ) ) {
188
-    			unset( self::$_registry[$variation_ref] );
189
-    		}
188
+				unset( self::$_registry[$variation_ref] );
189
+			}
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.