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 ? :)
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 ? :)
Share Improve this question edited Oct 15, 2019 at 13:30 ArbreMojo asked Jan 25, 2019 at 15:04 ArbreMojoArbreMojo 191 silver badge9 bronze badges1 Answer
Reset to default 1I 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.