[ XREF Home ] [ Index ]

PHP Cross Reference of WordPress Trunk

Provided by Yoast

title

Body

[close]

/wp-admin/ -> admin.php (source)

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


Generated: Wed Jun 1 08:30:02 2011 Cross-referenced by PHPXref 0.7
Provided by Yoast and awesome WordPress Hosting