跳到内容
新问题

对这个项目有疑问吗?注册一个免费的GitHub帐户以打开一个问题,并联系其维护者和社区。

单击“注册GitHub”,表示您同意我们的服务条款隐私声明。我们偶尔会向您发送与帐户相关的电子邮件。

已经在GitHub上了?登录到您的帐户

编辑器:使用canUser()检查删除操作扩展PostTrashCheck #23174

已合并
将1个提交合并到 2020年6月22日

对话

海洋90
复制链接
成员

@海洋90 海洋90 评论2020年6月15日

描述

修复 #23144.

这是一个不需要新版本的版本操作-删除对资源的操作。

这是如何测试的?

  • 创建仅具有阅读编辑_文章能力
  • 创建一个新帖子,注意不再有垃圾链接。

对于测试,您可以使用WP-CLI创建一个角色为“author_only_edit”的用户“author”,该角色只能创建/编辑草稿文章。

npx wp-env运行cli wp角色创建author_only_edit AuthorOnlyEditnpx wp-env运行cli wp-cap添加author_only_edit读取edit_postsnpx wp-env运行cli wp用户创建作者author@example.comnpx wp-env运行cli wp用户set-roleauthor@example.com作者仅编辑

屏幕截图

变更类型

错误修复

检查清单:

  • 我的代码已经过测试。
  • 我的代码遵循WordPress代码风格。
  • 我的代码遵循可访问性标准。
  • 我的代码有适当的内联文档。
  • 如果合适的话,我已经包括了开发人员文档。
  • 我已经更新了所有受此PR中任何重构/重命名影响的React Native文件。

@海洋90 海洋90补充[类型]Bug 现有功能无法按预期工作 [Package]编辑器 /包/编辑器标签2020年6月15日
@github-操作
复制链接

github-操作 机器人程序 评论2020年6月15日

尺寸变化:+77亿(0%)

总大小:1.13 MB

文件名 大小 更改
build/editor/index.js 44.8千字节 +77亿(0%)
ℹ️查看未更改
文件名 大小 更改
构建/a11y/index.js 1.14千字节 0亿
构建/注释/index.js 3.62千字节 0亿
构建/api-fetch/index.js 3.4千字节 0亿
构建/auto/index.js 2.83千字节 0亿
构建/blob/index.js 620亿 0亿
build/block-directory/index.js 7.27千字节 0亿
构建/块目录/样式-rtl.css 892磅 0亿
构建/块目录/样式.css 892亿 0亿
build/block-editor/index.js 106千字节 0亿
构建/块编辑器/style-rtl.css 12.1千字节 0亿
构建/块编辑器/样式.css 12.1千字节 0亿
build/block-library/editor-rtl.css 7.88千字节 0亿
build/block-library/editor.css 7.89千巴 0亿
build/block-library/index.js 129千字节 0亿
build/block-library/style-rtl.css 7.96千字节 0亿
build/block-library/style.css 7.96千字节 0亿
构建/块库/theme-rtl.css 684亿 0亿
构建/块库/theme.css 686亿 0亿
构建/块序列化默认解析器/index.js 1.88千字节 0亿
build/block-serialization-specifi-parser/index.js 3.1千字节 0亿
build/blocks/index.js 48.1千字节 0亿
build/components/index.js 195千字节 0亿
build/components/style-rtl.css 19.5千字节 0亿
构建/组件/样式.css 19.5千字节 0亿
构建/合成/索引.js 9.32千字节 0亿
构建/core-data/index.js 11.4千字节 0亿
构建/数据控制/索引.js 1.29千字节 0亿
build/data/index.js 8.44千字节 0亿
构建/日期/索引.js 5.47千字节 0亿
build/deprecated/index.js 772亿 0亿
build/dom-ready/index.js版本 568亿 0亿
build/dom/index.js版本 3.17千字节 0亿
构建/编辑导航/index.js 8.26千字节 0亿
构建/编辑导航/样式-rtl.css 975亿 0亿
构建/编辑导航/样式.css 974亿 0亿
build/edit-post/index.js 302千字节 0亿
构建/编辑-发布/样式-rtl.css 5.6千字节 0亿
构建/编辑-发布/样式.css 5.6千字节 0亿
build/edit-site/index.js 16.6千字节 0亿
构建/编辑site/style-rtl.css 2.96千字节 0亿
构建/编辑site/style.css 2.96千字节 0亿
build/edit-widgets/index.js 9.34千字节 0亿
build/edit-widgets/style-rtl.css 2.4千字节 0亿
构建/编辑小部件/style.css 2.4千字节 0亿
build/editor/editor-styles-rtl.css 423亿 0亿
构建/编辑器/编辑器样式.css 423亿 0亿
构建/编辑器/样式-rtl.css 4.26千字节 0亿
构建/编辑器/样式.css 4.27千字节 0亿
构建/元素/索引js 4.64千字节 0亿
构建/转义-html/index.js 733亿 0亿
build/format-library/index.js 7.72千字节 0亿
build/format-library/style-rtl.css 502亿 0亿
构建/格式库/样式.css 502亿 0亿
build/hooks/index.js 2.13千字节 0亿
build/html-entities/index.js 622亿 0亿
build/i18n/index.js版本 3.56千字节 0亿
build/浅等于/index.js 710亿 0亿
构建/键盘快捷方式/index.js 2.51千字节 0亿
build/keycodes/index.js 1.94千字节 0亿
build/list-reasable-blocks/index.js 3.13千字节 0亿
构建/list-rusable-blocks/style-rtl.css 226亿 0亿
build/list-rusable-blocks/style.css 226亿 0亿
build/media-utils/index.js 5.29千字节 0亿
build/notices/index.js 1.79千字节 0亿
构建/nux/index.js 3.4千字节 0亿
build/nux/style-rtl.css 616亿 0亿
build/nux/style.css 613亿 0亿
build/plugins/index.js 2.56千字节 0亿
build/primitives/index.js 1.5千字节 0亿
构建/priority-queue/index.js 789亿 0亿
build/redux-routine/index.js 2.85千字节 0亿
构建/rich-text/index.js 14千字节 0亿
build/server-side-render/index.js 2.68千字节 0亿
build/shortcode/index.js 1.7千字节 0亿
构建/token-list/index.js 1.28千字节 0亿
构建/url/index.js 4.06千字节 0亿
build/viewport/index.js 1.85千字节 0亿
build/warning/index.js 1.14千字节 0亿
构建/wordcount/index.js 1.17千字节 0亿

压缩尺寸作用

复制链接
贡献者

@你知道riad 你知道riad 留下了评论

选择隐藏此评论的原因

将显示原因,以便向其他人描述此评论。了解更多信息.

代码看起来不错。你知道我们如何轻松测试吗?我如何创建这样的用户?

const{getPostType,canUser}=select('core');
常量postId=getCurrentPostId();
const postType=获取postType(getCurrentPostType);
const资源=postType?。[“rest_base”]||'';
复制链接
贡献者

选择隐藏此评论的原因

将显示原因,以便向其他人描述此评论。了解更多信息.

Nit:我本应该避免使用这个临时变量,只在检查行27中使用postType。

复制链接
成员 作者

选择隐藏此评论的原因

将显示原因,以便向其他人描述此评论。了解更多信息.

嗯,资源在第27行中使用了两次。还是意味着这样做?

postId和postType?canUser('delete',postType['rest_base'],postId):false,

复制链接
贡献者

选择隐藏此评论的原因

将显示原因,以便向其他人描述此评论。了解更多信息.

是的,这正是我的意思。不过,这只是一个非常小的细节,并不重要。

@海洋90
复制链接
成员 作者

我如何创建这样的用户?

@你知道riad我用四个WP-CLI命令扩展了描述,以创建用于测试的角色和用户。

复制链接
贡献者

@你知道riad 你知道riad 留下了评论

选择隐藏此评论的原因

将显示原因,以便向其他人描述此评论。了解更多信息.

👍

免费注册 在GitHub上加入此对话.已经有账户了吗?登录以发表评论
标签
[Package]编辑器 /包/编辑器 [类型]Bug 现有功能无法按预期工作
项目
还没有
开发

成功合并此拉取请求可能会解决这些问题。

如果当前用户无法删除帖子,则不显示“移至垃圾箱”链接
2名参与者