0
|
1 |
<?php |
|
2 |
/** |
|
3 |
* WordPress Administration Bootstrap |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
|
|
9 |
/** |
|
10 |
* In WordPress Administration Screens |
|
11 |
* |
|
12 |
* @since 2.3.2 |
|
13 |
*/ |
5
|
14 |
if ( ! defined( 'WP_ADMIN' ) ) { |
|
15 |
define( 'WP_ADMIN', true ); |
|
16 |
} |
0
|
17 |
|
|
18 |
if ( ! defined('WP_NETWORK_ADMIN') ) |
|
19 |
define('WP_NETWORK_ADMIN', false); |
|
20 |
|
|
21 |
if ( ! defined('WP_USER_ADMIN') ) |
|
22 |
define('WP_USER_ADMIN', false); |
|
23 |
|
|
24 |
if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
|
25 |
define('WP_BLOG_ADMIN', true); |
|
26 |
} |
|
27 |
|
|
28 |
if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) |
|
29 |
define('WP_LOAD_IMPORTERS', true); |
|
30 |
|
|
31 |
require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); |
|
32 |
|
|
33 |
nocache_headers(); |
|
34 |
|
|
35 |
if ( get_option('db_upgraded') ) { |
|
36 |
flush_rewrite_rules(); |
|
37 |
update_option( 'db_upgraded', false ); |
|
38 |
|
|
39 |
/** |
|
40 |
* Fires on the next page load after a successful DB upgrade. |
|
41 |
* |
|
42 |
* @since 2.8.0 |
|
43 |
*/ |
|
44 |
do_action( 'after_db_upgrade' ); |
|
45 |
} elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) { |
|
46 |
if ( !is_multisite() ) { |
|
47 |
wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
|
48 |
exit; |
|
49 |
|
|
50 |
/** |
|
51 |
* Filter whether to attempt to perform the multisite DB upgrade routine. |
|
52 |
* |
|
53 |
* In single site, the user would be redirected to wp-admin/upgrade.php. |
5
|
54 |
* In multisite, the DB upgrade routine is automatically fired, but only |
|
55 |
* when this filter returns true. |
0
|
56 |
* |
|
57 |
* If the network is 50 sites or less, it will run every time. Otherwise, |
|
58 |
* it will throttle itself to reduce load. |
|
59 |
* |
|
60 |
* @since 3.0.0 |
|
61 |
* |
|
62 |
* @param bool true Whether to perform the Multisite upgrade routine. Default true. |
|
63 |
*/ |
|
64 |
} elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
|
65 |
$c = get_blog_count(); |
5
|
66 |
|
|
67 |
/* |
|
68 |
* If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
|
69 |
* attempt to do no more than threshold value, with some +/- allowed. |
|
70 |
*/ |
0
|
71 |
if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
|
72 |
require_once( ABSPATH . WPINC . '/http.php' ); |
|
73 |
$response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
5
|
74 |
/** This action is documented in wp-admin/network/upgrade.php */ |
0
|
75 |
do_action( 'after_mu_upgrade', $response ); |
|
76 |
unset($response); |
|
77 |
} |
|
78 |
unset($c); |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
|
83 |
|
|
84 |
auth_redirect(); |
|
85 |
|
|
86 |
// Schedule trash collection |
|
87 |
if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') ) |
|
88 |
wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
|
89 |
|
|
90 |
set_screen_options(); |
|
91 |
|
|
92 |
$date_format = get_option('date_format'); |
|
93 |
$time_format = get_option('time_format'); |
|
94 |
|
|
95 |
wp_enqueue_script( 'common' ); |
|
96 |
|
5
|
97 |
// $pagenow is set in vars.php |
|
98 |
// $wp_importers is sometimes set in wp-admin/includes/import.php |
|
99 |
// |
|
100 |
// The remaining variables are imported as globals elsewhere, |
|
101 |
// declared as globals here |
|
102 |
global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow; |
|
103 |
|
|
104 |
$page_hook = null; |
|
105 |
|
0
|
106 |
$editing = false; |
|
107 |
|
|
108 |
if ( isset($_GET['page']) ) { |
|
109 |
$plugin_page = wp_unslash( $_GET['page'] ); |
|
110 |
$plugin_page = plugin_basename($plugin_page); |
|
111 |
} |
|
112 |
|
|
113 |
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
114 |
$typenow = $_REQUEST['post_type']; |
|
115 |
else |
|
116 |
$typenow = ''; |
|
117 |
|
|
118 |
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) |
|
119 |
$taxnow = $_REQUEST['taxonomy']; |
|
120 |
else |
|
121 |
$taxnow = ''; |
|
122 |
|
|
123 |
if ( WP_NETWORK_ADMIN ) |
|
124 |
require(ABSPATH . 'wp-admin/network/menu.php'); |
|
125 |
elseif ( WP_USER_ADMIN ) |
|
126 |
require(ABSPATH . 'wp-admin/user/menu.php'); |
|
127 |
else |
|
128 |
require(ABSPATH . 'wp-admin/menu.php'); |
|
129 |
|
|
130 |
if ( current_user_can( 'manage_options' ) ) { |
|
131 |
/** |
|
132 |
* Filter the maximum memory limit available for administration screens. |
|
133 |
* |
|
134 |
* This only applies to administrators, who may require more memory for tasks like updates. |
|
135 |
* Memory limits when processing images (uploaded or edited by users of any role) are |
|
136 |
* handled separately. |
|
137 |
* |
|
138 |
* The WP_MAX_MEMORY_LIMIT constant specifically defines the maximum memory limit available |
|
139 |
* when in the administration back-end. The default is 256M, or 256 megabytes of memory. |
|
140 |
* |
|
141 |
* @since 3.0.0 |
|
142 |
* |
|
143 |
* @param string 'WP_MAX_MEMORY_LIMIT' The maximum WordPress memory limit. Default 256M. |
|
144 |
*/ |
|
145 |
@ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Fires as an admin screen or script is being initialized. |
|
150 |
* |
|
151 |
* Note, this does not just run on user-facing admin screens. |
|
152 |
* It runs on admin-ajax.php and admin-post.php as well. |
|
153 |
* |
|
154 |
* This is roughly analgous to the more general 'init' hook, which fires earlier. |
|
155 |
* |
|
156 |
* @since 2.5.0 |
|
157 |
*/ |
|
158 |
do_action( 'admin_init' ); |
|
159 |
|
|
160 |
if ( isset($plugin_page) ) { |
|
161 |
if ( !empty($typenow) ) |
|
162 |
$the_parent = $pagenow . '?post_type=' . $typenow; |
|
163 |
else |
|
164 |
$the_parent = $pagenow; |
|
165 |
if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
|
166 |
$page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
5
|
167 |
|
|
168 |
// Backwards compatibility for plugins using add_management_page(). |
0
|
169 |
if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
|
170 |
// There could be plugin specific params on the URL, so we need the whole query string |
|
171 |
if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
|
172 |
$query_string = $_SERVER[ 'QUERY_STRING' ]; |
|
173 |
else |
|
174 |
$query_string = 'page=' . $plugin_page; |
|
175 |
wp_redirect( admin_url('tools.php?' . $query_string) ); |
|
176 |
exit; |
|
177 |
} |
|
178 |
} |
|
179 |
unset($the_parent); |
|
180 |
} |
|
181 |
|
|
182 |
$hook_suffix = ''; |
5
|
183 |
if ( isset( $page_hook ) ) { |
0
|
184 |
$hook_suffix = $page_hook; |
5
|
185 |
} elseif ( isset( $plugin_page ) ) { |
0
|
186 |
$hook_suffix = $plugin_page; |
5
|
187 |
} elseif ( isset( $pagenow ) ) { |
0
|
188 |
$hook_suffix = $pagenow; |
5
|
189 |
} |
0
|
190 |
|
|
191 |
set_current_screen(); |
|
192 |
|
|
193 |
// Handle plugin admin pages. |
|
194 |
if ( isset($plugin_page) ) { |
|
195 |
if ( $page_hook ) { |
|
196 |
/** |
|
197 |
* Fires before a particular screen is loaded. |
|
198 |
* |
|
199 |
* The load-* hook fires in a number of contexts. This hook is for plugin screens |
|
200 |
* where a callback is provided when the screen is registered. |
|
201 |
* |
5
|
202 |
* The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin |
0
|
203 |
* page information including: |
|
204 |
* 1. The page type. If the plugin page is registered as a submenu page, such as for |
|
205 |
* Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. |
|
206 |
* 2. A separator of '_page_'. |
|
207 |
* 3. The plugin basename minus the file extension. |
|
208 |
* |
5
|
209 |
* Together, the three parts form the `$page_hook`. Citing the example above, |
0
|
210 |
* the hook name used would be 'load-settings_page_pluginbasename'. |
|
211 |
* |
|
212 |
* @see get_plugin_page_hook() |
|
213 |
* |
|
214 |
* @since 2.1.0 |
|
215 |
*/ |
|
216 |
do_action( 'load-' . $page_hook ); |
|
217 |
if (! isset($_GET['noheader'])) |
|
218 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
219 |
|
|
220 |
/** |
|
221 |
* Used to call the registered callback for a plugin screen. |
|
222 |
* |
5
|
223 |
* @ignore |
0
|
224 |
* @since 1.5.0 |
|
225 |
*/ |
|
226 |
do_action( $page_hook ); |
|
227 |
} else { |
|
228 |
if ( validate_file($plugin_page) ) |
|
229 |
wp_die(__('Invalid plugin page')); |
|
230 |
|
|
231 |
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") ) ) |
|
232 |
wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
|
233 |
|
|
234 |
/** |
|
235 |
* Fires before a particular screen is loaded. |
|
236 |
* |
|
237 |
* The load-* hook fires in a number of contexts. This hook is for plugin screens |
|
238 |
* where the file to load is directly included, rather than the use of a function. |
|
239 |
* |
5
|
240 |
* The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename. |
0
|
241 |
* |
|
242 |
* @see plugin_basename() |
|
243 |
* |
|
244 |
* @since 1.5.0 |
|
245 |
*/ |
|
246 |
do_action( 'load-' . $plugin_page ); |
|
247 |
|
|
248 |
if ( !isset($_GET['noheader'])) |
|
249 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
250 |
|
|
251 |
if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) |
|
252 |
include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
|
253 |
else |
|
254 |
include(WP_PLUGIN_DIR . "/$plugin_page"); |
|
255 |
} |
|
256 |
|
|
257 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
258 |
|
|
259 |
exit(); |
5
|
260 |
} elseif ( isset( $_GET['import'] ) ) { |
0
|
261 |
|
|
262 |
$importer = $_GET['import']; |
|
263 |
|
|
264 |
if ( ! current_user_can('import') ) |
|
265 |
wp_die(__('You are not allowed to import.')); |
|
266 |
|
|
267 |
if ( validate_file($importer) ) { |
|
268 |
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
|
269 |
exit; |
|
270 |
} |
|
271 |
|
|
272 |
if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]) ) { |
|
273 |
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
|
274 |
exit; |
|
275 |
} |
|
276 |
|
|
277 |
/** |
|
278 |
* Fires before an importer screen is loaded. |
|
279 |
* |
5
|
280 |
* The dynamic portion of the hook name, `$importer`, refers to the importer slug. |
0
|
281 |
* |
|
282 |
* @since 3.5.0 |
|
283 |
*/ |
|
284 |
do_action( 'load-importer-' . $importer ); |
|
285 |
|
|
286 |
$parent_file = 'tools.php'; |
|
287 |
$submenu_file = 'import.php'; |
|
288 |
$title = __('Import'); |
|
289 |
|
|
290 |
if (! isset($_GET['noheader'])) |
|
291 |
require_once(ABSPATH . 'wp-admin/admin-header.php'); |
|
292 |
|
|
293 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
294 |
|
|
295 |
define('WP_IMPORTING', true); |
|
296 |
|
|
297 |
/** |
|
298 |
* Whether to filter imported data through kses on import. |
|
299 |
* |
|
300 |
* Multisite uses this hook to filter all data through kses by default, |
|
301 |
* as a super administrator may be assisting an untrusted user. |
|
302 |
* |
|
303 |
* @since 3.1.0 |
|
304 |
* |
|
305 |
* @param bool false Whether to force data to be filtered through kses. Default false. |
|
306 |
*/ |
5
|
307 |
if ( apply_filters( 'force_filtered_html_on_import', false ) ) { |
0
|
308 |
kses_init_filters(); // Always filter imported data with kses on multisite. |
5
|
309 |
} |
0
|
310 |
|
|
311 |
call_user_func($wp_importers[$importer][2]); |
|
312 |
|
|
313 |
include(ABSPATH . 'wp-admin/admin-footer.php'); |
|
314 |
|
|
315 |
// Make sure rules are flushed |
|
316 |
flush_rewrite_rules(false); |
|
317 |
|
|
318 |
exit(); |
|
319 |
} else { |
|
320 |
/** |
|
321 |
* Fires before a particular screen is loaded. |
|
322 |
* |
|
323 |
* The load-* hook fires in a number of contexts. This hook is for core screens. |
|
324 |
* |
5
|
325 |
* The dynamic portion of the hook name, `$pagenow`, is a global variable |
0
|
326 |
* referring to the filename of the current page, such as 'admin.php', |
5
|
327 |
* 'post-new.php' etc. A complete hook for the latter would be |
|
328 |
* 'load-post-new.php'. |
0
|
329 |
* |
|
330 |
* @since 2.1.0 |
|
331 |
*/ |
|
332 |
do_action( 'load-' . $pagenow ); |
5
|
333 |
|
|
334 |
/* |
|
335 |
* The following hooks are fired to ensure backward compatibility. |
|
336 |
* In all other cases, 'load-' . $pagenow should be used instead. |
|
337 |
*/ |
0
|
338 |
if ( $typenow == 'page' ) { |
|
339 |
if ( $pagenow == 'post-new.php' ) |
|
340 |
do_action( 'load-page-new.php' ); |
|
341 |
elseif ( $pagenow == 'post.php' ) |
|
342 |
do_action( 'load-page.php' ); |
|
343 |
} elseif ( $pagenow == 'edit-tags.php' ) { |
|
344 |
if ( $taxnow == 'category' ) |
|
345 |
do_action( 'load-categories.php' ); |
|
346 |
elseif ( $taxnow == 'link_category' ) |
|
347 |
do_action( 'load-edit-link-categories.php' ); |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
if ( ! empty( $_REQUEST['action'] ) ) { |
|
352 |
/** |
|
353 |
* Fires when an 'action' request variable is sent. |
|
354 |
* |
5
|
355 |
* The dynamic portion of the hook name, `$_REQUEST['action']`, |
|
356 |
* refers to the action derived from the `GET` or `POST` request. |
0
|
357 |
* |
|
358 |
* @since 2.6.0 |
|
359 |
*/ |
|
360 |
do_action( 'admin_action_' . $_REQUEST['action'] ); |
|
361 |
} |