wp/wp-admin/admin.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    46 	if ( !is_multisite() ) {
    46 	if ( !is_multisite() ) {
    47 		wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
    47 		wp_redirect( admin_url( 'upgrade.php?_wp_http_referer=' . urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) );
    48 		exit;
    48 		exit;
    49 
    49 
    50 	/**
    50 	/**
    51 	 * Filter whether to attempt to perform the multisite DB upgrade routine.
    51 	 * Filters whether to attempt to perform the multisite DB upgrade routine.
    52 	 *
    52 	 *
    53 	 * 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.
    54 	 * In multisite, the DB upgrade routine is automatically fired, but only
    54 	 * In multisite, the DB upgrade routine is automatically fired, but only
    55 	 * when this filter returns true.
    55 	 * when this filter returns true.
    56 	 *
    56 	 *
    57 	 * 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,
    58 	 * it will throttle itself to reduce load.
    58 	 * it will throttle itself to reduce load.
    59 	 *
    59 	 *
    60 	 * @since 3.0.0
    60 	 * @since 3.0.0
    61 	 *
    61 	 *
    62 	 * @param bool true Whether to perform the Multisite upgrade routine. Default true.
    62 	 * @param bool $do_mu_upgrade Whether to perform the Multisite upgrade routine. Default true.
    63 	 */
    63 	 */
    64 	} elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    64 	} elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
    65 		$c = get_blog_count();
    65 		$c = get_blog_count();
    66 
    66 
    67 		/*
    67 		/*
    82 require_once(ABSPATH . 'wp-admin/includes/admin.php');
    82 require_once(ABSPATH . 'wp-admin/includes/admin.php');
    83 
    83 
    84 auth_redirect();
    84 auth_redirect();
    85 
    85 
    86 // Schedule trash collection
    86 // Schedule trash collection
    87 if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
    87 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() )
    88 	wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
    88 	wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
    89 
    89 
       
    90 // Schedule Transient cleanup.
       
    91 if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) {
       
    92 	wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
       
    93 }
       
    94 
    90 set_screen_options();
    95 set_screen_options();
    91 
    96 
    92 $date_format = get_option('date_format');
    97 $date_format = __( 'F j, Y' );
    93 $time_format = get_option('time_format');
    98 $time_format = __( 'g:i a' );
    94 
    99 
    95 wp_enqueue_script( 'common' );
   100 wp_enqueue_script( 'common' );
    96 
   101 
    97 // $pagenow is set in vars.php
   102 /**
    98 // $wp_importers is sometimes set in wp-admin/includes/import.php
   103  * $pagenow is set in vars.php
    99 //
   104  * $wp_importers is sometimes set in wp-admin/includes/import.php
   100 // The remaining variables are imported as globals elsewhere,
   105  * The remaining variables are imported as globals elsewhere, declared as globals here
   101 //     declared as globals here
   106  *
       
   107  * @global string $pagenow
       
   108  * @global array  $wp_importers
       
   109  * @global string $hook_suffix
       
   110  * @global string $plugin_page
       
   111  * @global string $typenow
       
   112  * @global string $taxnow
       
   113  */
   102 global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
   114 global $pagenow, $wp_importers, $hook_suffix, $plugin_page, $typenow, $taxnow;
   103 
   115 
   104 $page_hook = null;
   116 $page_hook = null;
   105 
   117 
   106 $editing = false;
   118 $editing = false;
   126 	require(ABSPATH . 'wp-admin/user/menu.php');
   138 	require(ABSPATH . 'wp-admin/user/menu.php');
   127 else
   139 else
   128 	require(ABSPATH . 'wp-admin/menu.php');
   140 	require(ABSPATH . 'wp-admin/menu.php');
   129 
   141 
   130 if ( current_user_can( 'manage_options' ) ) {
   142 if ( current_user_can( 'manage_options' ) ) {
   131 	/**
   143 	wp_raise_memory_limit( 'admin' );
   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 }
   144 }
   147 
   145 
   148 /**
   146 /**
   149  * Fires as an admin screen or script is being initialized.
   147  * Fires as an admin screen or script is being initialized.
   150  *
   148  *
   151  * Note, this does not just run on user-facing admin screens.
   149  * Note, this does not just run on user-facing admin screens.
   152  * It runs on admin-ajax.php and admin-post.php as well.
   150  * It runs on admin-ajax.php and admin-post.php as well.
   153  *
   151  *
   154  * This is roughly analgous to the more general 'init' hook, which fires earlier.
   152  * This is roughly analogous to the more general {@see 'init'} hook, which fires earlier.
   155  *
   153  *
   156  * @since 2.5.0
   154  * @since 2.5.0
   157  */
   155  */
   158 do_action( 'admin_init' );
   156 do_action( 'admin_init' );
   159 
   157 
   163 	else
   161 	else
   164 		$the_parent = $pagenow;
   162 		$the_parent = $pagenow;
   165 	if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
   163 	if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
   166 		$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
   164 		$page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
   167 
   165 
   168 		// Backwards compatibility for plugins using add_management_page().
   166 		// Back-compat for plugins using add_management_page().
   169 		if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
   167 		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
   168 			// There could be plugin specific params on the URL, so we need the whole query string
   171 			if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
   169 			if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
   172 				$query_string = $_SERVER[ 'QUERY_STRING' ];
   170 				$query_string = $_SERVER[ 'QUERY_STRING' ];
   173 			else
   171 			else
   211 		 *
   209 		 *
   212 		 * @see get_plugin_page_hook()
   210 		 * @see get_plugin_page_hook()
   213 		 *
   211 		 *
   214 		 * @since 2.1.0
   212 		 * @since 2.1.0
   215 		 */
   213 		 */
   216 		do_action( 'load-' . $page_hook );
   214 		do_action( "load-{$page_hook}" );
   217 		if (! isset($_GET['noheader']))
   215 		if (! isset($_GET['noheader']))
   218 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   216 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   219 
   217 
   220 		/**
   218 		/**
   221 		 * Used to call the registered callback for a plugin screen.
   219 		 * Used to call the registered callback for a plugin screen.
   223 		 * @ignore
   221 		 * @ignore
   224 		 * @since 1.5.0
   222 		 * @since 1.5.0
   225 		 */
   223 		 */
   226 		do_action( $page_hook );
   224 		do_action( $page_hook );
   227 	} else {
   225 	} else {
   228 		if ( validate_file($plugin_page) )
   226 		if ( validate_file( $plugin_page ) ) {
   229 			wp_die(__('Invalid plugin page'));
   227 			wp_die( __( 'Invalid plugin page.' ) );
       
   228 		}
   230 
   229 
   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") ) )
   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") ) )
   232 			wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
   231 			wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
   233 
   232 
   234 		/**
   233 		/**
   241 		 *
   240 		 *
   242 		 * @see plugin_basename()
   241 		 * @see plugin_basename()
   243 		 *
   242 		 *
   244 		 * @since 1.5.0
   243 		 * @since 1.5.0
   245 		 */
   244 		 */
   246 		do_action( 'load-' . $plugin_page );
   245 		do_action( "load-{$plugin_page}" );
   247 
   246 
   248 		if ( !isset($_GET['noheader']))
   247 		if ( !isset($_GET['noheader']))
   249 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   248 			require_once(ABSPATH . 'wp-admin/admin-header.php');
   250 
   249 
   251 		if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
   250 		if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
   259 	exit();
   258 	exit();
   260 } elseif ( isset( $_GET['import'] ) ) {
   259 } elseif ( isset( $_GET['import'] ) ) {
   261 
   260 
   262 	$importer = $_GET['import'];
   261 	$importer = $_GET['import'];
   263 
   262 
   264 	if ( ! current_user_can('import') )
   263 	if ( ! current_user_can( 'import' ) ) {
   265 		wp_die(__('You are not allowed to import.'));
   264 		wp_die( __( 'Sorry, you are not allowed to import content.' ) );
       
   265 	}
   266 
   266 
   267 	if ( validate_file($importer) ) {
   267 	if ( validate_file($importer) ) {
   268 		wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
   268 		wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
   269 		exit;
   269 		exit;
   270 	}
   270 	}
   279 	 *
   279 	 *
   280 	 * The dynamic portion of the hook name, `$importer`, refers to the importer slug.
   280 	 * The dynamic portion of the hook name, `$importer`, refers to the importer slug.
   281 	 *
   281 	 *
   282 	 * @since 3.5.0
   282 	 * @since 3.5.0
   283 	 */
   283 	 */
   284 	do_action( 'load-importer-' . $importer );
   284 	do_action( "load-importer-{$importer}" );
   285 
   285 
   286 	$parent_file = 'tools.php';
   286 	$parent_file = 'tools.php';
   287 	$submenu_file = 'import.php';
   287 	$submenu_file = 'import.php';
   288 	$title = __('Import');
   288 	$title = __('Import');
   289 
   289 
   300 	 * Multisite uses this hook to filter all data through kses by default,
   300 	 * Multisite uses this hook to filter all data through kses by default,
   301 	 * as a super administrator may be assisting an untrusted user.
   301 	 * as a super administrator may be assisting an untrusted user.
   302 	 *
   302 	 *
   303 	 * @since 3.1.0
   303 	 * @since 3.1.0
   304 	 *
   304 	 *
   305 	 * @param bool false Whether to force data to be filtered through kses. Default false.
   305 	 * @param bool $force Whether to force data to be filtered through kses. Default false.
   306 	 */
   306 	 */
   307 	if ( apply_filters( 'force_filtered_html_on_import', false ) ) {
   307 	if ( apply_filters( 'force_filtered_html_on_import', false ) ) {
   308 		kses_init_filters();  // Always filter imported data with kses on multisite.
   308 		kses_init_filters();  // Always filter imported data with kses on multisite.
   309 	}
   309 	}
   310 
   310 
   327 	 * 'post-new.php' etc. A complete hook for the latter would be
   327 	 * 'post-new.php' etc. A complete hook for the latter would be
   328 	 * 'load-post-new.php'.
   328 	 * 'load-post-new.php'.
   329 	 *
   329 	 *
   330 	 * @since 2.1.0
   330 	 * @since 2.1.0
   331 	 */
   331 	 */
   332 	do_action( 'load-' . $pagenow );
   332 	do_action( "load-{$pagenow}" );
   333 
   333 
   334 	/*
   334 	/*
   335 	 * The following hooks are fired to ensure backward compatibility.
   335 	 * The following hooks are fired to ensure backward compatibility.
   336 	 * In all other cases, 'load-' . $pagenow should be used instead.
   336 	 * In all other cases, 'load-' . $pagenow should be used instead.
   337 	 */
   337 	 */
   343 	}  elseif ( $pagenow == 'edit-tags.php' ) {
   343 	}  elseif ( $pagenow == 'edit-tags.php' ) {
   344 		if ( $taxnow == 'category' )
   344 		if ( $taxnow == 'category' )
   345 			do_action( 'load-categories.php' );
   345 			do_action( 'load-categories.php' );
   346 		elseif ( $taxnow == 'link_category' )
   346 		elseif ( $taxnow == 'link_category' )
   347 			do_action( 'load-edit-link-categories.php' );
   347 			do_action( 'load-edit-link-categories.php' );
       
   348 	} elseif( 'term.php' === $pagenow ) {
       
   349 		do_action( 'load-edit-tags.php' );
   348 	}
   350 	}
   349 }
   351 }
   350 
   352 
   351 if ( ! empty( $_REQUEST['action'] ) ) {
   353 if ( ! empty( $_REQUEST['action'] ) ) {
   352 	/**
   354 	/**