Why are certain functions pluggable (overrideable) in WordPress core and others not? (I note on the Codex page regarding Pluggable Functions no more are to be added in favour of filter usage.)
But theoretically, would there be any security implications or other concerns for having them all pluggable - or is it simply so less pluggable code becomes incompatible with core updates?
Why are certain functions pluggable (overrideable) in WordPress core and others not? (I note on the Codex page regarding Pluggable Functions no more are to be added in favour of filter usage.)
But theoretically, would there be any security implications or other concerns for having them all pluggable - or is it simply so less pluggable code becomes incompatible with core updates?
Share Improve this question edited May 5, 2019 at 9:15 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked May 5, 2019 at 4:51 majickmajick 5,1412 gold badges18 silver badges30 bronze badges 2- Can you maybe link the exact resource where you read that? Would like to read it. – norman.lol Commented May 5, 2019 at 7:16
- 1 @leymannx "Pluggable functions are no longer being added to WordPress core. All new functions instead use filters on their output to allow for similar overriding of their functionality." codex.wordpress/Pluggable_Functions – majick Commented May 6, 2019 at 10:38
1 Answer
Reset to default 2Pluggable functions are less elastic than filters/actions.
You can have only one pluggable function “active” - so only one plugin can override the core function. And you don’t have much control over which plugin will it be (WP will use the pluggable function that gets defined first).
So it won’t be very useful if all actions were replaced by pluggable functions.
On the other hand, there are some cases that using pluggable functions may have some sense. wp_mail is great example, I guess. If you want to change the way the emails are sent - you can. But you still want only one such function (otherwise, if you install two plugins that are changing it, you can end with multiple emails sent for every wp_email call).
So it makes sense to use pluggable, whenever it is critical to perform an action only once, but you still want to be able to modify what action is performed exactly.