我会用钩子before_delete_post
作为防止删除的最后一层保护(使用@tf的解决方案,这是正确的答案)。
并首先删除;删除;可视选项。下面隐藏了批量操作和清空垃圾桶按钮,并永久删除行操作。
使用此代码:
add_action( \'admin_head-edit.php\', \'hide_delete_css_wpse_92155\' );
add_filter( \'post_row_actions\', \'hide_row_action_wpse_92155\', 10, 2 );
add_filter( \'page_row_actions\', \'hide_row_action_wpse_92155\', 10, 2 );
function hide_delete_css_wpse_92155()
{
if( isset( $_REQUEST[\'post_status\'] ) && \'trash\' == $_REQUEST[\'post_status\'] )
{
echo "<style>
.alignleft.actions:first-child, #delete_all {
display: none;
}
</style>";
}
}
function hide_row_action_wpse_92155( $actions, $post )
{
if( isset( $_REQUEST[\'post_status\'] ) && \'trash\' == $_REQUEST[\'post_status\'] )
unset( $actions[\'delete\'] );
return $actions;
}
结果如下:
有趣的注意事项
没有挂钩
cpt_row_actions
. 挂钩
page_row_actions
和
post_row_actions
是
applied if the post type is hierarchical or not, 分别地