frozzare/wp-content-menu

为 WordPress 管理员添加内容菜单

安装数: 1,264

依赖项: 0

建议者: 0

安全: 0

星标: 8

关注者: 2

分支: 0

开放问题: 0

类型:wordpress-plugin

v1.0.4 2017-02-14 12:19 UTC

This package is auto-updated.

Last update: 2024-08-29 03:16:06 UTC


README

Build Status No Maintenance Intended

该插件向 WordPress 管理员添加内容菜单,使所有用于内容的帖子类型可以在此处存在。在执行此操作时,配置为使用内容菜单的帖子类型将从管理员菜单中删除。如果您有很多帖子类型,您将看到比之前更干净的行政菜单。

默认情况下,postpage 都将被移动到内容菜单,可以通过 content_menu_post_types 过滤器取消移动。

当选择帖子类型时,内容菜单将只显示子菜单项,因此您可以看到并使用该帖子类型的子菜单项,如第二张截图所示。

安装

composer require frozzare/wp-content-menu

用法

要将帖子类型移动到内容菜单,您可以在 register_post_type 中将 content_menu 设置为 true 或使用 content_menu_post_types 过滤器。

// With `register_post_type`
register_post_type( 'book', [
  'content_menu' => true
] );

// With the filter.
add_filter( 'content_menu_post_types', function ( $post_types ) {
  return ['page', 'post', 'book']
} );

您可以通过 content_menu_add_new_item_label 过滤器修改 添加新书籍 标签。

add_filter( 'content_menu_add_new_item_label', function ( $label ) {
  return 'Add New';
} );

为用户禁用内容菜单

add_filter( 'content_menu_user_allowed', function ( $allowed, $user ) {
  return false;
}, 10, 2 );

屏幕截图

贡献

欢迎每个人通过补丁、错误修复和新功能来做出贡献。

许可

MIT © Fredrik Forsmo