我正在为“路由器菜单”添加一个按钮(在“媒体库”右侧添加一些内容),但系统是一样的。
<script type="text/javascript">
jQuery(window).on(\'load\', function() {
var media = window.wp.media,
Attachment = media.model.Attachment,
Attachments = media.model.Attachments,
Query = media.model.Query,
l10n = media.view.l10n = typeof _wpMediaViewsL10n === \'undefined\' ? {} : _wpMediaViewsL10n,
NewMenuItem;
jQuery(document).on( \'click\', \'.insert-media\', function( event ) {
var workflow = wp.media.editor.get();
var options = workflow.options;
if( undefined == NewMenuItem ) {
NewMenuItem = new wp.media.view.RouterItem( _.extend( options, { text: \'New Item!\' } ) );
workflow.menu.view.views.set( \'.media-menu\', NewMenuItem, _.extend( options, { add: true } ) );
}
});
});
</script>
现在,它还没有做任何事情。这是下一步!