wordpress source code analysis(2)

In the previous chapter, we know wp-settings.php is a complex file. This file loads almost everything like plugins and active theme. We will look into it further.

After including plugin functions such as add_filter, add_actions from wp-includes/plugin.php, it loads wp-includes/default-filters.php to add a lot of predefined filters and actions. After that, it can stop loading other stuff if we just want the basics. Otherwise, it continues to load a bunch of other files, load must use plugins. Then do the first action do_action( 'muplugins_loaded' ).

The core part of do_action function is :

do {
  foreach ( (array) current($wp_filter[$tag]) as $the_ )
  if ( !is_null($the_['function']) )
  call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );

 

The actions(functions) asscociated with the tag are stored in the array of array $wp_filter[$tag]. The loop calls all those functions with the parameter args.

Note that $wp_filter[$tag] is a two-dimension array. The first dimension is proirity and the second dimension is function name. The outer loop iterates over the proirities and the inner loop iterates over the functions.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply