WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

WP URL call

I got this image from one E-book for WP plugin development. Could you please clarify me why the Plugins are loaded before Pluggables.

share|improve this question
Please watch the license. Every content in here is GNU GPL licensed. If the image isn't, then please remove it and replace it with your own. Else the sky might fall on your head. – kaiser Jan 17 '12 at 18:15
up vote 2 down vote accepted

Directly from source for pluggable.php:

 * These functions can be replaced via plugins. If plugins do not redefine these
 * functions, then these will be used instead.
 * @package WordPress

So, there's your answer, the functions in pluggable.php are intended to be overridden by Plugins.

Re: load order:

See this post by Konstantin Kovshenin. The relevant points (10-15):

  1. wp_get_active_and_valid_plugins() retrieves the list of all active plugin files for loading and includes them. This is the point where your plugin code gets executed, functions, classes defined, etc.
  2. Includes wp-includes/wp-pluggable.php and wp-includes/wp-pluggable-deprecated.php which include functions (and deprecated functions) that can be redefined by plugins. Like wp_mail() for more advanced mailing, wp_authenticate() for alternative authentication methods, etc.
  3. wp_set_internal_encoding() is called to set the internal encoding according to the blog_charset option.
  4. wp_cache_postload() is called if object caching is enabled.
  5. At this point a plugins_loaded action is fired. This is the very first action (after muplugins_loaded fired before loading the non-multi-site WordPress plugins) that you can hook into, it comes before the init because WordPress has not been initialized yet, at least not fully.

So, simplified:

  1. Plugins are loaded
  2. pluggable.php is loaded
  3. plugins_loaded action is fired

Which is the expected order.

(Note: this all takes place in wp-settings.php.)

share|improve this answer
The doubt is, as you said if the functions of pluggable.php is overridden by plugin means the pluggable.php should have been loaded prior to plugins. But the Diagram link shows in reverse order. – A.C.Balaji Jan 17 '12 at 16:48
The order takes place as expected. See updated answer. – Chip Bennett Jan 17 '12 at 17:12
Thank you Chip Bennett, I got some idea now. – A.C.Balaji Jan 17 '12 at 17:19
Each function definition in pluggables is preceded with an if(!function_exists('{function name}') { check. WordPress checks to see if you've manually defined any of these functions in your own plugins before defining them on its own. – EAMann Jan 17 '12 at 17:32
@EAMann Thank you EAMann, Now I'm very clear about my question now that, example, if the plugin defines the function wp_set_current_user, then in pluggable.php, wp_set_current_user won't be defined as if ( !function_exists('wp_set_current_user') ) :, Am I right ? – A.C.Balaji Jan 17 '12 at 17:48

Don't use pluggable functions!

Please note that you can never be sure, that a later plugin doesn't override your pluggable! I wrote on wp-hackers mailing list about this some time ago.

There's also another thread on wp-hackers that talks about that there's no fallback implemented. Please also read the related trac ticket.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.