Cannot pass variable to page definition

You called:

add_submenu_page( 'tools.php', 'STL Update', 'STL Update', 'manage_options', 'update_live', ['stl_page', 'stagingSite' => $stagingSite]);

Note that the 6th parameter you passed was ['stl_page', 'stagingSite' => $stagingSite] which is not a callable type, and a callable is expected.

callable can be:

  • 'function_name'
  • [ $object, 'method_name' ]
  • [ 'class', 'static_method_name' ]
  • function() { /* I'm a lambda/closure/anonymous function yay */ }

In your case it expected the second thing in the array to be a string containing a function name, instead it got this:

'stagingSite' => $stagingSite

and had no idea what to do with it. It doesn’t make a lot of sense, especially since the admin_menu action doesn’t pass a parameter, so there will never be a $stagingSite.

So remove the $stagingSite argument in your function, and pass a proper callable value telling WP what to call to display that submenu page.

As a sidenote, I suspect you did this to pass a variable through to the function, you can’t do that via callables, nor should you need to in this scenario