Completed
Branch BUG-9583-fix-fetching-term-rel... (646110)
by
unknown
539:15 queued 523:53
created
core/admin/EE_Admin_Page_CPT_Init.core.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	public function do_initial_loads() {
33 33
 		//we want to use the corresponding admin page object (but not route it!).  To do this we just set _routing to false.  That way this page object is being loaded on all pages to make sure we hook into admin properly.  But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;)
34 34
 		//This is important because we have hooks that help redirect custom post type saves
35
-		if ( !isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] != $this->_menu_map->menu_slug ) ) {
35
+		if ( ! isset($_REQUEST['page']) || (isset($_REQUEST['page']) && $_REQUEST['page'] != $this->_menu_map->menu_slug)) {
36 36
 			$this->_routing = FALSE;
37 37
 			$this->_initialize_admin_page();
38 38
 		} else {
@@ -40,17 +40,17 @@  discard block
 block discarded – undo
40 40
 			$this->_initialize_admin_page();
41 41
 			//added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality
42 42
 			remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization');
43
-			add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100 );
43
+			add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100);
44 44
 			//end removal of autosave functionality.
45 45
 		}
46 46
 	}
47 47
 
48 48
 	public function wp_just_in_time_script_localization() {
49
-		wp_localize_script( 'autosave', 'autosaveL10n', array(
49
+		wp_localize_script('autosave', 'autosaveL10n', array(
50 50
 			'autosaveInterval' => 172800,
51 51
 			'savingText' => __('Saving Draft…'),
52 52
 			'saveAlert' => __('The changes you made will be lost if you navigate away from this page.')
53
-		) );
53
+		));
54 54
 	}
55 55
 
56 56
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Init.core.php 3 patches
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 		$this->_set_init_properties();
89 89
 
90 90
 		//global styles/scripts across all wp admin pages
91
-		add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5 );
91
+		add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5);
92 92
 
93 93
 		//load initial stuff.
94 94
 		$this->_set_file_and_folder_name();
95 95
 
96 96
 		$this->_set_menu_map();
97 97
 
98
-		if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) )
98
+		if (empty($this->_menu_map) || is_array($this->_menu_map))
99 99
 			 {
100
-			 	EE_Error::doing_it_wrong( get_class( $this ) . '::$_menu_map', sprintf( __('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso' ), get_class( $this ) ), '4.4.0' );
100
+			 	EE_Error::doing_it_wrong(get_class($this).'::$_menu_map', sprintf(__('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso'), get_class($this)), '4.4.0');
101 101
 			 	return;
102 102
 			 }
103 103
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	public function load_wp_global_scripts_styles() {
160 160
 		/** STYLES **/
161 161
 		//register
162
-		wp_register_style('espresso_menu', EE_ADMIN_URL . 'assets/admin-menu-styles.css');
162
+		wp_register_style('espresso_menu', EE_ADMIN_URL.'assets/admin-menu-styles.css');
163 163
 
164 164
 
165 165
 
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 
202 202
 
203 203
 	protected function _set_capability() {
204
-		$capability = empty($this->capability) ?  $this->_menu_map->capability : $this->capability;
205
-		$this->capability = apply_filters( 'FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability );
204
+		$capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability;
205
+		$this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability);
206 206
 	}
207 207
 
208 208
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	public function initialize_admin_page() {
221 221
 		//let's check user access first
222 222
 		$this->_check_user_access();
223
-		if ( !is_object( $this->_loaded_page_object) ) return;
223
+		if ( ! is_object($this->_loaded_page_object)) return;
224 224
 		$this->_loaded_page_object->route_admin_request();
225 225
 		return;
226 226
 	}
@@ -232,25 +232,25 @@  discard block
 block discarded – undo
232 232
 
233 233
 
234 234
 	public function set_page_dependencies($wp_page_slug) {
235
-		if ( !$this->_load_page ) return;
235
+		if ( ! $this->_load_page) return;
236 236
 
237
-		if ( !is_object($this->_loaded_page_object) ) {
237
+		if ( ! is_object($this->_loaded_page_object)) {
238 238
 			$msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso');
239
-			$msg[] = $msg[0] . "\r\n" . sprintf(
239
+			$msg[] = $msg[0]."\r\n".sprintf(
240 240
 				__('The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', 'event_espresso'),
241 241
 				 $this->_file_name,
242 242
 				 $this->_file_name,
243
-				 $this->_folder_path . $this->_file_name,
243
+				 $this->_folder_path.$this->_file_name,
244 244
 				 $this->_menu_map->menu_slug
245 245
 			);
246
-			throw new EE_Error( implode( '||', $msg) );
246
+			throw new EE_Error(implode('||', $msg));
247 247
 		}
248 248
 
249 249
 		$this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
250
-		$page_hook = 'load-' . $wp_page_slug;
250
+		$page_hook = 'load-'.$wp_page_slug;
251 251
 		//hook into page load hook so all page specific stuff get's loaded.
252
-		if ( !empty($wp_page_slug) )
253
-			add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') );
252
+		if ( ! empty($wp_page_slug))
253
+			add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies'));
254 254
 	}
255 255
 
256 256
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function do_initial_loads() {
263 263
 		//no loading or initializing if menu map is setup incorrectly.
264
-		if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) ) {
264
+		if (empty($this->_menu_map) || is_array($this->_menu_map)) {
265 265
 			return;
266 266
 		}
267 267
 		$this->_initialize_admin_page();
@@ -278,19 +278,19 @@  discard block
 block discarded – undo
278 278
 		$bt = debug_backtrace();
279 279
 		//for more reliable determination of folder name
280 280
 		//we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this).  Why?  Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins)
281
-		$class = get_class( $this );
282
-		foreach ( $bt as $index => $values ) {
283
-			if ( isset( $values['class'] ) && $values['class'] == $class ) {
281
+		$class = get_class($this);
282
+		foreach ($bt as $index => $values) {
283
+			if (isset($values['class']) && $values['class'] == $class) {
284 284
 				$file_index = $index - 1;
285
-				$this->_folder_name = basename(dirname($bt[$file_index]['file']) );
286
-				if ( !empty( $this->_folder_name ) ) break;
285
+				$this->_folder_name = basename(dirname($bt[$file_index]['file']));
286
+				if ( ! empty($this->_folder_name)) break;
287 287
 			}
288 288
 		}
289 289
 
290
-		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . DS;
290
+		$this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.DS;
291 291
 
292
-		$this->_file_name = preg_replace( '/^ee/' , 'EE', $this->_folder_name );
293
-		$this->_file_name = ucwords( str_replace('_', ' ', $this->_file_name) );
292
+		$this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name);
293
+		$this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name));
294 294
 		$this->_file_name = str_replace(' ', '_', $this->_file_name);
295 295
 	}
296 296
 
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 	 * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks files/classes
303 303
 	 * @return array
304 304
 	 */
305
-	public function register_hooks( $extend = FALSE ) {
305
+	public function register_hooks($extend = FALSE) {
306 306
 
307 307
 		//get a list of files in the directory that have the "Hook" in their name an
308 308
 
309 309
 		//if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property.  Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf.
310
-		if ( $extend ) {
311
-			$hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS . '*' . $this->_file_name . '_Hooks_Extend.class.php' );
312
-			$this->_hook_paths = $this->_register_hook_files( $hook_files_glob_path, $extend );
310
+		if ($extend) {
311
+			$hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS.'*'.$this->_file_name.'_Hooks_Extend.class.php');
312
+			$this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend);
313 313
 		}
314 314
 
315 315
 		//loop through decaf folders
316
-		$hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' );
317
-		$this->_hook_paths = array_merge( $this->_register_hook_files( $hook_files_glob_path ), $this->_hook_paths );  //making sure any extended hook paths are later in the array than the core hook paths!
316
+		$hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php');
317
+		$this->_hook_paths = array_merge($this->_register_hook_files($hook_files_glob_path), $this->_hook_paths); //making sure any extended hook paths are later in the array than the core hook paths!
318 318
 
319 319
 		return $this->_hook_paths;
320 320
 
@@ -322,27 +322,27 @@  discard block
 block discarded – undo
322 322
 
323 323
 
324 324
 
325
-	protected function _register_hook_files( $hook_files_glob_path, $extend = FALSE ) {
325
+	protected function _register_hook_files($hook_files_glob_path, $extend = FALSE) {
326 326
 		$hook_paths = array();
327
-		if ( $hook_files = glob( $hook_files_glob_path ) ) {
328
-			if ( empty( $hook_files ) ) {
327
+		if ($hook_files = glob($hook_files_glob_path)) {
328
+			if (empty($hook_files)) {
329 329
 				return array();
330 330
 			}
331
-			foreach ( $hook_files as $file ) {
331
+			foreach ($hook_files as $file) {
332 332
 				//lets get the linked admin.
333
-				$hook_file = $extend ? str_replace( EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS, '', $file ) : str_replace($this->_folder_path, '', $file );
334
-				$replace = $extend ? '_' . $this->_file_name . '_Hooks_Extend.class.php' : '_' . $this->_file_name . '_Hooks.class.php';
335
-				$rel_admin = str_replace( $replace, '', $hook_file);
333
+				$hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS, '', $file) : str_replace($this->_folder_path, '', $file);
334
+				$replace = $extend ? '_'.$this->_file_name.'_Hooks_Extend.class.php' : '_'.$this->_file_name.'_Hooks.class.php';
335
+				$rel_admin = str_replace($replace, '', $hook_file);
336 336
 				$rel_admin = strtolower($rel_admin);
337 337
 				$hook_paths[] = $file;
338 338
 
339 339
 				//make sure we haven't already got a hook setup for this page path
340
-				if ( in_array( $rel_admin, $this->_files_hooked ) )
340
+				if (in_array($rel_admin, $this->_files_hooked))
341 341
 					continue;
342 342
 
343 343
 				$this->hook_file = $hook_file;
344
-				$rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin;
345
-				$filter = add_filter( $rel_admin_hook, array($this, 'load_admin_hook') );
344
+				$rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin;
345
+				$filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook'));
346 346
 				$this->_files_hooked[] = $rel_admin;
347 347
 			}
348 348
 		}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	protected function _initialize_admin_page() {
368 368
 
369 369
 		//JUST CHECK WE'RE ON RIGHT PAGE.
370
-		if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing )
370
+		if (( ! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing)
371 371
 			return; //not on the right page so let's get out.
372 372
 		$this->_load_page = TRUE;
373 373
 
@@ -375,30 +375,30 @@  discard block
 block discarded – undo
375 375
 //		spl_autoload_register(array( $this, 'set_autoloaders') );
376 376
 
377 377
 		//we don't need to do a page_request check here because it's only called via WP menu system.
378
-		$admin_page = $this->_file_name . '_Admin_Page';
379
-		$hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page;
378
+		$admin_page = $this->_file_name.'_Admin_Page';
379
+		$hook_suffix = $this->_menu_map->menu_slug.'_'.$admin_page;
380 380
 		$admin_page = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", $admin_page);
381 381
 
382 382
 		// define requested admin page class name then load the file and instantiate
383
-		$path_to_file = str_replace( array( '\\', '/' ), DS, $this->_folder_path . $admin_page . '.core.php' );
384
-		$path_to_file=apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",$path_to_file );//so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
383
+		$path_to_file = str_replace(array('\\', '/'), DS, $this->_folder_path.$admin_page.'.core.php');
384
+		$path_to_file = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", $path_to_file); //so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
385 385
 
386
-		if ( is_readable( $path_to_file )) {
386
+		if (is_readable($path_to_file)) {
387 387
 			// This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
388
-			do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization' );
389
-			do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug );
390
-			require_once( $path_to_file );
391
-			$a = new ReflectionClass( $admin_page );
392
-			$this->_loaded_page_object = $a->newInstance( $this->_routing );
388
+			do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
389
+			do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_'.$this->_menu_map->menu_slug);
390
+			require_once($path_to_file);
391
+			$a = new ReflectionClass($admin_page);
392
+			$this->_loaded_page_object = $a->newInstance($this->_routing);
393 393
 		}
394
-		do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization' );
395
-		do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug );
394
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
395
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_'.$this->_menu_map->menu_slug);
396 396
 	}
397 397
 
398 398
 
399 399
 
400 400
 	public function get_admin_page_name() {
401
-		return $this->_file_name . '_Admin_Page';
401
+		return $this->_file_name.'_Admin_Page';
402 402
 	}
403 403
 
404 404
 
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @return bool|die true if pass (or admin) wp_die if fail
432 432
 	 */
433 433
 	private function _check_user_access() {
434
-		if ( ! EE_Registry::instance()->CAP->current_user_can( $this->_menu_map->capability, $this->_menu_map->menu_slug ) ) {
435
-			wp_die( __('You don\'t have access to this page.'), '', array( 'back_link' => true ) );
434
+		if ( ! EE_Registry::instance()->CAP->current_user_can($this->_menu_map->capability, $this->_menu_map->menu_slug)) {
435
+			wp_die(__('You don\'t have access to this page.'), '', array('back_link' => true));
436 436
 		}
437 437
 		return true;
438 438
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
@@ -220,7 +222,9 @@  discard block
 block discarded – undo
220 222
 	public function initialize_admin_page() {
221 223
 		//let's check user access first
222 224
 		$this->_check_user_access();
223
-		if ( !is_object( $this->_loaded_page_object) ) return;
225
+		if ( !is_object( $this->_loaded_page_object) ) {
226
+			return;
227
+		}
224 228
 		$this->_loaded_page_object->route_admin_request();
225 229
 		return;
226 230
 	}
@@ -232,7 +236,9 @@  discard block
 block discarded – undo
232 236
 
233 237
 
234 238
 	public function set_page_dependencies($wp_page_slug) {
235
-		if ( !$this->_load_page ) return;
239
+		if ( !$this->_load_page ) {
240
+			return;
241
+		}
236 242
 
237 243
 		if ( !is_object($this->_loaded_page_object) ) {
238 244
 			$msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso');
@@ -249,8 +255,9 @@  discard block
 block discarded – undo
249 255
 		$this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
250 256
 		$page_hook = 'load-' . $wp_page_slug;
251 257
 		//hook into page load hook so all page specific stuff get's loaded.
252
-		if ( !empty($wp_page_slug) )
253
-			add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') );
258
+		if ( !empty($wp_page_slug) ) {
259
+					add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') );
260
+		}
254 261
 	}
255 262
 
256 263
 
@@ -283,7 +290,9 @@  discard block
 block discarded – undo
283 290
 			if ( isset( $values['class'] ) && $values['class'] == $class ) {
284 291
 				$file_index = $index - 1;
285 292
 				$this->_folder_name = basename(dirname($bt[$file_index]['file']) );
286
-				if ( !empty( $this->_folder_name ) ) break;
293
+				if ( !empty( $this->_folder_name ) ) {
294
+					break;
295
+				}
287 296
 			}
288 297
 		}
289 298
 
@@ -337,8 +346,9 @@  discard block
 block discarded – undo
337 346
 				$hook_paths[] = $file;
338 347
 
339 348
 				//make sure we haven't already got a hook setup for this page path
340
-				if ( in_array( $rel_admin, $this->_files_hooked ) )
341
-					continue;
349
+				if ( in_array( $rel_admin, $this->_files_hooked ) ) {
350
+									continue;
351
+				}
342 352
 
343 353
 				$this->hook_file = $hook_file;
344 354
 				$rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin;
@@ -367,8 +377,10 @@  discard block
 block discarded – undo
367 377
 	protected function _initialize_admin_page() {
368 378
 
369 379
 		//JUST CHECK WE'RE ON RIGHT PAGE.
370
-		if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing )
371
-			return; //not on the right page so let's get out.
380
+		if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) {
381
+					return;
382
+		}
383
+		//not on the right page so let's get out.
372 384
 		$this->_load_page = TRUE;
373 385
 
374 386
 		//let's set page specific autoloaders.  Note that this just sets autoloaders for THIS set of admin pages.
Please login to merge, or discard this patch.
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -214,7 +214,6 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @access  public
216 216
 	 * @uses   _initialize_admin_page()
217
-	 * @param  string $dir_name directory name for specific admin_page being loaded.
218 217
 	 * @return void
219 218
 	 */
220 219
 	public function initialize_admin_page() {
@@ -231,6 +230,9 @@  discard block
 block discarded – undo
231 230
 
232 231
 
233 232
 
233
+	/**
234
+	 * @param string $wp_page_slug
235
+	 */
234 236
 	public function set_page_dependencies($wp_page_slug) {
235 237
 		if ( !$this->_load_page ) return;
236 238
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Loader.core.php 2 patches
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 		//let's do a scan and see what installed pages we have
120 120
 		$this->_get_installed_pages();
121 121
 		//set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to).
122
-		add_action('admin_menu', array( $this, 'set_menus' ));
123
-		add_action( 'network_admin_menu', array( $this, 'set_network_menus' ) );
122
+		add_action('admin_menu', array($this, 'set_menus'));
123
+		add_action('network_admin_menu', array($this, 'set_network_menus'));
124 124
 	}
125 125
 
126 126
 
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 	 * @return void
134 134
 	 */
135 135
 	private function _define_caffeinated_constants() {
136
-		if ( ! defined( 'EE_CORE_CAF_ADMIN'  ) ) {
137
-			define( 'EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
138
-			define( 'EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
139
-			define( 'EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
140
-			define( 'EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
141
-			define( 'EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
142
-			define( 'EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
136
+		if ( ! defined('EE_CORE_CAF_ADMIN')) {
137
+			define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/');
138
+			define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/');
139
+			define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/');
140
+			define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/');
141
+			define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/');
142
+			define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/');
143 143
 		}
144 144
 	}
145 145
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		//set array of EE_Admin_Page_Menu_Group objects
160 160
 		$groups = array(
161
-			'main' => new EE_Admin_Page_Menu_Group( array(
161
+			'main' => new EE_Admin_Page_Menu_Group(array(
162 162
 				'menu_label' => __('Main', 'event_espresso'),
163 163
 				'show_on_menu' => EE_Admin_Page_Menu_Map::NONE,
164 164
 				'menu_slug' => 'main',
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 				'menu_order' => 0,
167 167
 				'parent_slug' => 'espresso_events',
168 168
 				)),
169
-			'management' => new EE_Admin_Page_Menu_Group( array(
169
+			'management' => new EE_Admin_Page_Menu_Group(array(
170 170
 				'menu_label' => __('Management', 'event_espresso'),
171 171
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
172 172
 				'menu_slug' => 'management',
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 				'menu_order' => 10,
175 175
 				'parent_slug' => 'espresso_events'
176 176
 				)),
177
-			'settings' => new EE_Admin_Page_Menu_Group( array(
177
+			'settings' => new EE_Admin_Page_Menu_Group(array(
178 178
 				'menu_label' => __('Settings', 'event_espresso'),
179 179
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
180 180
 				'menu_slug' => 'settings',
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 				'menu_order' => 30,
183 183
 				'parent_slug' => 'espresso_events'
184 184
 				)),
185
-			'templates' => new EE_Admin_Page_Menu_Group( array(
185
+			'templates' => new EE_Admin_Page_Menu_Group(array(
186 186
 				'menu_label' => __('Templates', 'event_espresso'),
187 187
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
188 188
 				'menu_slug' => 'templates',
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 				'menu_order' => 40,
191 191
 				'parent_slug' => 'espresso_events'
192 192
 				)),
193
-			'extras' => new EE_Admin_Page_Menu_Group( array(
193
+			'extras' => new EE_Admin_Page_Menu_Group(array(
194 194
 				'menu_label' => __('Extras', 'event_espresso'),
195 195
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
196 196
 				'menu_slug' => 'extras',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				'parent_slug' => 'espresso_events',
200 200
 				'maintenance_mode_parent' => 'espresso_maintenance_settings'
201 201
 				)),
202
-			'tools' => new EE_Admin_Page_Menu_Group( array(
202
+			'tools' => new EE_Admin_Page_Menu_Group(array(
203 203
 				'menu_label' => __("Tools", "event_espresso"),
204 204
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
205 205
 				'menu_slug' => 'tools',
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 				'menu_order' => 60,
208 208
 				'parent_slug' => 'espresso_events'
209 209
 				)),
210
-			'addons' => new EE_Admin_Page_Menu_Group( array(
210
+			'addons' => new EE_Admin_Page_Menu_Group(array(
211 211
 				'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
212 212
 				'menu_label' => __('Add-ons', 'event_espresso'),
213 213
 				'menu_slug' => 'addons',
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 				))
218 218
 			);
219 219
 
220
-		$this->_admin_menu_groups = apply_filters( 'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups );
220
+		$this->_admin_menu_groups = apply_filters('FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups);
221 221
 	}
222 222
 
223 223
 
@@ -235,10 +235,10 @@  discard block
 block discarded – undo
235 235
 	private function _rearrange_menu_groups() {
236 236
 		$groups = array();
237 237
 		//first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
238
-		usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) );
239
-		foreach ( $this->_admin_menu_groups as $group ) {
240
-			if ( ! $group instanceof EE_Admin_Page_Menu_Group )
241
-				throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) );
238
+		usort($this->_admin_menu_groups, array($this, '_sort_menu_maps'));
239
+		foreach ($this->_admin_menu_groups as $group) {
240
+			if ( ! $group instanceof EE_Admin_Page_Menu_Group)
241
+				throw new EE_Error(sprintf(__('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE)));
242 242
 			$groups[$group->menu_slug] = $group;
243 243
 		}
244 244
 		return $groups;
@@ -256,48 +256,48 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	private function _get_installed_pages() {
258 258
 		$installed_refs = array();
259
-		$exclude = array( 'assets', 'templates' );
259
+		$exclude = array('assets', 'templates');
260 260
 		// grab everything in the  admin core directory
261
-		$admin_screens = glob( EE_ADMIN_PAGES . '*', GLOB_ONLYDIR );
262
-		if ( $admin_screens ) {
263
-			foreach( $admin_screens as $admin_screen ) {
261
+		$admin_screens = glob(EE_ADMIN_PAGES.'*', GLOB_ONLYDIR);
262
+		if ($admin_screens) {
263
+			foreach ($admin_screens as $admin_screen) {
264 264
 				// files and anything in the exclude array need not apply
265
-				if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) {
265
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
266 266
 					// these folders represent the different EE admin pages
267
-					$installed_refs[ basename( $admin_screen ) ] = $admin_screen;
267
+					$installed_refs[basename($admin_screen)] = $admin_screen;
268 268
 				}
269 269
 			}
270 270
 		}
271 271
 
272
-		if ( empty( $installed_refs ) ) {
272
+		if (empty($installed_refs)) {
273 273
 			$error_msg[] = __('There are no EE_Admin pages detected, it looks like EE did not install properly', 'event_espresso');
274
-			$error_msg[] = $error_msg[0] . "\r\n" . sprintf( __('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES );
275
-			throw new EE_Error( implode( '||', $error_msg ));
274
+			$error_msg[] = $error_msg[0]."\r\n".sprintf(__('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES);
275
+			throw new EE_Error(implode('||', $error_msg));
276 276
 		}
277 277
 
278 278
 		//this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
279 279
 		$installed_refs = $this->_set_caffeinated($installed_refs);
280 280
 		//allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
281
-		$installed_refs = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs );
282
-		$this->_caffeinated_extends = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends );
281
+		$installed_refs = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs);
282
+		$this->_caffeinated_extends = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends);
283 283
 
284 284
 		//loop through admin pages and setup the $_installed_pages array.
285 285
 		$hooks_ref = array();
286
-		foreach ( $installed_refs as $page => $path ) {
286
+		foreach ($installed_refs as $page => $path) {
287 287
 			// set autoloaders for our admin page classes based on included path information
288
-			EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $path );
288
+			EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path);
289 289
 			// build list of installed pages
290
-			$this->_installed_pages[$page] = $this->_load_admin_page( $page, $path );
290
+			$this->_installed_pages[$page] = $this->_load_admin_page($page, $path);
291 291
 			// verify returned object
292
-			if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) {
293
-				if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map ) {
292
+			if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) {
293
+				if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
294 294
 					continue;
295 295
 				}
296 296
 
297 297
 				//skip if in full maintenance mode and maintenance_mode_parent is set
298 298
 				$maintenance_mode_parent = $this->_installed_pages[$page]->get_menu_map()->maintenance_mode_parent;
299
-				if ( empty( $maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
300
-					unset( $installed_refs[$page] );
299
+				if (empty($maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
300
+					unset($installed_refs[$page]);
301 301
 					continue;
302 302
 				}
303 303
 
@@ -305,45 +305,45 @@  discard block
 block discarded – undo
305 305
 				//flag for register hooks on extended pages b/c extended pages use the default INIT.
306 306
 				$extend = FALSE;
307 307
 				//now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals.  If there are then let's hook into the init admin filter and load our extend instead.
308
-				if ( isset( $this->_caffeinated_extends[$page] ) ) {
308
+				if (isset($this->_caffeinated_extends[$page])) {
309 309
 					$this->_current_caf_extend_slug = $page;
310
-					$path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name();
311
-					$path_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"] . '";';
312
-					$page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name();
313
-					$page_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"] . '";';
310
+					$path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name();
311
+					$path_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"].'";';
312
+					$page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name();
313
+					$page_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"].'";';
314 314
 
315
-					$hook_function_path = create_function( '$path_to_file', $path_runtime);
316
-					$hook_function_page = create_function( '$admin_page', $page_runtime );
315
+					$hook_function_path = create_function('$path_to_file', $path_runtime);
316
+					$hook_function_page = create_function('$admin_page', $page_runtime);
317 317
 
318
-					add_filter( $path_hook, $hook_function_path );
319
-					add_filter( $page_hook, $hook_function_page );
318
+					add_filter($path_hook, $hook_function_path);
319
+					add_filter($page_hook, $hook_function_page);
320 320
 					$extend = TRUE;
321 321
 				}
322 322
 				//let's do the registered hooks
323
-				$extended_hooks = $this->_installed_pages[$page]->register_hooks( $extend );
323
+				$extended_hooks = $this->_installed_pages[$page]->register_hooks($extend);
324 324
 				$hooks_ref = array_merge($hooks_ref, $extended_hooks);
325 325
 			}
326 326
 		}
327 327
 
328 328
 		//the hooks_ref is all the pages where we have $extended _Hooks files that will extend a class in a different folder.  So we want to make sure we load the file for the parent.
329 329
 		//first make sure we've got unique values
330
-		$hooks_ref = array_unique( $hooks_ref );
330
+		$hooks_ref = array_unique($hooks_ref);
331 331
 		//now let's loop and require!
332
-		foreach ( $hooks_ref as $path ) {
333
-			require_once( $path );
332
+		foreach ($hooks_ref as $path) {
333
+			require_once($path);
334 334
 		}
335 335
 		//make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
336 336
 		global $ee_menu_slugs;
337 337
 		$ee_menu_slugs = $this->_menu_slugs;
338 338
 
339 339
 		//we need to loop again to run any early code
340
-		foreach ( $installed_refs as $page => $path ) {
341
-			if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) {
340
+		foreach ($installed_refs as $page => $path) {
341
+			if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) {
342 342
 				$this->_installed_pages[$page]->do_initial_loads();
343 343
 			}
344 344
 		}
345 345
 
346
-		do_action( 'AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages );
346
+		do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
347 347
 
348 348
 	}
349 349
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @param string $page_slug
356 356
 	 * @return EE_Admin_Page
357 357
 	 */
358
-	public function get_admin_page_object( $page_slug = '' ) {
359
-		if ( isset( $this->_installed_pages[ $page_slug ] )) {
360
-			return $this->_installed_pages[ $page_slug ]->loaded_page_object();
358
+	public function get_admin_page_object($page_slug = '') {
359
+		if (isset($this->_installed_pages[$page_slug])) {
360
+			return $this->_installed_pages[$page_slug]->loaded_page_object();
361 361
 		}
362 362
 		return NULL;
363 363
 	}
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
 	 * @param $dir_name
371 371
 	 * @return string
372 372
 	 */
373
-	private function _get_classname_for_admin_page( $dir_name = '' ) {
374
-		$class_name = str_replace( '_', ' ', strtolower( $dir_name ));
375
-		return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page';
373
+	private function _get_classname_for_admin_page($dir_name = '') {
374
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
375
+		return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page';
376 376
 	}
377 377
 
378 378
 
@@ -383,9 +383,9 @@  discard block
 block discarded – undo
383 383
 	 * @param $dir_name
384 384
 	 * @return string
385 385
 	 */
386
-	private function _get_classname_for_admin_init_page( $dir_name = '' ) {
387
-		$class_name = str_replace( '_', ' ', strtolower( $dir_name ));
388
-		return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page_Init';
386
+	private function _get_classname_for_admin_init_page($dir_name = '') {
387
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
388
+		return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init';
389 389
 	}
390 390
 
391 391
 
@@ -398,13 +398,13 @@  discard block
 block discarded – undo
398 398
 	 * @throws EE_Error
399 399
 	 * @return object|bool  return page object if valid, bool false if not.
400 400
 	 */
401
-	private function _load_admin_page( $page = '', $path = '' ) {
402
-		$class_name = $this->_get_classname_for_admin_init_page( $page );
403
- 		EE_Registry::instance()->load_file( $path, $class_name, 'core' );
404
-		if ( ! class_exists( $class_name )) {
405
-			$error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page);
406
-			$error_msg[] = $error_msg[0] . "\r\n" . sprintf( __( 'There is no Init class in place for the %s admin page.', 'event_espresso') . '<br />' . __( 'Make sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, $class_name );
407
-			throw new EE_Error( implode( '||', $error_msg ));
401
+	private function _load_admin_page($page = '', $path = '') {
402
+		$class_name = $this->_get_classname_for_admin_init_page($page);
403
+ 		EE_Registry::instance()->load_file($path, $class_name, 'core');
404
+		if ( ! class_exists($class_name)) {
405
+			$error_msg[] = sprintf(__('Something went wrong with loading the %s admin page.', 'event_espresso'), $page);
406
+			$error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no Init class in place for the %s admin page.', 'event_espresso').'<br />'.__('Make sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', 'event_espresso'), $page, $class_name);
407
+			throw new EE_Error(implode('||', $error_msg));
408 408
 		}
409 409
 		$a = new ReflectionClass($class_name);
410 410
 		return  $a->newInstance();
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 	public function set_menus() {
424 424
 		//prep the menu pages (sort, group.)
425 425
 		$this->_prep_pages();
426
-		foreach( $this->_prepped_menu_maps as $menu_map ) {
427
-			if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) {
428
-				$menu_map->add_menu_page( FALSE );
426
+		foreach ($this->_prepped_menu_maps as $menu_map) {
427
+			if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
428
+				$menu_map->add_menu_page(FALSE);
429 429
 			}
430 430
 		}
431 431
 	}
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @return void
440 440
 	 */
441
-	public function set_network_menus(){
441
+	public function set_network_menus() {
442 442
 		$this->_prep_pages();
443
-		foreach( $this->_prepped_menu_maps as $menu_map ) {
444
-			if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) {
445
-				$menu_map->add_menu_page( TRUE );
443
+		foreach ($this->_prepped_menu_maps as $menu_map) {
444
+			if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
445
+				$menu_map->add_menu_page(TRUE);
446 446
 			}
447 447
 		}
448 448
 	}
@@ -463,22 +463,22 @@  discard block
 block discarded – undo
463 463
 		//rearrange _admin_menu_groups to be indexed by group slug.
464 464
 		$menu_groups = $this->_rearrange_menu_groups();
465 465
 
466
-		foreach( $this->_installed_pages as $page ) {
467
-			if ( $page instanceof EE_Admin_page_Init ) {
466
+		foreach ($this->_installed_pages as $page) {
467
+			if ($page instanceof EE_Admin_page_Init) {
468 468
 				$page_map = $page->get_menu_map();
469 469
 				//if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item.
470
-				if ( is_array( $page_map ) || empty( $page_map ) ) {
471
-					EE_Error::add_persistent_admin_notice( 'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION, sprintf( __('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso' ), $page->label ) );
470
+				if (is_array($page_map) || empty($page_map)) {
471
+					EE_Error::add_persistent_admin_notice('menu_map_warning_'.str_replace(' ', '_', $page->label).'_'.EVENT_ESPRESSO_VERSION, sprintf(__('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso'), $page->label));
472 472
 					continue;
473 473
 				}
474 474
 
475 475
 				//if page map is NOT a EE_Admin_Page_Menu_Map object then throw error.
476
-				if ( ! $page_map instanceof EE_Admin_Page_Menu_Map ) {
477
-					throw new EE_Error( sprintf( __('The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map ) );
476
+				if ( ! $page_map instanceof EE_Admin_Page_Menu_Map) {
477
+					throw new EE_Error(sprintf(__('The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map));
478 478
 				}
479 479
 
480 480
 				//use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array.
481
-				if ( empty( $page_map->maintenance_mode_parent ) &&  EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
481
+				if (empty($page_map->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
482 482
 					continue;
483 483
 				}
484 484
 
@@ -487,21 +487,21 @@  discard block
 block discarded – undo
487 487
 			}
488 488
 		}
489 489
 
490
-		if ( empty( $pages_array )) {
491
-			throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso') );
490
+		if (empty($pages_array)) {
491
+			throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso'));
492 492
 		}
493 493
 
494 494
 		//let's sort the groups, make sure it's a valid group, add header (if to show).
495
-		foreach ( $pages_array as $group => $menu_maps ) {
495
+		foreach ($pages_array as $group => $menu_maps) {
496 496
 			//valid_group?
497
-			if ( ! array_key_exists( $group, $menu_groups ) )
497
+			if ( ! array_key_exists($group, $menu_groups))
498 498
 				continue;
499 499
 
500 500
 			//sort pages.
501
-			usort( $menu_maps, array( $this, '_sort_menu_maps' ) );
501
+			usort($menu_maps, array($this, '_sort_menu_maps'));
502 502
 
503 503
 			//prepend header
504
-			array_unshift( $menu_maps, $menu_groups[$group] );
504
+			array_unshift($menu_maps, $menu_groups[$group]);
505 505
 
506 506
 			//reset $pages_array with prepped data
507 507
 			$pages_array[$group] = $menu_maps;
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
 
510 510
 
511 511
 		//now let's setup the _prepped_menu_maps property
512
-		foreach ( $menu_groups as $group => $group_objs ) {
513
-			if ( isset( $pages_array[$group] ) )
514
-				$this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] );
512
+		foreach ($menu_groups as $group => $group_objs) {
513
+			if (isset($pages_array[$group]))
514
+				$this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[$group]);
515 515
 		}/**/
516 516
 
517 517
 	}
@@ -531,10 +531,10 @@  discard block
 block discarded – undo
531 531
 	 * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be loaded.
532 532
 	 * @return array
533 533
 	 */
534
-	private function _set_caffeinated( $installed_refs ) {
534
+	private function _set_caffeinated($installed_refs) {
535 535
 
536 536
 		//first let's check if there IS a caffeinated folder. If there is not then lets get out.
537
-		if ( ! is_dir( EE_PLUGIN_DIR_PATH . 'caffeinated' . DS . 'admin' ) || ( defined( 'EE_DECAF' ) && EE_DECAF )) {
537
+		if ( ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated'.DS.'admin') || (defined('EE_DECAF') && EE_DECAF)) {
538 538
 			return $installed_refs;
539 539
 		}
540 540
 
@@ -543,15 +543,15 @@  discard block
 block discarded – undo
543 543
 		$exclude = array('tickets');
544 544
 
545 545
 		//okay let's setup an "New" pages first (we'll return installed refs later)
546
-		$new_admin_screens = glob( EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR );
547
-		if ( $new_admin_screens ) {
548
-			foreach( $new_admin_screens as $admin_screen ) {
546
+		$new_admin_screens = glob(EE_CORE_CAF_ADMIN.'new/*', GLOB_ONLYDIR);
547
+		if ($new_admin_screens) {
548
+			foreach ($new_admin_screens as $admin_screen) {
549 549
 				// files and anything in the exclude array need not apply
550
-				if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) {
550
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
551 551
 					// these folders represent the different NEW EE admin pages
552
-					$installed_refs[ basename( $admin_screen ) ] = $admin_screen;
552
+					$installed_refs[basename($admin_screen)] = $admin_screen;
553 553
 					// set autoloaders for our admin page classes based on included path information
554
-					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $admin_screen );
554
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
555 555
 //					$this->_caf_autoloader[] = array(
556 556
 //						'dir' => 'new',
557 557
 //						'folder' => basename( $admin_screen )
@@ -561,18 +561,18 @@  discard block
 block discarded – undo
561 561
 		}
562 562
 
563 563
 		//let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
564
-		$extends = glob( EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR );
565
-		if ( $extends ) {
566
-			foreach( $extends as $extend ) {
567
-				if ( is_dir( $extend ) ) {
568
-					$extend_ref = basename( $extend );
564
+		$extends = glob(EE_CORE_CAF_ADMIN.'extend/*', GLOB_ONLYDIR);
565
+		if ($extends) {
566
+			foreach ($extends as $extend) {
567
+				if (is_dir($extend)) {
568
+					$extend_ref = basename($extend);
569 569
 					//now let's make sure there is a file that matches the expected format
570
-					$filename = str_replace(' ', '_', ucwords( str_replace('_', ' ', $extend_ref ) ) );
571
-					$filename = 'Extend_' . $filename . '_Admin_Page';
572
-					$this->_caffeinated_extends[$extend_ref]['path'] = str_replace( array( '\\', '/' ), DS, EE_CORE_CAF_ADMIN . 'extend' . DS . $extend_ref . DS . $filename . '.core.php' );
570
+					$filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $extend_ref)));
571
+					$filename = 'Extend_'.$filename.'_Admin_Page';
572
+					$this->_caffeinated_extends[$extend_ref]['path'] = str_replace(array('\\', '/'), DS, EE_CORE_CAF_ADMIN.'extend'.DS.$extend_ref.DS.$filename.'.core.php');
573 573
 					$this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename;
574 574
 					// set autoloaders for our admin page classes based on included path information
575
-					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $extend );
575
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
576 576
 //					$this->_caf_autoloader[] = array(
577 577
 //						'dir' => 'extend',
578 578
 //						'folder' => $extend_ref
@@ -583,22 +583,22 @@  discard block
 block discarded – undo
583 583
 
584 584
 		//let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
585 585
 		$ee_admin_hooks = array();
586
-		$hooks = glob( EE_CORE_CAF_ADMIN . 'hooks/*.class.php' );
587
-		if ( $hooks ) {
588
-			foreach ( $hooks as $hook ) {
589
-				if ( is_readable( $hook ) ) {
586
+		$hooks = glob(EE_CORE_CAF_ADMIN.'hooks/*.class.php');
587
+		if ($hooks) {
588
+			foreach ($hooks as $hook) {
589
+				if (is_readable($hook)) {
590 590
 					require_once $hook;
591
-					$classname = str_replace( EE_CORE_CAF_ADMIN . 'hooks/', '', $hook );
591
+					$classname = str_replace(EE_CORE_CAF_ADMIN.'hooks/', '', $hook);
592 592
 					$classname = str_replace('.class.php', '', $classname);
593
-					if ( class_exists( $classname ) ) {
594
-						$a = new ReflectionClass( $classname );
593
+					if (class_exists($classname)) {
594
+						$a = new ReflectionClass($classname);
595 595
 						$ee_admin_hooks[] = $a->newInstance();
596 596
 					}
597 597
 				}
598 598
 			}
599 599
 		}/**/
600 600
 
601
-		$ee_admin_hooks = apply_filters( 'FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks );
601
+		$ee_admin_hooks = apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
602 602
 
603 603
 		return $installed_refs;
604 604
 
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 	 * @param  EE_Admin_Page_Menu_Map $b being compared to
656 656
 	 * @return int    sort order
657 657
 	 */
658
-	private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) {
659
-		if ( $a->menu_order == $b->menu_order )
658
+	private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b) {
659
+		if ($a->menu_order == $b->menu_order)
660 660
 			return 0;
661 661
 		return ($a->menu_order < $b->menu_order) ? -1 : 1;
662 662
 	}
Please login to merge, or discard this patch.
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -237,8 +238,9 @@  discard block
 block discarded – undo
237 238
 		//first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
238 239
 		usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) );
239 240
 		foreach ( $this->_admin_menu_groups as $group ) {
240
-			if ( ! $group instanceof EE_Admin_Page_Menu_Group )
241
-				throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) );
241
+			if ( ! $group instanceof EE_Admin_Page_Menu_Group ) {
242
+							throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) );
243
+			}
242 244
 			$groups[$group->menu_slug] = $group;
243 245
 		}
244 246
 		return $groups;
@@ -494,8 +496,9 @@  discard block
 block discarded – undo
494 496
 		//let's sort the groups, make sure it's a valid group, add header (if to show).
495 497
 		foreach ( $pages_array as $group => $menu_maps ) {
496 498
 			//valid_group?
497
-			if ( ! array_key_exists( $group, $menu_groups ) )
498
-				continue;
499
+			if ( ! array_key_exists( $group, $menu_groups ) ) {
500
+							continue;
501
+			}
499 502
 
500 503
 			//sort pages.
501 504
 			usort( $menu_maps, array( $this, '_sort_menu_maps' ) );
@@ -510,8 +513,9 @@  discard block
 block discarded – undo
510 513
 
511 514
 		//now let's setup the _prepped_menu_maps property
512 515
 		foreach ( $menu_groups as $group => $group_objs ) {
513
-			if ( isset( $pages_array[$group] ) )
514
-				$this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] );
516
+			if ( isset( $pages_array[$group] ) ) {
517
+							$this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] );
518
+			}
515 519
 		}/**/
516 520
 
517 521
 	}
@@ -656,8 +660,9 @@  discard block
 block discarded – undo
656 660
 	 * @return int    sort order
657 661
 	 */
658 662
 	private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) {
659
-		if ( $a->menu_order == $b->menu_order )
660
-			return 0;
663
+		if ( $a->menu_order == $b->menu_order ) {
664
+					return 0;
665
+		}
661 666
 		return ($a->menu_order < $b->menu_order) ? -1 : 1;
662 667
 	}
663 668
 
Please login to merge, or discard this patch.
core/admin/EE_Help_Tour_final_stop.class.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			'action' => 'admin_option_settings',
61 61
 			'page' => 'espresso_general_settings'
62 62
 			);
63
-		return '<p>' . sprintf( __('That\'s it for the tour!  At any time you can restart a tour by clicking on this help dropdown and then clicking one of the Tour buttons.  There are help tours available on all Event Espresso Admin pages.  If you want to turn off help tours for all pages, %sgo here%s. All the best with your events!', 'event_espresso'), '<a href="' . EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php') ) . '">', '</a>' ) . '</p>';
63
+		return '<p>'.sprintf(__('That\'s it for the tour!  At any time you can restart a tour by clicking on this help dropdown and then clicking one of the Tour buttons.  There are help tours available on all Event Espresso Admin pages.  If you want to turn off help tours for all pages, %sgo here%s. All the best with your events!', 'event_espresso'), '<a href="'.EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')).'">', '</a>').'</p>';
64 64
 	}
65 65
 
66 66
 }
67 67
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,8 +6,9 @@
 block discarded – undo
6 6
  * @package Event Espresso
7 7
  * @subpackage messages
8 8
  */
9
-if (!defined('EVENT_ESPRESSO_VERSION') )
9
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
10 10
 	exit('NO direct script access allowed');
11
+}
11 12
 
12 13
 /**
13 14
  *
Please login to merge, or discard this patch.
core/admin/templates/about_admin_wrapper.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <div class="wrap espresso-admin about-wrap">
2 2
 
3 3
 	<h1><?php  echo $admin_page_title; ?></h1>
4
-	<div class="about-text"><?php echo !empty($admin_page_subtitle) ? $admin_page_subtitle : ''; ?></div>
5
-	<div class="ee-badge"><img class="" src=" <?php echo EE_GLOBAL_ASSETS_URL; ?>images/event-espresso-cup-90x90.png" width="90" height="90" alt="<?php printf( esc_attr__( '%s Logo', 'event_espresso' ), 'Event Espresso' ); ?>"/><br /><?php printf( __('Version %s', 'event_espresso' ),  EVENT_ESPRESSO_VERSION ); ?></div>
4
+	<div class="about-text"><?php echo ! empty($admin_page_subtitle) ? $admin_page_subtitle : ''; ?></div>
5
+	<div class="ee-badge"><img class="" src=" <?php echo EE_GLOBAL_ASSETS_URL; ?>images/event-espresso-cup-90x90.png" width="90" height="90" alt="<?php printf(esc_attr__('%s Logo', 'event_espresso'), 'Event Espresso'); ?>"/><br /><?php printf(__('Version %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); ?></div>
6 6
 
7 7
 	<?php echo $nav_tabs; ?>
8 8
 
9 9
 
10 10
 <?php
11
-	do_action( 'AHEE__admin_wrapper__template__before_about_admin_page_content' );
11
+	do_action('AHEE__admin_wrapper__template__before_about_admin_page_content');
12 12
 	echo $about_admin_page_content;
13
-	do_action( 'AHEE__admin_wrapper__template__after_about_admin_page_content' );
13
+	do_action('AHEE__admin_wrapper__template__after_about_admin_page_content');
14 14
 ?>
15 15
 
16 16
 </div>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_metabox_column_wrapper.template.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
 
11 11
 		<?php
12 12
 		//let's loop through the columns
13
-		 for ( $i = 1; $i <= $num_columns; $i++ ) {
14
-		 	$metaref = ( $i === 1 ) ? 'normal' : 'side';
15
-		 	$metaref = ( $i > 2 ) ? 'column'.$i : $metaref;
13
+		 for ($i = 1; $i <= $num_columns; $i++) {
14
+		 	$metaref = ($i === 1) ? 'normal' : 'side';
15
+		 	$metaref = ($i > 2) ? 'column'.$i : $metaref;
16 16
 		 ?>
17 17
 
18 18
 			<div id='postbox-container-<?php echo $i; ?>' class='postbox-container'>
19
-				<?php do_meta_boxes( $current_page, $metaref, NULL ); ?>
19
+				<?php do_meta_boxes($current_page, $metaref, NULL); ?>
20 20
 			</div>
21 21
 		<?php }// end column loop ?>
22 22
 	</div> <!-- post-body -->
Please login to merge, or discard this patch.
core/admin/templates/admin_details_publish_metabox.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( $publish_box_extra_content ) : ?>
1
+<?php if ($publish_box_extra_content) : ?>
2 2
 <div id="minor-publishing">
3 3
 <?php echo $publish_box_extra_content; ?>
4 4
 </div>
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	
14 14
 	<div id="espresso_major_buttons_wrapper">
15 15
 	
16
-		<?php if ( $publish_delete_link ) : ?>
16
+		<?php if ($publish_delete_link) : ?>
17 17
 		<div id="delete-action">
18 18
 			<?php echo $publish_delete_link; ?>
19 19
 		</div>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_wrapper_no_sidebar.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
 			
14 14
 			
15 15
 			<div id="postbox-container-2" class="postbox-container">
16
-				<?php do_meta_boxes( $current_page, 'normal', NULL ); ?>
17
-				<?php do_meta_boxes( $current_page, 'advanced', NULL ); ?>
16
+				<?php do_meta_boxes($current_page, 'normal', NULL); ?>
17
+				<?php do_meta_boxes($current_page, 'advanced', NULL); ?>
18 18
 			</div>
19 19
 			<!-- postbox-container-2 -->
20 20
 			
Please login to merge, or discard this patch.
admin/templates/admin_general_metabox_contents_espresso_links.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <div class="padding">
2 2
 	   	<ul class="infolinks">
3 3
 	   		<li>
4
-	   			<?php echo '<a href="http://eventespresso.com/wiki/installation/" target="_blank">'.__('Installation', 'event_espresso') . '</a>  &amp; <a href="http://eventespresso.com/wiki/setting-up-event-espresso/" target="_blank">' . __('Usage Guide').'</a>'; ?>
4
+	   			<?php echo '<a href="http://eventespresso.com/wiki/installation/" target="_blank">'.__('Installation', 'event_espresso').'</a>  &amp; <a href="http://eventespresso.com/wiki/setting-up-event-espresso/" target="_blank">'.__('Usage Guide').'</a>'; ?>
5 5
 	   		</li>
6 6
 	   		<li>
7 7
 		   		<a href="http://eventespresso.com/wiki/put-custom-templates/" target="_blank">
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	   			</a>
31 31
 	   		</li>
32 32
 	   		<li>
33
-	   			<?php echo '<a href="http://eventespresso.com/pricing/" target="_blank">'.__('Plugins', 'event_espresso'). '</a> &amp; <a href="http://eventespresso.com/add-ons/" target="_blank">' .__('Add-ons', 'event_espresso').'</a>'; ?><br />
33
+	   			<?php echo '<a href="http://eventespresso.com/pricing/" target="_blank">'.__('Plugins', 'event_espresso').'</a> &amp; <a href="http://eventespresso.com/add-ons/" target="_blank">'.__('Add-ons', 'event_espresso').'</a>'; ?><br />
34 34
 	   			<br />
35 35
 	   			<ol>
36 36
 	   				<li>
Please login to merge, or discard this patch.