[ad_1]
In the main plugin file, the callback function of the hook has to be like the below if I’m using namespace:
namespace test;
add_action('admin_menu', __NAMESPACE__ . '\function_name');
But why if I include a file called load.php on the main plugin file, and it works like normal without mentioning the __NAMESPACE__?
So it looks like this on the main plugin file now:
require_once __DIR__ . '/includes/load.php';
The load.php looks like the below and it works:
namespace test;
add_action('admin_menu', 'function_name')
But why if I use the exact same code from load.php on the main plugin file and it won’t work until I make it like:
namespace test;
add_action('admin_menu', __NAMESPACE__ . '\function_name');
