WordPressのソースコードを読む(1)
WordPressを使う機会が増えたので、少しずつソースコードを読んでフレームワークの理解を深めたいと思います。
index.php
<?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' );
まずは、index.php。WordPressでテーマを使用すると定義したあとにwp-blog-header.phpを読み込む役割のようです。
wp-blog-header.php
<?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_did_header) ) { $wp_did_header = true; require_once( dirname(__FILE__) . '/wp-load.php' ); wp(); require_once( ABSPATH . WPINC . '/template-loader.php' ); }
ファイルの読み込みがされていないことを確認して処理を実行します。
次回は、ファイルの内容と関数の中身を見て行きます。