I’m trying to load JS for the entire WordPress admin area, but while it DOES load on admin pages, it never executes except on the post-edit page (…/post.php). There seems to be some mechanism stopping execution of Sage-built JS except on the post-edit page or something?
(Sage has pre-installed the editor.js script for the post-edit page, so I wonder if Sage was hard-coded to only run JS on that particular admin page?)
Here is my code:
function enqueue_admin_scripts( $hook ): void {
wp_enqueue_script( 'admin-script', get_template_directory_uri() . '/public/js/admin_script.js', [], '1.0', TRUE );
}
add_action( 'admin_enqueue_scripts', 'enqueue_admin_scripts' );
add_action( 'wp_enqueue_scripts', 'enqueue_admin_scripts' ); // for testing
My JavaScript file simply contains a console.log(), which shows on post-edit pages and on the front-end pages, but nowhere else in admin pages.
How can I get my JavaScript to load AND RUN on all admin pages?