themehybrid / hybrid-core

Official repository for the Hybrid Core WordPress development framework.
GNU General Public License v2.0
689 stars 144 forks source link

Cross-Project Tracking: function_exists() Checks #185

Open justintadlock opened 3 years ago

justintadlock commented 3 years ago

Because we intend to allow HC and its sub-projects to be bundled with multiple projects (see: https://github.com/themehybrid/hybrid-core/issues/183), we need to account for the repos with functions (not just classes). The easiest way to do this is to wrap each function with a function_exists() check like so:

if ( ! function_exists( __NAMESPACE__ . '\\func_name' ) ) {
// Function
}

Long term, we might consider phasing out functions with a static helper class instead. That way, the class autoloader bypasses the issue (file autoloading doesn't).