I notice that in some plugins you can override functions by …
- Creating an uploads folder
- Creating a folder with the plugin name
-
Using the following code
if (!function_exists('function_name')) { function function_name() { } }
Is this standard for all WordPress plugins or only if they’re written in a specific way?
If the plugin displays content via any function, the code:
… is used for safety.
If your plugin is disabled, and the
if (!function_exists('function_name'))
is missing, your theme will throw a fatal error.These are referred to as pluggable functions, and are intended to be able to be over-ridden, either by Plugins, Themes, or Child Themes.
It is only standard for functions that are intended to be over-ridden – and, generally speaking, the better practice is to add filter hooks to function outputs, rather than making functions pluggable.