不幸的是,在WP3中,这种情况似乎发生了很大的变化。5当他们升级媒体库时。该过滤器的$form\\u fields参数不再包含默认值。到目前为止,我找到的唯一解决方案是使用缓冲从视图中强制删除标记:
这是非常脆弱的-对WordPress核心的任何更改都可能破坏这一点
function wpse45562_remove_media_fields( $buffer ) {
// remove the \'caption\' block
$buffer = preg_replace( \'~<p>\\s*<label\\s*for="attachment_caption">.*?</p>~ims\', \'\', $buffer );
// remove the \'alt text\' block
$buffer = preg_replace( \'~<p>\\s*<label\\s*for="attachment_alt">.*?</p>~ims\', \'\', $buffer );
// remove the \'description\' box (and label separately)
$buffer = preg_replace( \'~<div\\s*id="wp-attachment_content-editor.*?</div>~ims\', \'\', $buffer );
$buffer = preg_replace( \'~<label\\s*for="content">.*?</label>~ims\', \'\', $buffer );
return $buffer;
}
function wpse45562_media_strip_buffer_start() { ob_start("wpse45562_remove_media_fields"); }
function wpse45562_media_strip_buffer_end() { ob_end_flush(); }
add_action(\'admin_head\', \'wpse45562_media_strip_buffer_start\', 10, 1);
add_action(\'admin_footer\', \'wpse45562_media_strip_buffer_end\', 10, 1);