From 962bd2c140559d40f496d0809ab4684e14cd0cc6 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Sun, 19 May 2024 23:11:23 +0530 Subject: [PATCH] Add option to enable large SVG items --- includes/safe-svg-settings.php | 19 +++++++++++++++++++ safe-svg.php | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/includes/safe-svg-settings.php b/includes/safe-svg-settings.php index 574075c6..34c15599 100644 --- a/includes/safe-svg-settings.php +++ b/includes/safe-svg-settings.php @@ -25,6 +25,7 @@ public function __construct() { */ public function settings_init() { register_setting( 'media', 'safe_svg_upload_roles', [ $this, 'sanitize_safe_svg_roles' ] ); + register_setting( 'media', 'safe_svg_large_svg', [ $this, 'sanitize_safe_svg_large_svg' ] ); add_settings_section( 'safe_svg_settings', @@ -40,6 +41,14 @@ public function settings_init() { 'media', 'safe_svg_settings' ); + + add_settings_field( + 'safe_svg_large_svg', + __( 'Large SVG Files', 'safe-svg' ), + [ $this, 'safe_svg_large_svg_cb' ], + 'media', + 'safe_svg_settings' + ); } /** @@ -162,4 +171,14 @@ public function update_capability( $new_roles, $old_roles ) { return $new_roles; } + /** + * Large SVG files field callback function. + */ + public function safe_svg_large_svg_cb() { + ?> + + sanitizer->setAllowHugeFiles( true ); + } + /** * Load extra filters to allow devs to access the safe tags and attrs by themselves. */