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 settings for user role selection #76

Merged
merged 25 commits into from Jul 3, 2023
Merged

add settings for user role selection #76

merged 25 commits into from Jul 3, 2023

Conversation

dhanendran
Copy link
Member

@dhanendran dhanendran commented Aug 22, 2022

Description of the Change

Added a settings section to select user roles who can upload SVG images. Based on the role section, a new capability safe_svg_upload_svg will be added to those roles. By default, super admins on a network site will have all the capabilities, so they can upload SVG files.

Closes #69

How to test the Change

  1. Go to /wp-admin/uploads.php page
  2. Try to upload an SVG file and it should not be uploaded and get an error message
  3. Enable the plugin and go to /wp-admin/options-media.php page
  4. All the available roles on the site should be listed with the checkbox
  5. Admin should be able to select the user roles who can upload the SVG files
  6. Select Administrator role and submit the form
  7. Go to /wp-admin/uploads.php page
  8. Try to upload an SVG file and it should be uploaded successfully

Changelog Entry

Feature - Add a new option to select which user roles can upload SVG files.

Credits

Props @dhanendran, @csloisel, @faisal-alvi

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.

@dhanendran dhanendran self-assigned this Aug 22, 2022
@jeffpaul jeffpaul added this to the 2.1.0 milestone Sep 2, 2022
README.md Outdated Show resolved Hide resolved
readme.txt Outdated Show resolved Hide resolved
* User role field callback function.
*/
public function safe_svg_roles_cb() {
$user_roles = get_editable_roles();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will show all roles, even those that can't do anything with media currently. Feels like we should trim this list down to only roles that currently have media upload capabilities to begin with, otherwise I could see confusion when someone sees Subscriber on this list, even though they can't upload any types of media

Choose a reason for hiding this comment

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

I've updated this in the latest push, it will be filtered to roles that have the upload_files permission. I've also added a filter for these roles.

includes/safe-svg-settings.php Show resolved Hide resolved
@darylldoyle darylldoyle mentioned this pull request Oct 21, 2022
4 tasks
@jeffpaul
Copy link
Member

@dkotter looking for an update code review from you here, thanks!

@jeffpaul
Copy link
Member

@faisal-alvi if you're able to review during your OSS week that'll help move this along, thanks!

@dkotter
Copy link
Collaborator

dkotter commented Feb 13, 2023

@faisal-alvi if you're able to review during your OSS week that'll help move this along, thanks!

I've reviewed the code here a few times and things are looking good from my perspective. Could use help in actually testing this out, want to ensure this works as expected and doesn't introduce any regressions. The main thing I'm concerned about is ensuring that anyone that can currently upload an SVG should still be able to upload an SVG after this update, at least until this new setting has been modified from the default.

Edit: looks like also a merge conflict that we can clean up here

faisal-alvi
faisal-alvi previously approved these changes Feb 14, 2023
Copy link
Member

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

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

@dhanendran & @csloisel thank you for the great work here!

Note: this is a report of testing only, as the Code Review is already been done by @dkotter.

  • ✅ A settings section to select user roles who can upload SVG images is displayed correctly.

image

  • ✅ I have tested and confirmed the functionality is working fine.
  • ✅ Only the user roles allowed in settings can upload the SVG.
  • ✅ If a user with a specific role is not allowed to upload, the following error is displayed and the SVG image does not upload.

image

@dkotter dkotter modified the milestones: 2.1.0, 2.2.0 Mar 22, 2023
@jeffpaul
Copy link
Member

jeffpaul commented May 8, 2023

Resolved the merge commit, but seeing PHPUnit failure that we'll want to resolve before merging

@jeffpaul jeffpaul marked this pull request as ready for review May 8, 2023 19:12
@jeffpaul jeffpaul requested a review from a team as a code owner May 8, 2023 19:12
@jayedul jayedul requested a review from jeffpaul June 20, 2023 17:09
@jeffpaul jeffpaul requested review from a team and removed request for jeffpaul, faisal-alvi and a team June 28, 2023 14:39
@jeffpaul
Copy link
Member

jeffpaul commented Jul 3, 2023

@10up/open-source-practice would be good to get a final code review pass on this before merging in... thanks!

@dkotter dkotter mentioned this pull request Jul 3, 2023
19 tasks
@dkotter dkotter merged commit 355c8e0 into develop Jul 3, 2023
11 checks passed
@dkotter dkotter deleted the feature/69 branch July 3, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Choose Who Can Upload
6 participants