Skip to content

Commit

Permalink
Update readmes. Add missing filter docblock. Update some text
Browse files Browse the repository at this point in the history
  • Loading branch information
dkotter committed Jul 3, 2023
1 parent 5648dcf commit b307b61
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

Safe SVG is the best way to Allow SVG Uploads in WordPress!

It gives you the ability to allow SVG uploads (and limit that by user role) whilst making sure that they're sanitized to stop SVG/XML vulnerabilities affecting your site. It also gives you the ability to preview your uploaded SVGs in the media library in all views.
It gives you the ability to allow SVG uploads whilst making sure that they're sanitized to stop SVG/XML vulnerabilities affecting your site. It also gives you the ability to preview your uploaded SVGs in the media library in all views.

### Current Features

* **Sanitised SVGs** - Don't open up security holes in your WordPress site by allowing uploads of unsanitised files.
* **SVGO Optimisation** - Runs your SVGs through the SVGO tool on upload to save you space.
* **View SVGs in the Media Library** - Gone are the days of guessing which SVG is the correct one, we'll enable SVG previews in the WordPress media library.

### Features on the Roadmap

* **SVGO Optimisation** - You'll have the option to run your SVGs through our SVGO server on upload to save you space.
* **Choose Who Can Upload** - Restrict SVG uploads to certain users on your WordPress site or allow anyone to upload.

Initially a proof of concept for [#24251](https://core.trac.wordpress.org/ticket/24251).

SVG Sanitization is done through the following library: [https://github.com/darylldoyle/svg-sanitizer](https://github.com/darylldoyle/svg-sanitizer).

SVG Optimization is done through the following library: [https://github.com/svg/svgo](https://github.com/svg/svgo).

## Requirements

* PHP 7.4+
Expand Down
11 changes: 10 additions & 1 deletion includes/safe-svg-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function sanitize_safe_svg_roles( $roles ) {
}

/**
* Get roles with with upload capabilities.
* Get roles with upload capabilities.
*
* @return array An array of roles with the upload_files capability.
*/
Expand All @@ -80,6 +80,15 @@ function( $_role ) {
}
);

/**
* Filter the roles that can upload SVG files.
*
* @since 2.2.0
*
* @param array $upload_roles The roles that can upload SVG files.
* @param array $all_roles All editable roles on the site.
* @param safe_svg_settings $this The safe_svg_settings instance.
*/
return apply_filters( 'safe_svg_upload_roles', $upload_roles, $all_roles, $this );
}

Expand Down
9 changes: 5 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ Enable SVG uploads and sanitize them to stop XML/SVG vulnerabilities in your Wor

Safe SVG is the best way to Allow SVG Uploads in WordPress!

It gives you the ability to allow SVG uploads (and limit that by user role) whilst making sure that they're sanitized to stop SVG/XML vulnerabilities affecting your site. It also gives you the ability to preview your uploaded SVGs in the media library in all views.
It gives you the ability to allow SVG uploads whilst making sure that they're sanitized to stop SVG/XML vulnerabilities affecting your site. It also gives you the ability to preview your uploaded SVGs in the media library in all views.

#### Current Features
* **Sanitised SVGs** - Don't open up security holes in your WordPress site by allowing uploads of unsanitised files.
* **SVGO Optimisation** - Runs your SVGs through the SVGO tool on upload to save you space.
* **View SVGs in the Media Library** - Gone are the days of guessing which SVG is the correct one, we'll enable SVG previews in the WordPress media library.

#### Features on the Roadmap
* **SVGO Optimisation** - You'll have the option to run your SVGs through our SVGO server on upload to save you space.
* **Choose Who Can Upload** - Restrict SVG uploads to certain users on your WordPress site or allow anyone to upload.

Initially a proof of concept for [#24251](https://core.trac.wordpress.org/ticket/24251).

SVG Sanitization is done through the following library: [https://github.com/darylldoyle/svg-sanitizer](https://github.com/darylldoyle/svg-sanitizer).

SVG Optimization is done through the following library: [https://github.com/svg/svgo](https://github.com/svg/svgo).

== Installation ==

Install through the WordPress directory or download, unzip and upload the files to your `/wp-content/plugins/` directory
Expand Down
7 changes: 4 additions & 3 deletions safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ public function __construct() {
}

/**
* Custom function to check if user can upload svg
* Use core caps if setting hasn't every been updated
* Custom function to check if user can upload svg.
*
* @return Bool
* Use core caps if setting hasn't every been updated.
*
* @return bool
*/
public function current_user_can_upload_svg() {
$upload_roles = get_option( 'safe_svg_upload_roles', [] );
Expand Down

0 comments on commit b307b61

Please sign in to comment.