学php之翻译wordpress(1)

单看文件结构,wordpress分了3个文件夹 wp-admin,wp-content,wp-includes 和零散的一堆php,暂时不清楚各自的分工

入口文件是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.
 * 主要就是加载wp-blog-header.php
* * @var bool
*/ define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' );

然后是wp-blog-header.php,这里可以看出wordpress 开始分了两个模块

  1. 加载非template 的东西
  2. 加载template 的东西
<?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();// wp-load.php 里面require了/wp-admin/setup-config.php,/wp-admin/setup-config.php里面 require了/wp-admin/wp-settings.php,/wp-admin/wp-settings.php require 了class-wp.php ,得到了WP 类,然后执行$GLOBALS['wp'] = new WP() 得到一个实例;
require_once( ABSPATH . WPINC . '/template-loader.php' );// 加载templateloader.php 文件 }

 

posted @ 2015-11-30 17:04  pasico  阅读(240)  评论(0编辑  收藏  举报