9 /** |
9 /** |
10 * In WordPress Administration Screens |
10 * In WordPress Administration Screens |
11 * |
11 * |
12 * @since 2.3.2 |
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 |
17 if ( ! defined('WP_NETWORK_ADMIN') ) |
18 if ( ! defined('WP_NETWORK_ADMIN') ) |
18 define('WP_NETWORK_ADMIN', false); |
19 define('WP_NETWORK_ADMIN', false); |
19 |
20 |
20 if ( ! defined('WP_USER_ADMIN') ) |
21 if ( ! defined('WP_USER_ADMIN') ) |
48 |
49 |
49 /** |
50 /** |
50 * Filter whether to attempt to perform the multisite DB upgrade routine. |
51 * Filter whether to attempt to perform the multisite DB upgrade routine. |
51 * |
52 * |
52 * In single site, the user would be redirected to wp-admin/upgrade.php. |
53 * In single site, the user would be redirected to wp-admin/upgrade.php. |
53 * In multisite, it is automatically fired, but only when this filter |
54 * In multisite, the DB upgrade routine is automatically fired, but only |
54 * returns true. |
55 * when this filter returns true. |
55 * |
56 * |
56 * If the network is 50 sites or less, it will run every time. Otherwise, |
57 * If the network is 50 sites or less, it will run every time. Otherwise, |
57 * it will throttle itself to reduce load. |
58 * it will throttle itself to reduce load. |
58 * |
59 * |
59 * @since 3.0.0 |
60 * @since 3.0.0 |
60 * |
61 * |
61 * @param bool true Whether to perform the Multisite upgrade routine. Default true. |
62 * @param bool true Whether to perform the Multisite upgrade routine. Default true. |
62 */ |
63 */ |
63 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
64 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
64 $c = get_blog_count(); |
65 $c = get_blog_count(); |
65 // If 50 or fewer sites, run every time. Else, run "about ten percent" of the time. Shh, don't check that math. |
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 */ |
66 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
71 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
67 require_once( ABSPATH . WPINC . '/http.php' ); |
72 require_once( ABSPATH . WPINC . '/http.php' ); |
68 $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
73 $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
69 /** |
74 /** This action is documented in wp-admin/network/upgrade.php */ |
70 * Fires after the multisite DB upgrade is complete. |
|
71 * |
|
72 * @since 3.0.0 |
|
73 * |
|
74 * @param array|WP_Error $response The upgrade response array or WP_Error on failure. |
|
75 */ |
|
76 do_action( 'after_mu_upgrade', $response ); |
75 do_action( 'after_mu_upgrade', $response ); |
77 unset($response); |
76 unset($response); |
78 } |
77 } |
79 unset($c); |
78 unset($c); |
80 } |
79 } |
92 |
91 |
93 $date_format = get_option('date_format'); |
92 $date_format = get_option('date_format'); |
94 $time_format = get_option('time_format'); |
93 $time_format = get_option('time_format'); |
95 |
94 |
96 wp_enqueue_script( 'common' ); |
95 wp_enqueue_script( 'common' ); |
|
96 |
|
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; |
97 |
105 |
98 $editing = false; |
106 $editing = false; |
99 |
107 |
100 if ( isset($_GET['page']) ) { |
108 if ( isset($_GET['page']) ) { |
101 $plugin_page = wp_unslash( $_GET['page'] ); |
109 $plugin_page = wp_unslash( $_GET['page'] ); |
154 $the_parent = $pagenow . '?post_type=' . $typenow; |
162 $the_parent = $pagenow . '?post_type=' . $typenow; |
155 else |
163 else |
156 $the_parent = $pagenow; |
164 $the_parent = $pagenow; |
157 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
165 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
158 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
166 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
159 // backwards compatibility for plugins using add_management_page |
167 |
|
168 // Backwards compatibility for plugins using add_management_page(). |
160 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
169 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
161 // There could be plugin specific params on the URL, so we need the whole query string |
170 // There could be plugin specific params on the URL, so we need the whole query string |
162 if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
171 if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
163 $query_string = $_SERVER[ 'QUERY_STRING' ]; |
172 $query_string = $_SERVER[ 'QUERY_STRING' ]; |
164 else |
173 else |
169 } |
178 } |
170 unset($the_parent); |
179 unset($the_parent); |
171 } |
180 } |
172 |
181 |
173 $hook_suffix = ''; |
182 $hook_suffix = ''; |
174 if ( isset($page_hook) ) |
183 if ( isset( $page_hook ) ) { |
175 $hook_suffix = $page_hook; |
184 $hook_suffix = $page_hook; |
176 else if ( isset($plugin_page) ) |
185 } elseif ( isset( $plugin_page ) ) { |
177 $hook_suffix = $plugin_page; |
186 $hook_suffix = $plugin_page; |
178 else if ( isset($pagenow) ) |
187 } elseif ( isset( $pagenow ) ) { |
179 $hook_suffix = $pagenow; |
188 $hook_suffix = $pagenow; |
|
189 } |
180 |
190 |
181 set_current_screen(); |
191 set_current_screen(); |
182 |
192 |
183 // Handle plugin admin pages. |
193 // Handle plugin admin pages. |
184 if ( isset($plugin_page) ) { |
194 if ( isset($plugin_page) ) { |
187 * Fires before a particular screen is loaded. |
197 * Fires before a particular screen is loaded. |
188 * |
198 * |
189 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
199 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
190 * where a callback is provided when the screen is registered. |
200 * where a callback is provided when the screen is registered. |
191 * |
201 * |
192 * The dynamic portion of the hook name, $page_hook, refers to a mixture of plugin |
202 * The dynamic portion of the hook name, `$page_hook`, refers to a mixture of plugin |
193 * page information including: |
203 * page information including: |
194 * 1. The page type. If the plugin page is registered as a submenu page, such as for |
204 * 1. The page type. If the plugin page is registered as a submenu page, such as for |
195 * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. |
205 * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. |
196 * 2. A separator of '_page_'. |
206 * 2. A separator of '_page_'. |
197 * 3. The plugin basename minus the file extension. |
207 * 3. The plugin basename minus the file extension. |
198 * |
208 * |
199 * Together, the three parts form the $page_hook. Citing the example above, |
209 * Together, the three parts form the `$page_hook`. Citing the example above, |
200 * the hook name used would be 'load-settings_page_pluginbasename'. |
210 * the hook name used would be 'load-settings_page_pluginbasename'. |
201 * |
211 * |
202 * @see get_plugin_page_hook() |
212 * @see get_plugin_page_hook() |
203 * |
213 * |
204 * @since 2.1.0 |
214 * @since 2.1.0 |
226 * Fires before a particular screen is loaded. |
235 * Fires before a particular screen is loaded. |
227 * |
236 * |
228 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
237 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
229 * where the file to load is directly included, rather than the use of a function. |
238 * where the file to load is directly included, rather than the use of a function. |
230 * |
239 * |
231 * The dynamic portion of the hook name, $plugin_page, refers to the plugin basename. |
240 * The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename. |
232 * |
241 * |
233 * @see plugin_basename() |
242 * @see plugin_basename() |
234 * |
243 * |
235 * @since 1.5.0 |
244 * @since 1.5.0 |
236 */ |
245 */ |
246 } |
255 } |
247 |
256 |
248 include(ABSPATH . 'wp-admin/admin-footer.php'); |
257 include(ABSPATH . 'wp-admin/admin-footer.php'); |
249 |
258 |
250 exit(); |
259 exit(); |
251 } else if (isset($_GET['import'])) { |
260 } elseif ( isset( $_GET['import'] ) ) { |
252 |
261 |
253 $importer = $_GET['import']; |
262 $importer = $_GET['import']; |
254 |
263 |
255 if ( ! current_user_can('import') ) |
264 if ( ! current_user_can('import') ) |
256 wp_die(__('You are not allowed to import.')); |
265 wp_die(__('You are not allowed to import.')); |
293 * |
302 * |
294 * @since 3.1.0 |
303 * @since 3.1.0 |
295 * |
304 * |
296 * @param bool false Whether to force data to be filtered through kses. Default false. |
305 * @param bool false Whether to force data to be filtered through kses. Default false. |
297 */ |
306 */ |
298 if ( apply_filters( 'force_filtered_html_on_import', false ) ) |
307 if ( apply_filters( 'force_filtered_html_on_import', false ) ) { |
299 kses_init_filters(); // Always filter imported data with kses on multisite. |
308 kses_init_filters(); // Always filter imported data with kses on multisite. |
|
309 } |
300 |
310 |
301 call_user_func($wp_importers[$importer][2]); |
311 call_user_func($wp_importers[$importer][2]); |
302 |
312 |
303 include(ABSPATH . 'wp-admin/admin-footer.php'); |
313 include(ABSPATH . 'wp-admin/admin-footer.php'); |
304 |
314 |
310 /** |
320 /** |
311 * Fires before a particular screen is loaded. |
321 * Fires before a particular screen is loaded. |
312 * |
322 * |
313 * The load-* hook fires in a number of contexts. This hook is for core screens. |
323 * The load-* hook fires in a number of contexts. This hook is for core screens. |
314 * |
324 * |
315 * The dynamic portion of the hook name, $pagenow, is a global variable |
325 * The dynamic portion of the hook name, `$pagenow`, is a global variable |
316 * referring to the filename of the current page, such as 'admin.php', |
326 * referring to the filename of the current page, such as 'admin.php', |
317 * 'post-new.php' etc. A complete hook for the latter would be 'load-post-new.php'. |
327 * 'post-new.php' etc. A complete hook for the latter would be |
|
328 * 'load-post-new.php'. |
318 * |
329 * |
319 * @since 2.1.0 |
330 * @since 2.1.0 |
320 */ |
331 */ |
321 do_action( 'load-' . $pagenow ); |
332 do_action( 'load-' . $pagenow ); |
322 // Backwards compatibility with old load-page-new.php, load-page.php, |
333 |
323 // and load-categories.php actions. |
334 /* |
|
335 * The following hooks are fired to ensure backward compatibility. |
|
336 * In all other cases, 'load-' . $pagenow should be used instead. |
|
337 */ |
324 if ( $typenow == 'page' ) { |
338 if ( $typenow == 'page' ) { |
325 if ( $pagenow == 'post-new.php' ) |
339 if ( $pagenow == 'post-new.php' ) |
326 do_action( 'load-page-new.php' ); |
340 do_action( 'load-page-new.php' ); |
327 elseif ( $pagenow == 'post.php' ) |
341 elseif ( $pagenow == 'post.php' ) |
328 do_action( 'load-page.php' ); |
342 do_action( 'load-page.php' ); |
336 |
350 |
337 if ( ! empty( $_REQUEST['action'] ) ) { |
351 if ( ! empty( $_REQUEST['action'] ) ) { |
338 /** |
352 /** |
339 * Fires when an 'action' request variable is sent. |
353 * Fires when an 'action' request variable is sent. |
340 * |
354 * |
341 * The dynamic portion of the hook name, $_REQUEST['action'], |
355 * The dynamic portion of the hook name, `$_REQUEST['action']`, |
342 * refers to the action derived from the GET or POST request. |
356 * refers to the action derived from the `GET` or `POST` request. |
343 * |
357 * |
344 * @since 2.6.0 |
358 * @since 2.6.0 |
345 */ |
359 */ |
346 do_action( 'admin_action_' . $_REQUEST['action'] ); |
360 do_action( 'admin_action_' . $_REQUEST['action'] ); |
347 } |
361 } |