Pada waktu kita membahas mengenai htaccess WordPress kita melihat bahwa pintu utama kedua WordPress setelah htaccess adalah index.php . Kita akan melacak alur dari index.php yang merupakan pintu kedua aplikasi WordPress.

Kalau kita melihat source code index.php dari WordPress adalah

<?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’ );

Kalau kita membaca source code di atas maka kita melihat dua hal berikut ini

  1. Mendefinisikan constant WP_USE_THEMES=true
     
  2. Meload wp-blog-header.php.
    Constant __FILE__ merupakan magic contant PHP yang dibicarakan di http://php.net/manual/en/language.constants.predefined.php .

Dari source code di atas maka index.php ini meload wp-blog-header.php .

Kita perlu melihat source code wp-blog-header.php seperti di bawah ini:

<?php
/**
 * Loads the WordPress environment and template.
 *
 * @package WordPress
 */

if ( !isset($wp_did_header) ) {

    $wp_did_header = true;

    // Load the WordPress library.
    require_once( dirname(__FILE__) . ‘/wp-load.php’ );

    // Set up the WordPress query.
    wp();

    // Load the theme template.
    require_once( ABSPATH . WPINC . ‘/template-loader.php’ );

}

Pada source wp-blog-header.php ini kita melihat bahwa wp-blog-header.php ini meload wp-load.php . 
Kita juga bahwa program di atas menjalankan function wp(). Jika kita penasaran mengenai function wp() ini, apa yang dikerjakan dan di mana lokasinya, kita dapat mencarinya di https://developer.wordpress.org/reference/ atau langsung ke https://developer.wordpress.org/reference/functions/wp/ .

Bagian penting dari souce code wp-load.php ini adalah

if ( file_exists( ABSPATH . ‘wp-config.php’) ) {

    /** The config file resides in ABSPATH */
    require_once( ABSPATH . ‘wp-config.php’ );

}

Dengan pemikiran yang sama kita perlu melihat bagian penting dari source code wp-config.php yaitu

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . ‘wp-settings.php’);

Dengan demikian salah satu bagian utama alur index.php ini sampai pada file wp-settings.php .

Kunjungi www.proweb.co.id untuk menambah wawasan anda.

Melacak index.php WordPress
× Ada yang dapat saya bantu ? Available on SundayMondayTuesdayWednesdayThursdayFridaySaturday