首先,有必要更改JavaScript,以便在请求中包含post\\u id:
jQuery(document).ready(function() {
jQuery(\'#pc_extContent_button\').click(function() {
var pID = jQuery(\'#post_ID\').val();
formfield = jQuery(\'#pc_extContent\').attr(\'name\');
tb_show(\'premiumTB\', \'media-upload.php?post_id=\'+ pID +\'&type=image&TB_iframe=true\');
return false;
});
window.send_to_editor = function(html) {
imgurl = jQuery(\'img\', html).attr(\'href\');
jQuery(\'#pc_extContent\').val(imgurl);
tb_remove();
}
});
然后可以在函数中使用贝氏网的解。php(或类似)
function remove_media_library_tab($tabs) {
if (isset($_REQUEST[\'post_id\'])) {
$post_type = get_post_type($_REQUEST[\'post_id\']);
if (\'premium\' == $post_type) {
unset($tabs[\'library\']);
unset($tabs[\'type_url\']);
}
}
return $tabs;
}
add_filter(\'media_upload_tabs\', \'remove_media_library_tab\');
因此,所有这些都可以很好地协同工作,并且选项卡被移除。