今回はwp-settings.phpを見てみます。
このファイルの役割をまとめるとWordPressが動作するために必要な各種定数・関数・クラスの設定を行うということになります。
長いファイルですがめげずに頑張って見てみることにしますね。
wp-settings.phpの処理内容
<?php define( 'WPINC', 'wp-includes' ); require( ABSPATH . WPINC . '/load.php' ); require( ABSPATH . WPINC . '/default-constants.php' ); global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version; require( ABSPATH . WPINC . '/version.php' ); wp_initial_constants(); wp_check_php_mysql_versions(); @ini_set( 'magic_quotes_runtime', 0 ); @ini_set( 'magic_quotes_sybase', 0 ); date_default_timezone_set( 'UTC' ); wp_unregister_GLOBALS(); wp_fix_server_vars(); wp_favicon_request(); wp_maintenance(); timer_start(); wp_debug_mode(); if ( WP_CACHE ) WP_DEBUG ? include( WP_CONTENT_DIR . '/advanced-cache.php' ) : @include( WP_CONTENT_DIR . '/advanced-cache.php' ); wp_set_lang_dir(); require( ABSPATH . WPINC . '/compat.php' ); require( ABSPATH . WPINC . '/functions.php' ); require( ABSPATH . WPINC . '/class-wp.php' ); require( ABSPATH . WPINC . '/class-wp-error.php' ); require( ABSPATH . WPINC . '/plugin.php' ); require( ABSPATH . WPINC . '/pomo/mo.php' ); require_wp_db(); $GLOBALS['table_prefix'] = $table_prefix; wp_set_wpdb_vars(); wp_start_object_cache(); require( ABSPATH . WPINC . '/default-filters.php' ); if ( is_multisite() ) { require( ABSPATH . WPINC . '/ms-blogs.php' ); require( ABSPATH . WPINC . '/ms-settings.php' ); } elseif ( ! defined( 'MULTISITE' ) ) { define( 'MULTISITE', false ); } register_shutdown_function( 'shutdown_action_hook' ); return false; require_once( ABSPATH . WPINC . '/l10n.php' ); wp_not_installed(); require( ABSPATH . WPINC . '/class-wp-walker.php' ); require( ABSPATH . WPINC . '/class-wp-ajax-response.php' ); require( ABSPATH . WPINC . '/formatting.php' ); require( ABSPATH . WPINC . '/capabilities.php' ); require( ABSPATH . WPINC . '/query.php' ); require( ABSPATH . WPINC . '/date.php' ); require( ABSPATH . WPINC . '/theme.php' ); require( ABSPATH . WPINC . '/class-wp-theme.php' ); require( ABSPATH . WPINC . '/template.php' ); require( ABSPATH . WPINC . '/user.php' ); require( ABSPATH . WPINC . '/session.php' ); require( ABSPATH . WPINC . '/meta.php' ); require( ABSPATH . WPINC . '/general-template.php' ); require( ABSPATH . WPINC . '/link-template.php' ); require( ABSPATH . WPINC . '/author-template.php' ); require( ABSPATH . WPINC . '/post.php' ); require( ABSPATH . WPINC . '/post-template.php' ); require( ABSPATH . WPINC . '/revision.php' ); require( ABSPATH . WPINC . '/post-formats.php' ); require( ABSPATH . WPINC . '/post-thumbnail-template.php' ); require( ABSPATH . WPINC . '/category.php' ); require( ABSPATH . WPINC . '/category-template.php' ); require( ABSPATH . WPINC . '/comment.php' ); require( ABSPATH . WPINC . '/comment-template.php' ); require( ABSPATH . WPINC . '/rewrite.php' ); require( ABSPATH . WPINC . '/feed.php' ); require( ABSPATH . WPINC . '/bookmark.php' ); require( ABSPATH . WPINC . '/bookmark-template.php' ); require( ABSPATH . WPINC . '/kses.php' ); require( ABSPATH . WPINC . '/cron.php' ); require( ABSPATH . WPINC . '/deprecated.php' ); require( ABSPATH . WPINC . '/script-loader.php' ); require( ABSPATH . WPINC . '/taxonomy.php' ); require( ABSPATH . WPINC . '/update.php' ); require( ABSPATH . WPINC . '/canonical.php' ); require( ABSPATH . WPINC . '/shortcodes.php' ); require( ABSPATH . WPINC . '/class-wp-embed.php' ); require( ABSPATH . WPINC . '/media.php' ); require( ABSPATH . WPINC . '/http.php' ); require( ABSPATH . WPINC . '/class-http.php' ); require( ABSPATH . WPINC . '/widgets.php' ); require( ABSPATH . WPINC . '/nav-menu.php' ); require( ABSPATH . WPINC . '/nav-menu-template.php' ); require( ABSPATH . WPINC . '/admin-bar.php' ); if ( is_multisite() ) { require( ABSPATH . WPINC . '/ms-functions.php' ); require( ABSPATH . WPINC . '/ms-default-filters.php' ); require( ABSPATH . WPINC . '/ms-deprecated.php' ); } wp_plugin_directory_constants(); $GLOBALS['wp_plugin_paths'] = array(); foreach ( wp_get_mu_plugins() as $mu_plugin ) { include_once( $mu_plugin ); } unset( $mu_plugin ); if ( is_multisite() ) { foreach( wp_get_active_network_plugins() as $network_plugin ) { wp_register_plugin_realpath( $network_plugin ); include_once( $network_plugin ); } unset( $network_plugin ); } do_action( 'muplugins_loaded' ); if ( is_multisite() ) ms_cookie_constants( ); wp_cookie_constants(); wp_ssl_constants(); require( ABSPATH . WPINC . '/vars.php' ); create_initial_taxonomies(); create_initial_post_types(); register_theme_directory( get_theme_root() ); foreach ( wp_get_active_and_valid_plugins() as $plugin ) { wp_register_plugin_realpath( $plugin ); include_once( $plugin ); } unset( $plugin ); require( ABSPATH . WPINC . '/pluggable.php' ); require( ABSPATH . WPINC . '/pluggable-deprecated.php' ); wp_set_internal_encoding(); if ( WP_CACHE && function_exists( 'wp_cache_postload' ) ) wp_cache_postload(); do_action( 'plugins_loaded' ); wp_functionality_constants(); wp_magic_quotes(); do_action( 'sanitize_comment_cookies' ); $GLOBALS['wp_the_query'] = new WP_Query(); $GLOBALS['wp_query'] = $GLOBALS['wp_the_query']; $GLOBALS['wp_rewrite'] = new WP_Rewrite(); $GLOBALS['wp'] = new WP(); $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory(); $GLOBALS['wp_roles'] = new WP_Roles(); do_action( 'setup_theme' ); // Define the template related constants. wp_templating_constants( ); // Load the default text localization domain. load_default_textdomain(); $locale = get_locale(); $locale_file = WP_LANG_DIR . "/$locale.php"; if ( ( 0 === validate_file( $locale ) ) && is_readable( $locale_file ) ) require( $locale_file ); unset( $locale_file ); require_once( ABSPATH . WPINC . '/locale.php' ); $GLOBALS['wp_locale'] = new WP_Locale(); if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) { if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) include( STYLESHEETPATH . '/functions.php' ); if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) include( TEMPLATEPATH . '/functions.php' ); } do_action( 'after_setup_theme' ); $GLOBALS['wp']->init(); do_action( 'init' ); if ( is_multisite() ) { if ( true !== ( $file = ms_site_check() ) ) { require( $file ); die(); } unset($file); } do_action( 'wp_loaded' );
長い。。。
心が折れました。外部のPHPファイルで定義されている(と思われる)定数、変数、関数がありすぎて先にそっちを読まないと訳がわかりません。
本来は一つずつ理解して進みたいんですがこれはそうも言ってられそうにないので主だった処理をまとめるとwp-load.php及びdefault-constants.phpを読み込んで関数や定数を定義することとwp-includesディレクトリ以下のPHPファイルを多数読み込むことの二つになるかと思います。
ということで続けてload.phpとdefault-constants.phpを見ていくことにしたいと思います。