namespace not working correctly
-
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');
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘namespace not working correctly’ is closed to new replies.