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

/wp-admin/admin.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 203 lines | 128 code | 47 blank | 28 comment | 52 complexity | bfc064037511bde4be26b0829eb46dc2 MD5 | raw file
  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_user($_GET['post_type'], true);
  68. else
  69. $typenow = '';
  70. require(ABSPATH . 'wp-admin/menu.php');
  71. if ( current_user_can( 'manage_options' ) )
  72. @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
  73. do_action('admin_init');
  74. if ( isset($plugin_page) ) {
  75. if ( !empty($typenow) )
  76. $the_parent = $pagenow . '?post_type=' . $typenow;
  77. else
  78. $the_parent = $pagenow;
  79. if ( ! $page_hook = get_plugin_page_hook($plugin_page, $the_parent) ) {
  80. $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
  81. // backwards compatibility for plugins using add_management_page
  82. if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook($plugin_page, 'tools.php') ) {
  83. // There could be plugin specific params on the URL, so we need the whole query string
  84. if ( !empty($_SERVER[ 'QUERY_STRING' ]) )
  85. $query_string = $_SERVER[ 'QUERY_STRING' ];
  86. else
  87. $query_string = 'page=' . $plugin_page;
  88. wp_redirect( 'tools.php?' . $query_string );
  89. exit;
  90. }
  91. }
  92. unset($the_parent);
  93. }
  94. $hook_suffix = '';
  95. if ( isset($page_hook) )
  96. $hook_suffix = $page_hook;
  97. else if ( isset($plugin_page) )
  98. $hook_suffix = $plugin_page;
  99. else if ( isset($pagenow) )
  100. $hook_suffix = $pagenow;
  101. set_current_screen();
  102. // Handle plugin admin pages.
  103. if ( isset($plugin_page) ) {
  104. if ( $page_hook ) {
  105. do_action('load-' . $page_hook);
  106. if (! isset($_GET['noheader']))
  107. require_once(ABSPATH . 'wp-admin/admin-header.php');
  108. do_action($page_hook);
  109. } else {
  110. if ( validate_file($plugin_page) )
  111. wp_die(__('Invalid plugin page'));
  112. 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") ) )
  113. wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
  114. do_action('load-' . $plugin_page);
  115. if ( !isset($_GET['noheader']))
  116. require_once(ABSPATH . 'wp-admin/admin-header.php');
  117. if ( file_exists(WPMU_PLUGIN_DIR . "/$plugin_page") )
  118. include(WPMU_PLUGIN_DIR . "/$plugin_page");
  119. else
  120. include(ABSPATH . PLUGINDIR . "/$plugin_page");
  121. }
  122. include(ABSPATH . 'wp-admin/admin-footer.php');
  123. exit();
  124. } else if (isset($_GET['import'])) {
  125. $importer = $_GET['import'];
  126. if ( ! current_user_can('import') )
  127. wp_die(__('You are not allowed to import.'));
  128. if ( validate_file($importer) )
  129. wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
  130. // Allow plugins to define importers as well
  131. if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) {
  132. if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
  133. wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
  134. include(ABSPATH . "wp-admin/import/$importer.php");
  135. }
  136. $parent_file = 'tools.php';
  137. $submenu_file = 'import.php';
  138. $title = __('Import');
  139. if (! isset($_GET['noheader']))
  140. require_once(ABSPATH . 'wp-admin/admin-header.php');
  141. require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
  142. define('WP_IMPORTING', true);
  143. if ( is_multisite() )
  144. kses_init_filters(); // Always filter imported data with kses.
  145. call_user_func($wp_importers[$importer][2]);
  146. include(ABSPATH . 'wp-admin/admin-footer.php');
  147. // Make sure rules are flushed
  148. global $wp_rewrite;
  149. $wp_rewrite->flush_rules(false);
  150. exit();
  151. } else {
  152. do_action("load-$pagenow");
  153. }
  154. if ( !empty($_REQUEST['action']) )
  155. do_action('admin_action_' . $_REQUEST['action']);
  156. ?>