5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 /** |
9 /** |
10 * In WordPress Administration Panels |
10 * In WordPress Administration Screens |
11 * |
11 * |
12 * @since unknown |
12 * @since 2.3.2 |
13 */ |
13 */ |
14 if ( !defined('WP_ADMIN') ) |
14 if ( ! defined('WP_ADMIN') ) |
15 define('WP_ADMIN', TRUE); |
15 define('WP_ADMIN', true); |
16 |
16 |
17 if ( defined('ABSPATH') ) |
17 if ( ! defined('WP_NETWORK_ADMIN') ) |
18 require_once(ABSPATH . 'wp-load.php'); |
18 define('WP_NETWORK_ADMIN', false); |
19 else |
19 |
20 require_once('../wp-load.php'); |
20 if ( ! defined('WP_USER_ADMIN') ) |
|
21 define('WP_USER_ADMIN', false); |
|
22 |
|
23 if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
|
24 define('WP_BLOG_ADMIN', true); |
|
25 } |
|
26 |
|
27 if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) |
|
28 define('WP_LOAD_IMPORTERS', true); |
|
29 |
|
30 require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); |
21 |
31 |
22 if ( get_option('db_upgraded') ) { |
32 if ( get_option('db_upgraded') ) { |
23 $wp_rewrite->flush_rules(); |
33 flush_rewrite_rules(); |
24 update_option( 'db_upgraded', false ); |
34 update_option( 'db_upgraded', false ); |
25 |
35 |
26 /** |
36 /** |
27 * Runs on the next page load after successful upgrade |
37 * Runs on the next page load after successful upgrade |
28 * |
38 * |
29 * @since 2.8 |
39 * @since 2.8 |
30 */ |
40 */ |
31 do_action('after_db_upgrade'); |
41 do_action('after_db_upgrade'); |
32 } elseif ( get_option('db_version') != $wp_db_version ) { |
42 } elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) { |
33 wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])))); |
43 if ( !is_multisite() ) { |
34 exit; |
44 wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI'])))); |
|
45 exit; |
|
46 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
|
47 /** |
|
48 * On really small MU installs run the upgrader every time, |
|
49 * else run it less often to reduce load. |
|
50 * |
|
51 * @since 2.8.4b |
|
52 */ |
|
53 $c = get_blog_count(); |
|
54 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
|
55 require_once( ABSPATH . WPINC . '/http.php' ); |
|
56 $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
|
57 do_action( 'after_mu_upgrade', $response ); |
|
58 unset($response); |
|
59 } |
|
60 unset($c); |
|
61 } |
35 } |
62 } |
36 |
63 |
37 require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
64 require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
38 |
65 |
39 auth_redirect(); |
66 auth_redirect(); |
40 |
67 |
41 nocache_headers(); |
68 nocache_headers(); |
42 |
|
43 update_category_cache(); |
|
44 |
69 |
45 // Schedule trash collection |
70 // Schedule trash collection |
46 if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) |
71 if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) |
47 wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
72 wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
48 |
73 |
49 set_screen_options(); |
74 set_screen_options(); |
50 |
75 |
51 $posts_per_page = get_option('posts_per_page'); |
|
52 $date_format = get_option('date_format'); |
76 $date_format = get_option('date_format'); |
53 $time_format = get_option('time_format'); |
77 $time_format = get_option('time_format'); |
54 |
78 |
55 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'text', 'trackback', 'pingback')); |
79 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'text', 'trackback', 'pingback')); |
56 |
80 |
57 wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7')); |
|
58 wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF')); |
|
59 |
|
60 wp_enqueue_script( 'common' ); |
81 wp_enqueue_script( 'common' ); |
61 wp_enqueue_script( 'jquery-color' ); |
82 wp_enqueue_script( 'jquery-color' ); |
62 |
83 |
63 $editing = false; |
84 $editing = false; |
64 |
85 |
65 if (isset($_GET['page'])) { |
86 if ( isset($_GET['page']) ) { |
66 $plugin_page = stripslashes($_GET['page']); |
87 $plugin_page = stripslashes($_GET['page']); |
67 $plugin_page = plugin_basename($plugin_page); |
88 $plugin_page = plugin_basename($plugin_page); |
68 } |
89 } |
69 |
90 |
70 require(ABSPATH . 'wp-admin/menu.php'); |
91 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
92 $typenow = $_REQUEST['post_type']; |
|
93 else |
|
94 $typenow = ''; |
|
95 |
|
96 if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) |
|
97 $taxnow = $_REQUEST['taxonomy']; |
|
98 else |
|
99 $taxnow = ''; |
|
100 |
|
101 if ( WP_NETWORK_ADMIN ) |
|
102 require(ABSPATH . 'wp-admin/network/menu.php'); |
|
103 elseif ( WP_USER_ADMIN ) |
|
104 require(ABSPATH . 'wp-admin/user/menu.php'); |
|
105 else |
|
106 require(ABSPATH . 'wp-admin/menu.php'); |
|
107 |
|
108 if ( current_user_can( 'manage_options' ) ) |
|
109 @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
71 |
110 |
72 do_action('admin_init'); |
111 do_action('admin_init'); |
73 |
112 |
74 // Handle plugin admin pages. |
113 if ( isset($plugin_page) ) { |
75 if (isset($plugin_page)) { |
114 if ( !empty($typenow) ) |
76 if( ! $page_hook = get_plugin_page_hook($plugin_page, $pagenow) ) { |
115 $the_parent = $pagenow . '?post_type=' . $typenow; |
|
116 else |
|
117 $the_parent = $pagenow; |
|
118 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
77 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
119 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
78 // backwards compatibility for plugins using add_management_page |
120 // backwards compatibility for plugins using add_management_page |
79 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
121 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
80 // There could be plugin specific params on the URL, so we need the whole query string |
122 // There could be plugin specific params on the URL, so we need the whole query string |
81 if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
123 if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
82 $query_string = $_SERVER[ 'QUERY_STRING' ]; |
124 $query_string = $_SERVER[ 'QUERY_STRING' ]; |
83 else |
125 else |
84 $query_string = 'page=' . $plugin_page; |
126 $query_string = 'page=' . $plugin_page; |
85 wp_redirect( 'tools.php?' . $query_string ); |
127 wp_redirect( admin_url('tools.php?' . $query_string) ); |
86 exit; |
128 exit; |
87 } |
129 } |
88 } |
130 } |
89 |
131 unset($the_parent); |
|
132 } |
|
133 |
|
134 $hook_suffix = ''; |
|
135 if ( isset($page_hook) ) |
|
136 $hook_suffix = $page_hook; |
|
137 else if ( isset($plugin_page) ) |
|
138 $hook_suffix = $plugin_page; |
|
139 else if ( isset($pagenow) ) |
|
140 $hook_suffix = $pagenow; |
|
141 |
|
142 set_current_screen(); |
|
143 |
|
144 // Handle plugin admin pages. |
|
145 if ( isset($plugin_page) ) { |
90 if ( $page_hook ) { |
146 if ( $page_hook ) { |
91 do_action('load-' . $page_hook); |
147 do_action('load-' . $page_hook); |
92 if (! isset($_GET['noheader'])) |
148 if (! isset($_GET['noheader'])) |
93 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
149 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
94 |
150 |
95 do_action($page_hook); |
151 do_action($page_hook); |
96 } else { |
152 } else { |
97 if ( validate_file($plugin_page) ) { |
153 if ( validate_file($plugin_page) ) |
98 wp_die(__('Invalid plugin page')); |
154 wp_die(__('Invalid plugin page')); |
99 } |
155 |
100 |
156 if ( !( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) && !( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") && is_file(WPMU_PLUGIN_DIR . "/$plugin_page") ) ) |
101 if (! ( file_exists(WP_PLUGIN_DIR . "/$plugin_page") && is_file(WP_PLUGIN_DIR . "/$plugin_page") ) ) |
|
102 wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
157 wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
103 |
158 |
104 do_action('load-' . $plugin_page); |
159 do_action('load-' . $plugin_page); |
105 |
160 |
106 if (! isset($_GET['noheader'])) |
161 if ( !isset($_GET['noheader'])) |
107 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
162 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
108 |
163 |
109 include(WP_PLUGIN_DIR . "/$plugin_page"); |
164 if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) |
|
165 include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
|
166 else |
|
167 include(WP_PLUGIN_DIR . "/$plugin_page"); |
110 } |
168 } |
111 |
169 |
112 include(ABSPATH . 'wp-admin/admin-footer.php'); |
170 include(ABSPATH . 'wp-admin/admin-footer.php'); |
113 |
171 |
114 exit(); |
172 exit(); |