Functions unable to load the $page object

Here’s mine (also very hackish and not reliable in all cases):

$site = site();
$site->visit(kirby()->path());
$page = $site->page();