Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardise capabilities for wp_template, wp_template_part and wp_global_styles #30893

Closed
wants to merge 6 commits into from

Conversation

carlomanf
Copy link

Description

Closes #30892

Although I have #27632 open as a more ambitious permissions prototype, there has not been much attention on it and it's unlikely to be ready for 5.8.

Accordingly, this branch is intended as a smaller target that just cleans up some code without changing behaviour.

At the moment, all three of the FSE post types use edit_theme_options as a blanket capability. However, all of them are doing this in different ways:

  • wp_template does a just-in-time update of the capability using the user_has_cap filter
  • wp_template_part uses the default post capabilities, and relies only on the REST API permissions check
  • wp_global_styles sets some of the capabilities directly on the post type object, but many of them are missing

This standardises all three post types to configure their capabilities in the same way.

How has this been tested?

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @carlomanf! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 16, 2021
@mtias mtias added [Block] Template Part Affects the Template Parts Block [Feature] Templates API Related to API powering block template functionality in the Site Editor Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Apr 19, 2021
@oandregal oandregal mentioned this pull request Apr 28, 2021
82 tasks
*
* @return array Default capabilities.
*/
function gutenberg_get_default_capabilities_for_fse() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function is not very useful as part of our public API so we should mark it as internal by saying In the comments that it is internal and prefixing it with "_".

Regarding the name I guess it can more specific _gutenberg_get_default_capabilities_for_fse_post_types.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended.

@carlomanf
Copy link
Author

Superseded by WordPress/wordpress-develop#1267

@carlomanf carlomanf closed this May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Feature] Templates API Related to API powering block template functionality in the Site Editor First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Templates and template parts appear in admin menu for all users
3 participants