Understanding the WordPress Core — Notes From a Direct Code Examination

Objective

The objective of this session was very clear:

Know the WordPress core by directly reading the code.

Not tutorials.
Not documentation.
Not summaries.

The approach was to take a fresh WordPress core package, open the actual files, and understand how WordPress starts and runs.


Current WordPress Core Version

At the time of writing, the latest stable WordPress core release is:

WordPress 6.9.4

This is part of the 6.9 branch, which includes security and maintenance fixes.


Starting Point

The process begins with downloading the WordPress core package and opening the core files directly.

The files examined first form the bootstrap spine of WordPress.

  • index.php
  • wp-blog-header.php
  • wp-load.php
  • wp-config.php
  • wp-settings.php
  • wp-includes/version.php
  • wp-includes/load.php

These files control how WordPress starts.


WordPress Entry Point

The first file examined is:

index.php

The file itself is extremely small and contains only a few lines.

Its job is simply to start WordPress.


define('WP_USE_THEMES', true);
require __DIR__ . '/wp-blog-header.php';

This tells WordPress to load themes and passes control to the next file.


Application Loader

The next file in the chain is:

wp-blog-header.php

This file performs three actions:

  1. Load the WordPress environment
  2. Run the WordPress query system
  3. Load the template engine

require_once __DIR__ . '/wp-load.php';
wp();
require_once ABSPATH . WPINC . '/template-loader.php';

At this point the WordPress runtime begins.


Configuration Loader

Next comes:

wp-load.php

This file locates the configuration file and prepares the environment.


define('ABSPATH', __DIR__ . '/');
require_once ABSPATH . 'wp-config.php';

Configuration File

The configuration file examined is:

wp-config.php

This file defines:

  • database credentials
  • authentication keys
  • table prefix
  • debugging settings

define('DB_NAME','database_name_here');
define('DB_USER','username_here');
define('DB_PASSWORD','password_here');
define('DB_HOST','localhost');

At the end of the file WordPress loads the runtime:


require_once ABSPATH . 'wp-settings.php';

Core Runtime Initialization

The most important bootstrap file is:

wp-settings.php

This file builds the WordPress runtime.

Major tasks inside this file include:

  • loading version information
  • checking server requirements
  • initializing constants
  • loading plugins
  • loading themes
  • firing WordPress hooks

Version Information

WordPress version data is defined in:

wp-includes/version.php

$wp_version = '6.9.4';

Environment Loader

The environment setup functions are located in:

wp-includes/load.php

This file performs tasks such as:

  • server variable normalization
  • maintenance mode checks
  • debugging configuration
  • database loading
  • object cache initialization

Plugin System

WordPress uses a hook system to allow plugins and themes to modify behavior.

The hook system is defined in:

wp-includes/plugin.php

Internally this relies on:

class-wp-hook.php

Hooks are executed through:

call_user_func_array()

Plugin Loading

Plugins load during initialization in the following order:

  1. Must-use plugins
  2. Network plugins
  3. Active plugins
wp-content/mu-plugins

Theme Loading

After plugins are loaded, WordPress loads the active theme.

If present, this file runs:

functions.php

Hook Execution


muplugins_loaded
plugins_loaded
setup_theme
after_setup_theme
init
wp_loaded

Key Insight

The WordPress architecture is driven by:

  1. A small bootstrap chain
  2. A hook-based execution system
  3. Plugin and theme extensibility

Conclusion

Understanding WordPress begins with understanding the bootstrap files and the hook system that builds the runtime environment.