In the second version you’re running your code as a wp_enqueue_scripts hook. This is for frontend scripts and isn’t called in the admin site. For that you need to hook admin_enqueue_scripts as well:
add_action( 'wp_enqueue_scripts', 'boatTheBusForOutdoorAccess_register_url');
add_action( 'admin_enqueue_scripts', 'boatTheBusForOutdoorAccess_register_url');
That said, it might be simpler to just include your admin scripts based on is_admin()
if ( is_admin() && ! wp_doing_ajax() ) {
require_once dirname( __FILE__ ) . '/inc/annualReportFunctions.php';
}
It looks like you’re trying to only load page-specific PHP on the right pages: I don’t know how much that would really help (I think modern PHP runtimes have opcode caches etc.) but for the admin site at least I don’t think it’s worth worrying about and you might as well load all admin functions always there.
(Also note that you can use __DIR__
for the path: dirname( __FILE__ )
is for compatibility with old PHPs that WordPress no longer supports anyway.)