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

Gutenberg-plugin JS enqueue error for users without permission to push. #1231

Open
1 task done
peterwilsoncc opened this issue Jun 17, 2024 · 1 comment
Open
1 task done
Assignees
Labels
help wanted type:bug Something isn't working.
Milestone

Comments

@peterwilsoncc
Copy link
Collaborator

Describe the bug

When a user without permission to syndicate posts visits the block editor screen, an error is thrown enqueuing the Gutenberg-plugin JavaScript as the dt-push dependency is not available.

This is caused by the is_syndicatable() check in the push-ui file preventing the registration of the dependency if it's unavailable.

if ( ! syndicatable() ) {
return;
}

It may be possible to remove the is_syndicatable() check when enqueuing the the push UI JavaScript but the JavaScript may require the addition of a check for the user permissions.

Steps to Reproduce

  1. Add the following code to prevent pushing for all users to mu plugins
    add_filter( 'dt_syndicatable_capabilities', function() { return 'do_not_allow'; } );
  2. Enable the Query Monitor plugin
  3. Visit the post edit screen
  4. Query Monitor will report the dependency issue

Screenshots, screen recording, code snippet

Screenshot 2024-06-17 at 11 25 51 AM

Environment information

  • Distributor Develop @ 75c0bf3
  • WordPress 6.5.4

WordPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@peterwilsoncc peterwilsoncc added the type:bug Something isn't working. label Jun 17, 2024
@jeffpaul jeffpaul added this to the 2.2.0 milestone Jun 17, 2024
@thrijith thrijith self-assigned this Jul 19, 2024
@thrijith
Copy link
Member

Hi @peterwilsoncc

If I remove the syndicatable before script enqueuing it gets rid of the error and if I login via a user who doesn't have permission to push content, the UI to push doesn't show anything https://cleanshot.thrijith.com/6h0NTlQ5gqpnjwmZ7F8D, do we need any additional checks in the JS in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted type:bug Something isn't working.
Projects
Status: To Do
Development

No branches or pull requests

3 participants