-
Notifications
You must be signed in to change notification settings - Fork 6
Pluggable Functions
The UCF WordPress Theme is designed to be overridable by child themes with action and filter hooks and pluggable functions.
Unlike actions and filters, which let you modify content or perform actions within some part of a function, a pluggable function can be completely overridden by a plugin or child theme. For more information on how child theme overrides work, please see WordPress's documentation on child themes.
Use the wiki's sidebar navigation to view this theme's pluggable functions.
In this theme, all pluggable functions will be wrapped in a if ( ! function_exists() ) check.
Additionally, all functions declared in the UCF WordPress Theme, pluggable or not, will have a name prefixed with ucfwp_, so you'll know what functions are provided by the parent theme vs. other plugins.
Depending on what you're trying to modify, you may be able to either override a pluggable function entirely, or modify its behavior or returned value using an action or filter hook.
Generally speaking, if you can use a action or filter to achieve the result you're looking for, we recommend doing so in lieu of redefining a pluggable function. Just using a hook, as opposed to rewriting an entire function, will make it easier to keep up with updates to the UCF WordPress Theme in the future.
However, there may be certain scenarios where overriding a pluggable function would make more sense, e.g. for modifying custom layouts for compatible plugins. Overall, use your best judgment and consider how your modifications may be impacted by future parent theme updates.
Want to override a UCF WordPress Theme function in your child theme? Simply re-declare the function in your child theme's functions.php file. Because child themes are loaded before parent themes, your function will take precedence over the UCF WordPress Theme's version.
// Your child theme's functions.php
function ucfwp_some_pluggable_function() {
// Add whatever custom code you want to run in this function here
}Keep in mind that the function you're overriding is going to be referenced elsewhere in the parent theme, and expected to have a specific number of arguments and return a specific type of value (string, integer, boolean, etc). Your function overrides should use an identical number of arguments (if any), and should aim to return similarly typed values to avoid errors or conflicts in the parent theme.