您的插件索引文件:
add_action( \'print_media_templates\', \'wpse8170_admin_footer\' );
function wpse8170_admin_footer() {
require \'templates.php\';
}
您的模板。php:
<script id="tmpl-mytemplate" type="text/html">
<h1>Hello {{data.name}}!</h1>
</script>
您的媒体js文件:
wp.media.view.MyView = wp.media.View.extend({
template: wp.media.template(\'mytemplate\'),
render: function() {
this.$el.html(this.template({name: \'world\'}));
}
});