+/**
+ * Fires as an admin screen or script is being initialized.
+ *
+ * Note, this does not just run on user-facing admin screens.
+ * It runs on admin-ajax.php and admin-post.php as well.
+ *
+ * This is roughly analgous to the more general 'init' hook, which fires earlier.
+ *
+ * @since 2.5.0
+ */
+do_action( 'admin_init' );
+
+if ( isset($plugin_page) ) {
+ if ( !empty($typenow) )
+ $the_parent = $pagenow . '?post_type=' . $typenow;
+ else
+ $the_parent = $pagenow;
+ if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
+ $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
+ // backwards compatibility for plugins using add_management_page
+ if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
+ // There could be plugin specific params on the URL, so we need the whole query string
+ if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
+ $query_string = $_SERVER[ 'QUERY_STRING' ];
+ else
+ $query_string = 'page=' . $plugin_page;
+ wp_redirect( admin_url('tools.php?' . $query_string) );
+ exit;
+ }
+ }
+ unset($the_parent);
+}
+
+$hook_suffix = '';
+if ( isset($page_hook) )
+ $hook_suffix = $page_hook;
+else if ( isset($plugin_page) )
+ $hook_suffix = $plugin_page;
+else if ( isset($pagenow) )
+ $hook_suffix = $pagenow;
+
+set_current_screen();
+
+// Handle plugin admin pages.
+if ( isset($plugin_page) ) {