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 |
18 if ( ! defined('WP_NETWORK_ADMIN') ) |
18 if ( ! defined( 'WP_NETWORK_ADMIN' ) ) { |
19 define('WP_NETWORK_ADMIN', false); |
19 define( 'WP_NETWORK_ADMIN', false ); |
20 |
20 } |
21 if ( ! defined('WP_USER_ADMIN') ) |
21 |
22 define('WP_USER_ADMIN', false); |
22 if ( ! defined( 'WP_USER_ADMIN' ) ) { |
|
23 define( 'WP_USER_ADMIN', false ); |
|
24 } |
23 |
25 |
24 if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
26 if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { |
25 define('WP_BLOG_ADMIN', true); |
27 define( 'WP_BLOG_ADMIN', true ); |
26 } |
28 } |
27 |
29 |
28 if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) |
30 if ( isset( $_GET['import'] ) && ! defined( 'WP_LOAD_IMPORTERS' ) ) { |
29 define('WP_LOAD_IMPORTERS', true); |
31 define( 'WP_LOAD_IMPORTERS', true ); |
30 |
32 } |
31 require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); |
33 |
|
34 require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' ); |
32 |
35 |
33 nocache_headers(); |
36 nocache_headers(); |
34 |
37 |
35 if ( get_option('db_upgraded') ) { |
38 if ( get_option( 'db_upgraded' ) ) { |
36 flush_rewrite_rules(); |
39 flush_rewrite_rules(); |
37 update_option( 'db_upgraded', false ); |
40 update_option( 'db_upgraded', false ); |
38 |
41 |
39 /** |
42 /** |
40 * Fires on the next page load after a successful DB upgrade. |
43 * Fires on the next page load after a successful DB upgrade. |
41 * |
44 * |
42 * @since 2.8.0 |
45 * @since 2.8.0 |
43 */ |
46 */ |
44 do_action( 'after_db_upgrade' ); |
47 do_action( 'after_db_upgrade' ); |
45 } elseif ( get_option('db_version') != $wp_db_version && empty($_POST) ) { |
48 } elseif ( get_option( 'db_version' ) != $wp_db_version && empty( $_POST ) ) { |
46 if ( !is_multisite() ) { |
49 if ( ! is_multisite() ) { |
47 wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
50 wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ); |
48 exit; |
51 exit; |
49 |
52 |
50 /** |
53 /** |
51 * Filters whether to attempt to perform the multisite DB upgrade routine. |
54 * Filters whether to attempt to perform the multisite DB upgrade routine. |
52 * |
55 * |
53 * In single site, the user would be redirected to wp-admin/upgrade.php. |
56 * In single site, the user would be redirected to wp-admin/upgrade.php. |
54 * In multisite, the DB upgrade routine is automatically fired, but only |
57 * In multisite, the DB upgrade routine is automatically fired, but only |
55 * when this filter returns true. |
58 * when this filter returns true. |
56 * |
59 * |
57 * If the network is 50 sites or less, it will run every time. Otherwise, |
60 * If the network is 50 sites or less, it will run every time. Otherwise, |
58 * it will throttle itself to reduce load. |
61 * it will throttle itself to reduce load. |
59 * |
62 * |
60 * @since 3.0.0 |
63 * @since 3.0.0 |
61 * |
64 * |
62 * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
65 * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true. |
63 */ |
66 */ |
64 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
67 } elseif ( apply_filters( 'do_mu_upgrade', true ) ) { |
65 $c = get_blog_count(); |
68 $c = get_blog_count(); |
66 |
69 |
67 /* |
70 /* |
68 * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: |
71 * 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. |
72 * attempt to do no more than threshold value, with some +/- allowed. |
70 */ |
73 */ |
71 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) { |
74 if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) == 1 ) ) { |
72 require_once( ABSPATH . WPINC . '/http.php' ); |
75 require_once( ABSPATH . WPINC . '/http.php' ); |
73 $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
76 $response = wp_remote_get( |
|
77 admin_url( 'upgrade.php?step=1' ), |
|
78 array( |
|
79 'timeout' => 120, |
|
80 'httpversion' => '1.1', |
|
81 ) |
|
82 ); |
74 /** This action is documented in wp-admin/network/upgrade.php */ |
83 /** This action is documented in wp-admin/network/upgrade.php */ |
75 do_action( 'after_mu_upgrade', $response ); |
84 do_action( 'after_mu_upgrade', $response ); |
76 unset($response); |
85 unset( $response ); |
77 } |
86 } |
78 unset($c); |
87 unset( $c ); |
79 } |
88 } |
80 } |
89 } |
81 |
90 |
82 require_once(ABSPATH . 'wp-admin/includes/admin.php'); |
91 require_once( ABSPATH . 'wp-admin/includes/admin.php' ); |
83 |
92 |
84 auth_redirect(); |
93 auth_redirect(); |
85 |
94 |
86 // Schedule trash collection |
95 // Schedule trash collection |
87 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) |
96 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) { |
88 wp_schedule_event(time(), 'daily', 'wp_scheduled_delete'); |
97 wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' ); |
|
98 } |
89 |
99 |
90 // Schedule Transient cleanup. |
100 // Schedule Transient cleanup. |
91 if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { |
101 if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { |
92 wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); |
102 wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); |
93 } |
103 } |
115 |
125 |
116 $page_hook = null; |
126 $page_hook = null; |
117 |
127 |
118 $editing = false; |
128 $editing = false; |
119 |
129 |
120 if ( isset($_GET['page']) ) { |
130 if ( isset( $_GET['page'] ) ) { |
121 $plugin_page = wp_unslash( $_GET['page'] ); |
131 $plugin_page = wp_unslash( $_GET['page'] ); |
122 $plugin_page = plugin_basename($plugin_page); |
132 $plugin_page = plugin_basename( $plugin_page ); |
123 } |
133 } |
124 |
134 |
125 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
135 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) { |
126 $typenow = $_REQUEST['post_type']; |
136 $typenow = $_REQUEST['post_type']; |
127 else |
137 } else { |
128 $typenow = ''; |
138 $typenow = ''; |
129 |
139 } |
130 if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) |
140 |
|
141 if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) { |
131 $taxnow = $_REQUEST['taxonomy']; |
142 $taxnow = $_REQUEST['taxonomy']; |
132 else |
143 } else { |
133 $taxnow = ''; |
144 $taxnow = ''; |
134 |
145 } |
135 if ( WP_NETWORK_ADMIN ) |
146 |
136 require(ABSPATH . 'wp-admin/network/menu.php'); |
147 if ( WP_NETWORK_ADMIN ) { |
137 elseif ( WP_USER_ADMIN ) |
148 require( ABSPATH . 'wp-admin/network/menu.php' ); |
138 require(ABSPATH . 'wp-admin/user/menu.php'); |
149 } elseif ( WP_USER_ADMIN ) { |
139 else |
150 require( ABSPATH . 'wp-admin/user/menu.php' ); |
140 require(ABSPATH . 'wp-admin/menu.php'); |
151 } else { |
|
152 require( ABSPATH . 'wp-admin/menu.php' ); |
|
153 } |
141 |
154 |
142 if ( current_user_can( 'manage_options' ) ) { |
155 if ( current_user_can( 'manage_options' ) ) { |
143 wp_raise_memory_limit( 'admin' ); |
156 wp_raise_memory_limit( 'admin' ); |
144 } |
157 } |
145 |
158 |
153 * |
166 * |
154 * @since 2.5.0 |
167 * @since 2.5.0 |
155 */ |
168 */ |
156 do_action( 'admin_init' ); |
169 do_action( 'admin_init' ); |
157 |
170 |
158 if ( isset($plugin_page) ) { |
171 if ( isset( $plugin_page ) ) { |
159 if ( !empty($typenow) ) |
172 if ( ! empty( $typenow ) ) { |
160 $the_parent = $pagenow . '?post_type=' . $typenow; |
173 $the_parent = $pagenow . '?post_type=' . $typenow; |
161 else |
174 } else { |
162 $the_parent = $pagenow; |
175 $the_parent = $pagenow; |
163 if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) { |
176 } |
164 $page_hook = get_plugin_page_hook($plugin_page, $plugin_page); |
177 |
|
178 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent ); |
|
179 if ( ! $page_hook ) { |
|
180 $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page ); |
165 |
181 |
166 // Back-compat for plugins using add_management_page(). |
182 // Back-compat for plugins using add_management_page(). |
167 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) { |
183 if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook( $plugin_page, 'tools.php' ) ) { |
168 // There could be plugin specific params on the URL, so we need the whole query string |
184 // There could be plugin specific params on the URL, so we need the whole query string |
169 if ( !empty($_SERVER[ 'QUERY_STRING' ]) ) |
185 if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { |
170 $query_string = $_SERVER[ 'QUERY_STRING' ]; |
186 $query_string = $_SERVER['QUERY_STRING']; |
171 else |
187 } else { |
172 $query_string = 'page=' . $plugin_page; |
188 $query_string = 'page=' . $plugin_page; |
173 wp_redirect( admin_url('tools.php?' . $query_string) ); |
189 } |
|
190 wp_redirect( admin_url( 'tools.php?' . $query_string ) ); |
174 exit; |
191 exit; |
175 } |
192 } |
176 } |
193 } |
177 unset($the_parent); |
194 unset( $the_parent ); |
178 } |
195 } |
179 |
196 |
180 $hook_suffix = ''; |
197 $hook_suffix = ''; |
181 if ( isset( $page_hook ) ) { |
198 if ( isset( $page_hook ) ) { |
182 $hook_suffix = $page_hook; |
199 $hook_suffix = $page_hook; |
210 * @see get_plugin_page_hook() |
227 * @see get_plugin_page_hook() |
211 * |
228 * |
212 * @since 2.1.0 |
229 * @since 2.1.0 |
213 */ |
230 */ |
214 do_action( "load-{$page_hook}" ); |
231 do_action( "load-{$page_hook}" ); |
215 if (! isset($_GET['noheader'])) |
232 if ( ! isset( $_GET['noheader'] ) ) { |
216 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
233 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
234 } |
217 |
235 |
218 /** |
236 /** |
219 * Used to call the registered callback for a plugin screen. |
237 * Used to call the registered callback for a plugin screen. |
220 * |
238 * |
221 * @ignore |
239 * This hook uses a dynamic hook name, `$page_hook`, which refers to a mixture of plugin |
|
240 * page information including: |
|
241 * 1. The page type. If the plugin page is registered as a submenu page, such as for |
|
242 * Settings, the page type would be 'settings'. Otherwise the type is 'toplevel'. |
|
243 * 2. A separator of '_page_'. |
|
244 * 3. The plugin basename minus the file extension. |
|
245 * |
|
246 * Together, the three parts form the `$page_hook`. Citing the example above, |
|
247 * the hook name used would be 'settings_page_pluginbasename'. |
|
248 * |
|
249 * @see get_plugin_page_hook() |
|
250 * |
222 * @since 1.5.0 |
251 * @since 1.5.0 |
223 */ |
252 */ |
224 do_action( $page_hook ); |
253 do_action( $page_hook ); |
225 } else { |
254 } else { |
226 if ( validate_file( $plugin_page ) ) { |
255 if ( validate_file( $plugin_page ) ) { |
227 wp_die( __( 'Invalid plugin page.' ) ); |
256 wp_die( __( 'Invalid plugin page.' ) ); |
228 } |
257 } |
229 |
258 |
230 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") ) ) |
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" ) ) ) { |
231 wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page))); |
260 wp_die( sprintf( __( 'Cannot load %s.' ), htmlentities( $plugin_page ) ) ); |
|
261 } |
232 |
262 |
233 /** |
263 /** |
234 * Fires before a particular screen is loaded. |
264 * Fires before a particular screen is loaded. |
235 * |
265 * |
236 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
266 * The load-* hook fires in a number of contexts. This hook is for plugin screens |
242 * |
272 * |
243 * @since 1.5.0 |
273 * @since 1.5.0 |
244 */ |
274 */ |
245 do_action( "load-{$plugin_page}" ); |
275 do_action( "load-{$plugin_page}" ); |
246 |
276 |
247 if ( !isset($_GET['noheader'])) |
277 if ( ! isset( $_GET['noheader'] ) ) { |
248 require_once(ABSPATH . 'wp-admin/admin-header.php'); |
278 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
249 |
279 } |
250 if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") ) |
280 |
251 include(WPMU_PLUGIN_DIR . "/$plugin_page"); |
281 if ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page" ) ) { |
252 else |
282 include( WPMU_PLUGIN_DIR . "/$plugin_page" ); |
253 include(WP_PLUGIN_DIR . "/$plugin_page"); |
283 } else { |
254 } |
284 include( WP_PLUGIN_DIR . "/$plugin_page" ); |
255 |
285 } |
256 include(ABSPATH . 'wp-admin/admin-footer.php'); |
286 } |
|
287 |
|
288 include( ABSPATH . 'wp-admin/admin-footer.php' ); |
257 |
289 |
258 exit(); |
290 exit(); |
259 } elseif ( isset( $_GET['import'] ) ) { |
291 } elseif ( isset( $_GET['import'] ) ) { |
260 |
292 |
261 $importer = $_GET['import']; |
293 $importer = $_GET['import']; |
262 |
294 |
263 if ( ! current_user_can( 'import' ) ) { |
295 if ( ! current_user_can( 'import' ) ) { |
264 wp_die( __( 'Sorry, you are not allowed to import content.' ) ); |
296 wp_die( __( 'Sorry, you are not allowed to import content.' ) ); |
265 } |
297 } |
266 |
298 |
267 if ( validate_file($importer) ) { |
299 if ( validate_file( $importer ) ) { |
268 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
300 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
269 exit; |
301 exit; |
270 } |
302 } |
271 |
303 |
272 if ( ! isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2]) ) { |
304 if ( ! isset( $wp_importers[ $importer ] ) || ! is_callable( $wp_importers[ $importer ][2] ) ) { |
273 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
305 wp_redirect( admin_url( 'import.php?invalid=' . $importer ) ); |
274 exit; |
306 exit; |
275 } |
307 } |
276 |
308 |
277 /** |
309 /** |
334 /* |
367 /* |
335 * The following hooks are fired to ensure backward compatibility. |
368 * The following hooks are fired to ensure backward compatibility. |
336 * In all other cases, 'load-' . $pagenow should be used instead. |
369 * In all other cases, 'load-' . $pagenow should be used instead. |
337 */ |
370 */ |
338 if ( $typenow == 'page' ) { |
371 if ( $typenow == 'page' ) { |
339 if ( $pagenow == 'post-new.php' ) |
372 if ( $pagenow == 'post-new.php' ) { |
340 do_action( 'load-page-new.php' ); |
373 do_action( 'load-page-new.php' ); |
341 elseif ( $pagenow == 'post.php' ) |
374 } elseif ( $pagenow == 'post.php' ) { |
342 do_action( 'load-page.php' ); |
375 do_action( 'load-page.php' ); |
343 } elseif ( $pagenow == 'edit-tags.php' ) { |
376 } |
344 if ( $taxnow == 'category' ) |
377 } elseif ( $pagenow == 'edit-tags.php' ) { |
|
378 if ( $taxnow == 'category' ) { |
345 do_action( 'load-categories.php' ); |
379 do_action( 'load-categories.php' ); |
346 elseif ( $taxnow == 'link_category' ) |
380 } elseif ( $taxnow == 'link_category' ) { |
347 do_action( 'load-edit-link-categories.php' ); |
381 do_action( 'load-edit-link-categories.php' ); |
348 } elseif( 'term.php' === $pagenow ) { |
382 } |
|
383 } elseif ( 'term.php' === $pagenow ) { |
349 do_action( 'load-edit-tags.php' ); |
384 do_action( 'load-edit-tags.php' ); |
350 } |
385 } |
351 } |
386 } |
352 |
387 |
353 if ( ! empty( $_REQUEST['action'] ) ) { |
388 if ( ! empty( $_REQUEST['action'] ) ) { |
|
389 $action = $_REQUEST['action']; |
|
390 |
354 /** |
391 /** |
355 * Fires when an 'action' request variable is sent. |
392 * Fires when an 'action' request variable is sent. |
356 * |
393 * |
357 * The dynamic portion of the hook name, `$_REQUEST['action']`, |
394 * The dynamic portion of the hook name, `$action`, refers to |
358 * refers to the action derived from the `GET` or `POST` request. |
395 * the action derived from the `GET` or `POST` request. |
359 * |
396 * |
360 * @since 2.6.0 |
397 * @since 2.6.0 |
361 */ |
398 */ |
362 do_action( 'admin_action_' . $_REQUEST['action'] ); |
399 do_action( "admin_action_{$action}" ); |
363 } |
400 } |