您可以使用add_filter()
对于post_row_actions
要筛选出您不想要的函数,请添加您想要的函数。像这样:
<?php
/** Plugin Name: (wpse) Draft vs. Trash Posts */
add_filter( \'post_row_actions\', \'my_plugin_update_actions\', 10, 2 );
function my_plugin_update_actions($actions, $post) {
$capability = \'promote_users\';
$role = \'Administrator\';
// Choose what you want to check against. Better only use one: Capability *or* role.
if (
current_user_can( $capability )
OR current_user_has_role( $role )
) {
unset($actions[\'trash\']);
$actions[\'draft\'] = \'<a class="submitdelete" title="Move this item to drafts" href="\'.admin_url(\'post.php?post=\'.$post->ID.\'&action=draft\').\'">Move To Draft</a>\';
}
return $actions;
}
这应该会让你朝着正确的方向开始。