Namespaces and plugin class

I’m starting using sage and stuck in a problem envolving namespaces. I have this function:

function scpt_blog() {
     if ( ! class_exists( 'Super_Custom_Post_Type' ) )

         $trabalhos = new Super_Custom_Post_Type();
add_action( 'after_setup_theme', __NAMESPACE__ . '\\scpt_blog' );

But it’s returning this error: Fatal error: Class ‘Roots\Sage\Extras\Super_Custom_Post_Type’ not found in…

This class is from a plugin called super-cpt. How can I point the namespace of this class correctly?

Probably like this:

if ( ! class_exists( '\\Super_Custom_Post_Type' ) )

$trabalhos = new \Super_Custom_Post_Type();

Since you can see in the error, it’s looking for the Super_Custom_Post_Type class in your current namespace.

Give this a read, under namespaces:

1 Like

Fixed! Thanks a lot.