root/branches/2.2/wp-admin/admin.php

Revision 4887, 2.6 kB (checked in by markjaquith, 2 years ago)

Fewer clicks and better user experience for upgrades. fixes #2447

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2 if ( defined('ABSPATH') )
3     require_once( ABSPATH . 'wp-config.php');
4 else
5     require_once('../wp-config.php');
6
7 if ( get_option('db_version') != $wp_db_version ) {
8     wp_redirect(get_option('siteurl') . '/wp-admin/upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])));
9     exit;
10 }
11
12 require_once(ABSPATH . 'wp-admin/admin-functions.php');
13 require_once(ABSPATH . 'wp-admin/admin-db.php');
14 require_once(ABSPATH . WPINC . '/registration.php');
15
16 auth_redirect();
17
18 nocache_headers();
19
20 update_category_cache();
21
22 wp_get_current_user();
23
24 $posts_per_page = get_option('posts_per_page');
25 $what_to_show = get_option('what_to_show');
26 $date_format = get_option('date_format');
27 $time_format = get_option('time_format');
28
29 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
30
31 wp_enqueue_script( 'fat' );
32
33 $editing = false;
34
35 if (isset($_GET['page'])) {
36     $plugin_page = stripslashes($_GET['page']);
37     $plugin_page = plugin_basename($plugin_page);
38 }
39
40 require(ABSPATH . '/wp-admin/menu.php');
41
42 // Handle plugin admin pages.
43 if (isset($plugin_page)) {
44     $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
45
46     if ( $page_hook ) {
47         do_action('load-' . $page_hook);
48         if (! isset($_GET['noheader']))
49             require_once(ABSPATH . '/wp-admin/admin-header.php');
50
51         do_action($page_hook);
52     } else {
53         if ( validate_file($plugin_page) ) {
54             wp_die(__('Invalid plugin page'));
55         }
56
57         if (! file_exists(ABSPATH . PLUGINDIR . "/$plugin_page"))
58             wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
59
60         do_action('load-' . $plugin_page);
61
62         if (! isset($_GET['noheader']))
63             require_once(ABSPATH . '/wp-admin/admin-header.php');
64
65         include(ABSPATH . PLUGINDIR . "/$plugin_page");
66     }
67
68     include(ABSPATH . 'wp-admin/admin-footer.php');
69
70     exit();
71 } else if (isset($_GET['import'])) {
72
73     $importer = $_GET['import'];
74
75     if ( ! current_user_can('import') )
76         wp_die(__('You are not allowed to import.'));
77
78     if ( validate_file($importer) ) {
79         wp_die(__('Invalid importer.'));
80     }
81
82     if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
83         wp_die(__('Cannot load importer.'));
84
85     include(ABSPATH . "wp-admin/import/$importer.php");
86
87     $parent_file = 'edit.php';
88     $submenu_file = 'import.php';
89     $title = __('Import');
90
91     if (! isset($_GET['noheader']))
92         require_once(ABSPATH . 'wp-admin/admin-header.php');
93
94     require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
95
96     define('WP_IMPORTING', true);
97
98     call_user_func($wp_importers[$importer][2]);
99
100     include(ABSPATH . 'wp-admin/admin-footer.php');
101
102     exit();
103 } else {
104     do_action("load-$pagenow");
105 }
106
107 ?>
108
Note: See TracBrowser for help on using the browser.