我发现以下方法效果最好。。。在编辑器页面(metabox链接)中单击“添加特色图像”时,“媒体管理器”中缺少“插入帖子”选项和您提到的所有选项。这对我来说太完美了,因为我想删除用户在帖子中插入图像的选项。如果这是您想要的,请将此代码放在主题的函数中。php文件。。。
/**
* Removes "image edit" option from Media Manager.
*/
add_action( \'admin_footer-post-new.php\', \'wpse_76214_script\' );
add_action( \'admin_footer-post.php\', \'wpse_76214_script\' );
function wpse_76214_script() {
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$( \'li.attachment\' ).live( \'click\', function( event ) {
$( \'.media-sidebar a.edit-attachment\' ).remove(); // remove edit image link
});
} );
</script>
<?php
}
/**
* Removes "Add Media" Button from the editor.
*/
function z_remove_media_controls() {
remove_action( \'media_buttons\', \'media_buttons\' );
}
add_action(\'admin_head\',\'z_remove_media_controls\');
/**
* Takes over the "Featured Image" meta box and allows you to change its options.
*/
add_action(\'do_meta_boxes\', \'change_image_box\');
function change_image_box()
{
remove_meta_box( \'postimagediv\', \'post\', \'side\' );
remove_meta_box( \'postimagediv\', \'page\', \'side\' );
// if you have other post types, remove the meta box from them as well
// remove_meta_box( \'postimagediv\', \'YOUR-POST-TYPE-HERE\', \'side\' );
add_meta_box(\'postimagediv\', __(\'Add Images\'), \'post_thumbnail_meta_box\', \'post\', \'side\' );
add_meta_box(\'postimagediv\', __(\'Add Images\'), \'post_thumbnail_meta_box\', \'page\', \'side\' );
// if you have other post types, add the new meta box for them as well
// add_meta_box(\'postimagediv\', __(\'Add Images\'), \'post_thumbnail_meta_box\', \'YOUR-POST-TYPE-HERE\', \'side\' );
}
/**
* Renames Feature Image Link that appears inside meta box.
*/
add_action(\'admin_head-post-new.php\',change_thumbnail_html);
add_action(\'admin_head-post.php\',change_thumbnail_html);
function change_thumbnail_html( $content ) {
add_filter(\'admin_post_thumbnail_html\',do_thumb);
}
function do_thumb($content){
return str_replace(__(\'Set featured image\'), __(\'Add Images and Set Featured\'),$content);
}
用户现在只能通过单击元框中的链接来添加图像,元框现在名为“添加图像”此外,元框内的链接已更改,以避免混淆。希望这有帮助!