Question

I would like to override this plugin class in child theme :

class-config.php

namespace um;

if ( ! defined( 'ABSPATH' ) ) exit;

if ( ! class_exists( 'um\Config' ) ) {


    /**
     * Class Config
     *
     * Class with global variables for UM
     *
     * @package um
     */
    class Config
    {
        //some code here...
    }
    //end class
}

But as you can see, this class uses a namespace, so I can't just write this in my functions.php :

functions.php

class Config
{
    //some new code here...
}

I tried to add namespace um; in functions.php but of course it doesn't work.

Does anybody have an idea ? :)

Was it helpful?

Solution

I found it ! :)

I just created another file called class-config-new.php just next to functions.php. I wrote my class in class-config-new.php and added the namespace, and I added a require_once in functions.php to call the file.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top