是否可以删除自定义帖子类型的快速编辑功能?
我有14个自定义分类法,每个分类法中有数百个术语,要将它们全部加载到页面的源代码中需要花费太多的时间和资源。
我试图用google找到一个解决方案,但大多数都只是隐藏了“快速编辑”按钮,但代码是由wordpress加载到页脚的,因此没有什么区别。
是否可以删除自定义帖子类型的快速编辑功能?
我有14个自定义分类法,每个分类法中有数百个术语,要将它们全部加载到页面的源代码中需要花费太多的时间和资源。
我试图用google找到一个解决方案,但大多数都只是隐藏了“快速编辑”按钮,但代码是由wordpress加载到页脚的,因此没有什么区别。
查看builk actions page 在法典中。我相信取消设置的正确操作是内联的。这将删除“编辑”批量操作,实际上是快速编辑。
<?php
function remove_bulk_actions( $actions ){
unset( $actions[\'inline\'] );
return $actions;
}
add_filter(\'bulk_actions-custom_post_type_slug\',\'remove_bulk_actions\');
?>
对于每行中的快速编辑,请查看manage_{$post_type}_columns, 因为您可以用自己的标题栏替换标题栏,并按照自己的意愿呈现标题栏。中当前没有要删除快速编辑的筛选器WP Posts List Table, 因此,如果替换列不起作用,则需要创建自己的列WP list table extension (很棒的教程)。要澄清Eric的帖子add_filter
代码需要具有screenid
在自定义post类型slug之前。最常见的生物bulk_actions-edit-custom_post_type_slug
.
而且unset( $actions[\'inline\'] )
似乎不是选项。
二者都unset( $actions[\'edit\'] )
和unset( $actions[\'trash\'] )
是我能找到的全部。
最后,此代码删除批量选项下拉菜单项,它不会删除;“快速编辑”;将鼠标悬停在帖子上时显示的选项。
function ssp_remove_member_bulk_actions( $actions, $post ){
unset( $actions[\'edit\'] );
return $actions;
}
add_filter(\'bulk_actions-edit-member\',\'ssp_remove_member_bulk_actions\', 10, 2);
THIS CODE Removes Quick Edit (thanks to jfacemyer)
function remove_quick_edit( $actions, $post ) {
unset($actions[\'inline hide-if-no-js\']);
return $actions;
}
add_filter(\'post_row_actions\',\'remove_quick_edit\',10,2);
You can also turn off:
<编辑=unset($actions[\'edit\']);
unset($actions[\'trash\']);unset($actions[\'view\']);To remove everything from the Quick Edit hover options:
function remove_quick_edit( $actions, $post ) {
unset($actions[\'edit\']);
unset($actions[\'trash\']);
unset($actions[\'view\']);
unset($actions[\'inline hide-if-no-js\']);
return $actions;
}
add_filter(\'post_row_actions\',\'remove_quick_edit\',10,2);
最后,您只能删除基于自定义帖子类型甚至用户功能的操作:// Based on Post Type
if ($post->post_type==\'myposttype\') {
unset($actions[\'edit\']);
}
// Based on User Capability
if ( current_user_can(\'manage_options\') ) {
unset($actions[\'edit\']);
}
接受的答案修改bulk edit 下拉列表,不是post rows.
您查找的筛选器位于wp-admin/includes/class-wp-posts-list-table.php
, 第1342行(WordPress 5.0.2):
/**
* Filters the array of row action links on the Posts list table.
*
* The filter is evaluated only for non-hierarchical post types.
*
* @since 2.8.0
*
* @param array $actions An array of row action links. Defaults are
* \'Edit\', \'Quick Edit\', \'Restore\', \'Trash\',
* \'Delete Permanently\', \'Preview\', and \'View\'.
* @param WP_Post $post The post object.
*/
$actions = apply_filters( \'post_row_actions\', $actions, $post );
这将起作用:/**
* This filter modifies "my_post_type" post rows,
* such as "Edit", "Quick Edit" and "Trash".
*
* @param $actions
* @param $post
*
* @return mixed
*/
add_filter(\'post_row_actions\', function($action, $post) {
if ($post->post_type == \'my_post_type\') {
// Remove "Quick Edit"
unset($actions[\'inline hide-if-no-js\']);
}
return $actions;
}, 10, 2);
我正在使用分类法图像插件,并试图对分类法进行排序,但分类法图像效果不佳。这项工作:$terms = get_terms( \'work_cat\', $args ); 但事实并非如此:$terms = apply_filters( \'taxonomy-images-get-terms\', \'\', $args ); 有什么想法吗?以下是完整的查询:<?php $args = array( \'taxonomy\' =>