Is there a way to override only a portion of the function print_media_templates defined in wp-includes\media-template.php?

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:

  1. Copy the entire function to a new function in your theme or a plugin.
  2. Add a callback to the wp_enqueue_media action hook that removes wp_print_media_templates from the default hooks.
  3. Inside that wp_enqueue_media callback, add your copied version of the function to the same hooks in place of wp_print_media_templates.

But this introduces a number of issues:

  1. 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.
  2. 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.

deneme bonusudeneme bonusu veren sitelerpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casino