Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 days ago.
Improve this questionif ( !function_exists( 'my_function' ) ) {
// do function
}
I'm not sure why, but it never occurred to me before to make a theme fully pluggable so that it's easier for people to customize with a child theme.
That's obviously an upside, but are there any downsides, other than more code? Does it make loading noticeably slower? Does it break anything or cause any other quirks? Are there any functions that can't or shouldn't be made pluggable?
Closed. This question is opinion-based. It is not currently accepting answers.Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 days ago.
Improve this questionif ( !function_exists( 'my_function' ) ) {
// do function
}
I'm not sure why, but it never occurred to me before to make a theme fully pluggable so that it's easier for people to customize with a child theme.
That's obviously an upside, but are there any downsides, other than more code? Does it make loading noticeably slower? Does it break anything or cause any other quirks? Are there any functions that can't or shouldn't be made pluggable?
The right way to do this would be
function my_function() {
$my_data = apply_filters('my_filter', $my_data);
return $my_data;
}
Anyone who wants to override your function can then do so by hooking to my_filter
without having to worry about whether their file is executed before yours.