Why are there `function_exists` in `wc-conditional-functions.php`?
-
My question is that what is the intended purpose of wrapping almost all function in
wc-conditional-functions.php
in afunction_exists
conditional?First I thought I’ll be able to override these in my theme, just like many other functions in WooCommerce wrapped in
function_exists
clauses, but it turns out that this file is loaded on plugin load basically meaning that only MU plugins could ever reliably override these, as other plugins may or may not be loaded before WooCommerce, and theme files are always loaded after.I’ve traced back the wrapping in conditionals to here: https://github.com/woocommerce/woocommerce/commit/730e21fdbc998137bbfdf0951fae7c614f14033d but the commit message only state the obvious.
I guess the explanation is that 14 years ago the way WordPress worked and plugins were loaded could be different, and these conditional checks just stayed there, but looking from today’s perspective they don’t serve any real purpose I guess, right?
It would be nice to be able to override these from a theme for special use-cases, that’s how I had to see this is not really possible, despite what the conditional checks would suggest.
Also, shouldn’t these be deprecated at some point?
- You must be logged in to reply to this topic.