I am just starting out of writing a fundamental MVC WordPress wordpress plugin development framework, and I am recognizing I am going to possess a naming conflict problem. If I wish to include this framework in some of the plug ins and/or styles I am developing, eventually I am likely to encounter an problem that class_is available() is not likely to solve.

I possibly could produce the framework like a stand-alone wordpress plugin, but that will require anybody who downloaded among my plug ins or styles also to download the framework, which does not appear realistic (specifically for upgrades to existing plug ins that do not have this type of dependency presently).

Anyway, I believed a lot of you available have most likely encounter the issues, and that i wanted to ascertain if anybody acquired a great technique to manage the issue.

If at all possible, I do not things to need to have a unique prefix per wordpress plugin (which will making upgrading the framework a nightmare). I am wishing there's some clever method to dynamically title all these classes without needing to hard code it.

Namespace can resolve your condition.


Apologies towards the asker because of not getting this right the very first time. The Luc is appropriate. Namespace is the greatest option.


Some frameworks decide to put instructions before their class names to prevent conflicts. Yii just buts C in-front like:

class CClassName 

The answer I wound up selecting was to produce a bootstrap.php file, have each demonstration of the framework register (inside a global variable) what version it's and it is file path. I Quickly register an action to operate in the end plug ins/theme are loaded which compares all versions and just loads the classes connected most abundant in recent version.

The only real downside I look into this really is that I'd need to make certain my framework is backwards compatible, however i planned on doing that anyway.

This is actually the code I made use of during my bootstrap file. Clearly the version number in every demonstration of the framework will have to match the version quantity of the framework incorporated.

// register this version of the framework
$GLOBALS['pw_framework_meta']['0.1.2'] = __FILE__;

if ( !function_exists('pw_framework_init') ) {

     * Sort the $GLOBALS['pw_framework_meta'] variable for the latest registered
     * version of the framework. Include the PW_Framework.php file and then call init()
    function pw_framework_init()
        // get all the different versions registered with $GLOBALS['pw_framework_meta']
        $versions = $GLOBALS['pw_framework_meta'];

        // sort the versions
        uksort($versions, 'version_compare');

        // get the latest versions (the last in the array)
        $latest = end($versions);

        if ( !class_exists('PW_Framework') ) {
            require_once( dirname($latest) . '/PW_Framework.php' );

    // register pw_framework_init() with the 'after_setup_theme' hook
    // This way we can ensure that all plugins or themes that might be using PW_Framework
    // have had a chance to register with the $GLOBALS['pw_framework_meta'] variable
    add_action( 'after_setup_theme', 'pw_framework_init' );