No, there isn’t. Unless there’s an apply_filters()
call, you can’t modify any of the output.
You mentioned “the only hook is to the entire function”, but that’s not the case either. There is a do_action()
call at the end, but this is an action hook, so it only lets you run something at the end of the function. It doesn’t let you modify the output.
To replace the wp_print_media_templates
function you would need to perform a number of steps:
- Copy the entire function to a new function in your theme or a plugin.
- Add a callback to the
wp_enqueue_media
action hook that removeswp_print_media_templates
from the default hooks. - Inside that
wp_enqueue_media
callback, add your copied version of the function to the same hooks in place ofwp_print_media_templates
.
But this introduces a number of issues:
- The JavaScript that powers the media library is expecting the HTML added by the original hook. If you modify this there’s a chance that you’ll break this JavaScript by moving or removing elements that are expected by the script.
- You’re now on the hook to keep your copy of the function up to date with any changes made by future WordPress versions. If you don’t you may miss out on new features or cause the above issue by failing to add/change/remove elements that might be expected by updates to the script in WordPress.