PageRenderTime 25ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/admin.php

http://cartonbank.googlecode.com/
PHP | 208 lines | 130 code | 48 blank | 30 comment | 52 complexity | 7ebc14d09f00836734812f5c16ba30af MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, LGPL-2.1, AGPL-1.0, LGPL-3.0
  1. <?php
  2. /**
  3. * WordPress Administration Bootstrap
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /**
  9. * In WordPress Administration Panels
  10. *
  11. * @since unknown
  12. */
  13. if ( !defined('WP_ADMIN') )
  14. define('WP_ADMIN', TRUE);
  15. if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') )
  16. define('WP_LOAD_IMPORTERS', true);
  17. require_once(dirname(dirname(__FILE__)) . '/wp-load.php');
  18. if ( get_option('db_upgraded') ) {
  19. $wp_rewrite->flush_rules();
  20. update_option( 'db_upgraded', false );
  21. /**
  22. * Runs on the next page load after successful upgrade
  23. *
  24. * @since 2.8
  25. */
  26. do_action('after_db_upgrade');
  27. } elseif ( get_option('db_version') != $wp_db_version ) {
  28. if ( !is_multisite() ) {
  29. wp_redirect(admin_url('upgrade.php?_wp_http_referer=' . urlencode(stripslashes($_SERVER['REQUEST_URI']))));
  30. exit;
  31. } elseif ( apply_filters( 'do_mu_upgrade', true ) ) {
  32. /**
  33. * On really small MU installs run the upgrader every time,
  34. * else run it less often to reduce load.
  35. *
  36. * @since 2.8.4b
  37. */
  38. $c = get_blog_count();
  39. if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int)( $c / 50 ) ) == 1 ) ) {
  40. require_once( ABSPATH . WPINC . '/http.php' );
  41. $response = wp_remote_get( admin_url( 'upgrade.php?step=1' ), array( 'timeout' => 120, 'httpversion' => '1.1' ) );
  42. do_action( 'after_mu_upgrade', $response );
  43. unset($response);
  44. }
  45. unset($c);
  46. }
  47. }
  48. require_once(ABSPATH . 'wp-admin/includes/admin.php');
  49. auth_redirect();
  50. nocache_headers();
  51. update_category_cache();
  52. // Schedule trash collection
  53. if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
  54. wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
  55. set_screen_options();
  56. $date_format = get_option('date_format');
  57. $time_format = get_option('time_format');
  58. wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'text', 'trackback', 'pingback'));
  59. wp_enqueue_script( 'common' );
  60. wp_enqueue_script( 'jquery-color' );
  61. $editing = false;
  62. if ( isset($_GET['page']) ) {
  63. $plugin_page = stripslashes($_GET['page']);
  64. $plugin_page = plugin_basename($plugin_page);
  65. }
  66. if ( isset($_GET['post_type']) )
  67. $typenow = sanitize_key($_GET['post_type']);
  68. else
  69. $typenow = '';
  70. if ( isset($_GET['taxonomy']) )
  71. $taxnow = sanitize_key($_GET['taxonomy']);
  72. else
  73. $taxnow = '';
  74. require(ABSPATH . 'wp-admin/menu.php');
  75. //if ( current_user_can( 'manage_options' ) )
  76. // @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) ); //http://wordpress.org/support/topic/server-refuse-connection-on-wp-admin
  77. do_action('admin_init');
  78. if ( isset($plugin_page) ) {
  79. if ( !empty($typenow) )
  80. $the_parent = $pagenow . '?post_type=' . $typenow;
  81. else
  82. $the_parent = $pagenow;
  83. if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
  84. $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
  85. // backwards compatibility for plugins using add_management_page
  86. if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
  87. // There could be plugin specific params on the URL, so we need the whole query string
  88. if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
  89. $query_string = $_SERVER[ 'QUERY_STRING' ];
  90. else
  91. $query_string = 'page=' . $plugin_page;
  92. wp_redirect( 'tools.php?' . $query_string );
  93. exit;
  94. }
  95. }
  96. unset($the_parent);
  97. }
  98. $hook_suffix = '';
  99. if ( isset($page_hook) )
  100. $hook_suffix = $page_hook;
  101. else if ( isset($plugin_page) )
  102. $hook_suffix = $plugin_page;
  103. else if ( isset($pagenow) )
  104. $hook_suffix = $pagenow;
  105. set_current_screen();
  106. // Handle plugin admin pages.
  107. if ( isset($plugin_page) ) {
  108. if ( $page_hook ) {
  109. do_action('load-' . $page_hook);
  110. if (! isset($_GET['noheader']))
  111. require_once(ABSPATH . 'wp-admin/admin-header.php');
  112. do_action($page_hook);
  113. } else {
  114. if ( validate_file($plugin_page) )
  115. wp_die(__('Invalid plugin page'));
  116. 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") ) )
  117. wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
  118. do_action('load-' . $plugin_page);
  119. if ( !isset($_GET['noheader']))
  120. require_once(ABSPATH . 'wp-admin/admin-header.php');
  121. if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
  122. include(WPMU_PLUGIN_DIR . "/$plugin_page");
  123. else
  124. include(ABSPATH . PLUGINDIR . "/$plugin_page");
  125. }
  126. include(ABSPATH . 'wp-admin/admin-footer.php');
  127. exit();
  128. } else if (isset($_GET['import'])) {
  129. $importer = $_GET['import'];
  130. if ( ! current_user_can('import') )
  131. wp_die(__('You are not allowed to import.'));
  132. if ( validate_file($importer) )
  133. wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
  134. // Allow plugins to define importers as well
  135. if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) {
  136. if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
  137. wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
  138. include(ABSPATH . "wp-admin/import/$importer.php");
  139. }
  140. $parent_file = 'tools.php';
  141. $submenu_file = 'import.php';
  142. $title = __('Import');
  143. if (! isset($_GET['noheader']))
  144. require_once(ABSPATH . 'wp-admin/admin-header.php');
  145. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  146. define('WP_IMPORTING', true);
  147. if ( is_multisite() )
  148. kses_init_filters(); // Always filter imported data with kses.
  149. call_user_func($wp_importers[$importer][2]);
  150. include(ABSPATH . 'wp-admin/admin-footer.php');
  151. // Make sure rules are flushed
  152. global $wp_rewrite;
  153. $wp_rewrite->flush_rules(false);
  154. exit();
  155. } else {
  156. do_action("load-$pagenow");
  157. }
  158. if ( !empty($_REQUEST['action']) )
  159. do_action('admin_action_' . $_REQUEST['action']);
  160. ?>