我注意到,自WP 3.5以来,我们现在有了主干。js和下划线。包括js库。新的媒体模式使用下划线模板,我想知道如何插入它们,尤其是在管理方面。是否有正确的方法插入这些?
在WordPress中使用下划线模板
1 个回复
最合适的回答,由SO网友:Eugene Manuilov 整理而成
您的插件索引文件:
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\'}));
}
});
结束