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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,24 @@ public function __construct() {
*/
public function current_user_can_upload_svg() {
$upload_roles = get_option( 'safe_svg_upload_roles', [] );
$can_upload = false;

// Fallback to upload_files check for backwards compatibility.
if ( empty( $upload_roles ) ) {
return current_user_can( 'upload_files' );
// Fallback to upload_files check for backwards compatibility.
$can_upload = current_user_can( 'upload_files' );
} else {
// Use our custom capability if some upload roles are set.
$can_upload = current_user_can( 'safe_svg_upload_svg' );
}

return current_user_can( 'safe_svg_upload_svg' );
/**
* Determine if the current user can upload an svg.
*
* @param bool $can_upload Can the current user upload an svg?
*
* @return bool
*/
return (bool) apply_filters( 'safe_svg_current_user_can_upload', $can_upload );
}

/**
Expand Down
Loading