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

Add a filter around the return value from our current_user_can_upload_svg method #193

Merged
merged 2 commits into from
May 8, 2024

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Apr 17, 2024

Description of the Change

This PR adds a new filter, safe_svg_current_user_can_upload, around the returned value from our current_user_can_upload_svg method. This filter allows others to have more fine-tune control on who can or cannot upload svgs. For instance, this would allow you to lock down uploads to specific users, instead of specific roles. Or would allow you to allow non-logged in users the ability to upload svgs.

Closes #192

How to test the Change

  1. With this PR checked out, go to the Media Settings page and ensure your user account has permissions to upload
  2. Test uploading an svg and ensure it works
  3. Switch to an account that doesn't have permission to upload
  4. Ensure svgs aren't allowed
  5. Now use the new current_user_can_upload_svg and modify permissions, running through the tests again to ensure things work. As an example, could add add_filter( 'safe_svg_current_user_can_upload', '__return_false' ); and ensure that no one can upload svgs, or add_filter( 'safe_svg_current_user_can_upload', '__return_true' ); and ensure everyone can upload svgs.

Changelog Entry

Added - New filter, safe_svg_current_user_can_upload, allowing more control over who can upload svg files.

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

…_svg method, allowing others to modify which users can or can not upload
@dkotter dkotter added this to the 2.3.0 milestone Apr 17, 2024
@dkotter dkotter self-assigned this Apr 17, 2024
@dkotter dkotter requested a review from jeffpaul as a code owner April 17, 2024 17:55
@dkotter dkotter requested a review from a team April 19, 2024 14:59
@jeffpaul jeffpaul requested review from a team and iamdharmesh and removed request for jeffpaul and a team May 6, 2024 13:01
@github-actions github-actions bot added the needs:code-review This requires code review. label May 8, 2024
Copy link
Member

@iamdharmesh iamdharmesh left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @dkotter. PR LGTM and it tests well.

@iamdharmesh iamdharmesh merged commit 990189f into develop May 8, 2024
14 checks passed
@iamdharmesh iamdharmesh deleted the feature/192 branch May 8, 2024 15:02
@shmaltz
Copy link

shmaltz commented May 8, 2024

Thank you @dkotter !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the current_user_can_upload_svg method to be filtered
3 participants