我在WP 5中实现此功能的唯一方法是安装Classic Editor.
那我可以用media_view_settings 添加选项卡。
add_filter(\'media_view_settings\', \'addMediaTab\');
function addMediaTab($settings) {
$settings[\'tabs\'] = array(\'mymediatab\' => \'My Media Tab\');
return $settings;
}
但新的UI似乎没有包括古腾堡中的这些部分,如果使用经典编辑器,最终会得到类似的结果。
You can also do this with JS.
var Library = wp.media.controller.Library;
var oldMediaFrame = wp.media.view.MediaFrame.Post;
wp.media.view.MediaFrame.Post = oldMediaFrame.extend({
initialize: function () {
oldMediaFrame.prototype.initialize.apply(this, arguments);
var options = this.options;
this.states.add([
new Library({
id: \'inserts\',
title: \'My New Tab\',
priority: 20,
toolbar: \'main-insert\',
filterable: \'all\',
library: wp.media.query(options.library),
multiple: false,
editable: false,
library: wp.media.query(_.defaults({
newtab: \'newtab\',
}, options.library)),
displaySettings: true,
displayUserSettings: true
}),
]);
},
});
More Info
Ticket with more info about Media_upload_tabs & WP5
JS Demo Example