29 |
29 |
30 if ( isset( $_GET['import'] ) && ! defined( 'WP_LOAD_IMPORTERS' ) ) { |
30 if ( isset( $_GET['import'] ) && ! defined( 'WP_LOAD_IMPORTERS' ) ) { |
31 define( 'WP_LOAD_IMPORTERS', true ); |
31 define( 'WP_LOAD_IMPORTERS', true ); |
32 } |
32 } |
33 |
33 |
34 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
34 require_once dirname( __DIR__ ) . '/wp-load.php'; |
35 |
35 |
36 nocache_headers(); |
36 nocache_headers(); |
37 |
37 |
38 if ( get_option( 'db_upgraded' ) ) { |
38 if ( get_option( 'db_upgraded' ) ) { |
|
39 |
39 flush_rewrite_rules(); |
40 flush_rewrite_rules(); |
40 update_option( 'db_upgraded', false ); |
41 update_option( 'db_upgraded', false ); |
41 |
42 |
42 /** |
43 /** |
43 * Fires on the next page load after a successful DB upgrade. |
44 * Fires on the next page load after a successful DB upgrade. |
44 * |
45 * |
45 * @since 2.8.0 |
46 * @since 2.8.0 |
46 */ |
47 */ |
47 do_action( 'after_db_upgrade' ); |
48 do_action( 'after_db_upgrade' ); |
48 } elseif ( get_option( 'db_version' ) != $wp_db_version && empty( $_POST ) ) { |
49 |
|
50 } elseif ( ! wp_doing_ajax() && empty( $_POST ) |
|
51 && (int) get_option( 'db_version' ) !== $wp_db_version |
|
52 ) { |
|
53 |
49 if ( ! is_multisite() ) { |
54 if ( ! is_multisite() ) { |
50 wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
55 wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
51 exit; |
56 exit; |
52 |
57 } |
53 /** |
58 |
54 * Filters whether to attempt to perform the multisite DB upgrade routine. |
59 /** |
55 * |
60 * Filters whether to attempt to perform the multisite DB upgrade routine. |
56 * In single site, the user would be redirected to wp-admin/upgrade.php. |
61 * |
57 * In multisite, the DB upgrade routine is automatically fired, but only |
62 * In single site, the user would be redirected to wp-admin/upgrade.php. |
58 * when this filter returns true. |
63 * In multisite, the DB upgrade routine is automatically fired, but only |
59 * |
64 * when this filter returns true. |
60 * If the network is 50 sites or less, it will run every time. Otherwise, |
65 * |
61 * it will throttle itself to reduce load. |
66 * If the network is 50 sites or less, it will run every time. Otherwise, |
62 * |
67 * it will throttle itself to reduce load. |
63 * @since 3.0.0 |
68 * |
64 * |
69 * @since MU (3.0.0) |
65 * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
70 * |
66 */ |
71 * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
67 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
72 */ |
|
73 if ( apply_filters( 'do_mu_upgrade', true ) ) { |
68 $c = get_blog_count(); |
74 $c = get_blog_count(); |
69 |
75 |
70 /* |
76 /* |
71 * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
77 * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
72 * attempt to do no more than threshold value, with some +/- allowed. |
78 * attempt to do no more than threshold value, with some +/- allowed. |
73 */ |
79 */ |
74 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) == 1 ) ) { |
80 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) === 1 ) ) { |
75 require_once( ABSPATH . WPINC . '/http.php' ); |
81 require_once ABSPATH . WPINC . '/http.php'; |
76 $response = wp_remote_get( |
82 $response = wp_remote_get( |
77 admin_url( 'upgrade.php?step=1' ), |
83 admin_url( 'upgrade.php?step=1' ), |
78 array( |
84 array( |
79 'timeout' => 120, |
85 'timeout' => 120, |
80 'httpversion' => '1.1', |
86 'httpversion' => '1.1', |
86 } |
92 } |
87 unset( $c ); |
93 unset( $c ); |
88 } |
94 } |
89 } |
95 } |
90 |
96 |
91 require_once( ABSPATH . 'wp-admin/includes/admin.php' ); |
97 require_once ABSPATH . 'wp-admin/includes/admin.php'; |
92 |
98 |
93 auth_redirect(); |
99 auth_redirect(); |
94 |
100 |
95 // Schedule trash collection |
101 // Schedule Trash collection. |
96 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) { |
102 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) { |
97 wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' ); |
103 wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' ); |
98 } |
104 } |
99 |
105 |
100 // Schedule Transient cleanup. |
106 // Schedule transient cleanup. |
101 if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { |
107 if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { |
102 wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); |
108 wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); |
103 } |
109 } |
104 |
110 |
105 set_screen_options(); |
111 set_screen_options(); |
178 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent ); |
184 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent ); |
179 if ( ! $page_hook ) { |
185 if ( ! $page_hook ) { |
180 $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page ); |
186 $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page ); |
181 |
187 |
182 // Back-compat for plugins using add_management_page(). |
188 // Back-compat for plugins using add_management_page(). |
183 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook( $plugin_page, 'tools.php' ) ) { |
189 if ( empty( $page_hook ) && 'edit.php' === $pagenow && get_plugin_page_hook( $plugin_page, 'tools.php' ) ) { |
184 // There could be plugin specific params on the URL, so we need the whole query string |
190 // There could be plugin specific params on the URL, so we need the whole query string. |
185 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
191 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
186 $query_string = $_SERVER['QUERY_STRING']; |
192 $query_string = $_SERVER['QUERY_STRING']; |
187 } else { |
193 } else { |
188 $query_string = 'page=' . $plugin_page; |
194 $query_string = 'page=' . $plugin_page; |
189 } |
195 } |
254 } else { |
260 } else { |
255 if ( validate_file( $plugin_page ) ) { |
261 if ( validate_file( $plugin_page ) ) { |
256 wp_die( __( 'Invalid plugin page.' ) ); |
262 wp_die( __( 'Invalid plugin page.' ) ); |
257 } |
263 } |
258 |
264 |
259 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" ) ) ) { |
265 if ( ! ( file_exists( WP_PLUGIN_DIR . "/$plugin_page" ) && is_file( WP_PLUGIN_DIR . "/$plugin_page" ) ) |
|
266 && ! ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) && is_file( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) |
|
267 ) { |
|
268 /* translators: %s: Admin page generated by a plugin. */ |
260 wp_die( sprintf( __( 'Cannot load %s.' ), htmlentities( $plugin_page ) ) ); |
269 wp_die( sprintf( __( 'Cannot load %s.' ), htmlentities( $plugin_page ) ) ); |
261 } |
270 } |
262 |
271 |
263 /** |
272 /** |
264 * Fires before a particular screen is loaded. |
273 * Fires before a particular screen is loaded. |
270 * |
279 * |
271 * @see plugin_basename() |
280 * @see plugin_basename() |
272 * |
281 * |
273 * @since 1.5.0 |
282 * @since 1.5.0 |
274 */ |
283 */ |
275 do_action( "load-{$plugin_page}" ); |
284 do_action( "load-{$plugin_page}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
276 |
285 |
277 if ( ! isset( $_GET['noheader'] ) ) { |
286 if ( ! isset( $_GET['noheader'] ) ) { |
278 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
287 require_once ABSPATH . 'wp-admin/admin-header.php'; |
279 } |
288 } |
280 |
289 |
281 if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) { |
290 if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) { |
282 include( WPMU_PLUGIN_DIR . "/$plugin_page" ); |
291 include WPMU_PLUGIN_DIR . "/$plugin_page"; |
283 } else { |
292 } else { |
284 include( WP_PLUGIN_DIR . "/$plugin_page" ); |
293 include WP_PLUGIN_DIR . "/$plugin_page"; |
285 } |
294 } |
286 } |
295 } |
287 |
296 |
288 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
297 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
289 |
298 |
290 exit(); |
299 exit; |
291 } elseif ( isset( $_GET['import'] ) ) { |
300 } elseif ( isset( $_GET['import'] ) ) { |
292 |
301 |
293 $importer = $_GET['import']; |
302 $importer = $_GET['import']; |
294 |
303 |
295 if ( ! current_user_can( 'import' ) ) { |
304 if ( ! current_user_can( 'import' ) ) { |
296 wp_die( __( 'Sorry, you are not allowed to import content.' ) ); |
305 wp_die( __( 'Sorry, you are not allowed to import content into this site.' ) ); |
297 } |
306 } |
298 |
307 |
299 if ( validate_file( $importer ) ) { |
308 if ( validate_file( $importer ) ) { |
300 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
309 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
301 exit; |
310 exit; |
311 * |
320 * |
312 * The dynamic portion of the hook name, `$importer`, refers to the importer slug. |
321 * The dynamic portion of the hook name, `$importer`, refers to the importer slug. |
313 * |
322 * |
314 * @since 3.5.0 |
323 * @since 3.5.0 |
315 */ |
324 */ |
316 do_action( "load-importer-{$importer}" ); |
325 do_action( "load-importer-{$importer}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
317 |
326 |
318 $parent_file = 'tools.php'; |
327 $parent_file = 'tools.php'; |
319 $submenu_file = 'import.php'; |
328 $submenu_file = 'import.php'; |
320 $title = __( 'Import' ); |
329 $title = __( 'Import' ); |
321 |
330 |
322 if ( ! isset( $_GET['noheader'] ) ) { |
331 if ( ! isset( $_GET['noheader'] ) ) { |
323 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
332 require_once ABSPATH . 'wp-admin/admin-header.php'; |
324 } |
333 } |
325 |
334 |
326 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
335 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
327 |
336 |
328 define( 'WP_IMPORTING', true ); |
337 define( 'WP_IMPORTING', true ); |
329 |
338 |
330 /** |
339 /** |
331 * Whether to filter imported data through kses on import. |
340 * Whether to filter imported data through kses on import. |
341 kses_init_filters(); // Always filter imported data with kses on multisite. |
350 kses_init_filters(); // Always filter imported data with kses on multisite. |
342 } |
351 } |
343 |
352 |
344 call_user_func( $wp_importers[ $importer ][2] ); |
353 call_user_func( $wp_importers[ $importer ][2] ); |
345 |
354 |
346 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
355 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
347 |
356 |
348 // Make sure rules are flushed |
357 // Make sure rules are flushed. |
349 flush_rewrite_rules( false ); |
358 flush_rewrite_rules( false ); |
350 |
359 |
351 exit(); |
360 exit; |
352 } else { |
361 } else { |
353 /** |
362 /** |
354 * Fires before a particular screen is loaded. |
363 * Fires before a particular screen is loaded. |
355 * |
364 * |
356 * The load-* hook fires in a number of contexts. This hook is for core screens. |
365 * The load-* hook fires in a number of contexts. This hook is for core screens. |
360 * 'post-new.php' etc. A complete hook for the latter would be |
369 * 'post-new.php' etc. A complete hook for the latter would be |
361 * 'load-post-new.php'. |
370 * 'load-post-new.php'. |
362 * |
371 * |
363 * @since 2.1.0 |
372 * @since 2.1.0 |
364 */ |
373 */ |
365 do_action( "load-{$pagenow}" ); |
374 do_action( "load-{$pagenow}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
366 |
375 |
367 /* |
376 /* |
368 * The following hooks are fired to ensure backward compatibility. |
377 * The following hooks are fired to ensure backward compatibility. |
369 * In all other cases, 'load-' . $pagenow should be used instead. |
378 * In all other cases, 'load-' . $pagenow should be used instead. |
370 */ |
379 */ |
371 if ( $typenow == 'page' ) { |
380 if ( 'page' === $typenow ) { |
372 if ( $pagenow == 'post-new.php' ) { |
381 if ( 'post-new.php' === $pagenow ) { |
373 do_action( 'load-page-new.php' ); |
382 do_action( 'load-page-new.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
374 } elseif ( $pagenow == 'post.php' ) { |
383 } elseif ( 'post.php' === $pagenow ) { |
375 do_action( 'load-page.php' ); |
384 do_action( 'load-page.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
376 } |
385 } |
377 } elseif ( $pagenow == 'edit-tags.php' ) { |
386 } elseif ( 'edit-tags.php' === $pagenow ) { |
378 if ( $taxnow == 'category' ) { |
387 if ( 'category' === $taxnow ) { |
379 do_action( 'load-categories.php' ); |
388 do_action( 'load-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
380 } elseif ( $taxnow == 'link_category' ) { |
389 } elseif ( 'link_category' === $taxnow ) { |
381 do_action( 'load-edit-link-categories.php' ); |
390 do_action( 'load-edit-link-categories.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
382 } |
391 } |
383 } elseif ( 'term.php' === $pagenow ) { |
392 } elseif ( 'term.php' === $pagenow ) { |
384 do_action( 'load-edit-tags.php' ); |
393 do_action( 'load-edit-tags.php' ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
385 } |
394 } |
386 } |
395 } |
387 |
396 |
388 if ( ! empty( $_REQUEST['action'] ) ) { |
397 if ( ! empty( $_REQUEST['action'] ) ) { |
389 $action = $_REQUEST['action']; |
398 $action = $_REQUEST['action']; |