Inside the shortcode function for playlists, there is this line:
do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
Hooked into that is wp_playlist_scripts()
which hooks the templates into the footer:
add_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
add_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
So if you want to replace the templates, you can hook into wp_playlist_scripts
after those hooks have been added (so any priority greater than 10), remove the hooks, then hook in your own templates:
function wpse_296966_hook_new_playlist_templates() {
// Unhook default templates.
remove_action( 'wp_footer', 'wp_underscore_playlist_templates', 0 );
remove_action( 'admin_footer', 'wp_underscore_playlist_templates', 0 );
// Hook in new templates.
add_action( 'wp_footer', 'wpse_296966_underscore_playlist_templates', 0 );
add_action( 'admin_footer', 'wpse_296966_underscore_playlist_templates', 0 );
}
add_action( 'wp_playlist_scripts', 'wpse_296966_hook_new_playlist_templates', 20 );
Then you just need to copy the wp_underscore_playlist_templates()
function, in its entirety, to a new function in your theme/plugin called wpse_296966_underscore_playlist_templates()
(or whatever you want, just needs to match the add_action()
call. Then make any modifications you want to the function to get the markup you wanted.
I would avoid doing anything too drastic though, since the scripts likely depend on specific classes, and the general structure. But removing these unwanted characters shouldn’t be a problem.