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

/wordpress3.4.2/wp-admin/admin.php

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