I need to get logged in user id inside my plugin.
Is this the proper way?
$root = dirname(dirname(dirname(dirname(__FILE__))));
if (file_exists($root.'/wp-load.php')) {
require_once($root.'/wp-load.php');
}
$user_id = get_current_user_id();
Otto saying that we shouldn't load wp-load.php file since we have no idea where wp-load.php file located and it doubles the server load.
So I'm really confused.
And one more question..
According to that image wp-load.php loaded before all the plugins. So why all plugin authors include that file again?