I think I worked out the problem.
before_wp_tiny_mce_action
is not an action hook called before the actual TinyMCE editor in the DOM. It is called before the script that is loaded via the admin_print_footer_scripts
action. So I think the admin_footer
action hook is before the before_wp_tiny_mce_action
action hook so I am calling my action too late.
I am going to have to find another way of detecting if a page has TinyMCE on it before it starts writing the script.