Pluggable functions are set of functions built into WordPress. These functions can do anything from getting the current user's information to generating hashes from strings to setting cookies. As a WordPress developer, you can use these in your plugins. All of the pluggable functions are included in wp-includes/pluggable.php. You can also find a list of them online at the Codex. If you look in the code--this is that WordPress track that's available online directly from the Codex site-- you can see before every function declaration there is a special if statement that looks to see if that function already exists or not.
If the function doesn't exist, it then declares it. If it does exist, it then ignores the declaration. This is precisely what makes these pluggable. What that means is these are functions that are used throughout the environment of WordPress that you have the ability to override and create your own versions of. If you create your own version, these will then exist, and it will not then declare its internal version--thus pluggable. Take, for example, the plugin that we worked on. We had a function called Cc Mail.
Cc Mail uses the PHP mail function to send out the mail. Well, let's say we want to send it through a universal mail application that was used within WordPress. There is one called wp mail, and if you click on it in the Codex, you'll see the format is very similar to PHP mail-- only we have the ability to override this. So maybe it's something we want to utilize. To change it, you simply use the function, because it's already included in the WordPress environment. WordPress has a set of built-in functions called pluggable functions.
These can be helpful when we need to use them. Simply find them in the pluggable PHP file, or here in WordPress Codex. They provide us with some special functionality that is not available everywhere within WordPress. What makes them pluggable is the ability to override them if we want to, and that new functionality will be used all throughout the WordPress environment.
Get unlimited access to all courses for just $25/month.Become a member