Skip to content

Commit

Permalink
Add additional contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
darylldoyle committed Sep 30, 2024
1 parent fd69010 commit 8af17da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion safe-svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ public function __construct() {
$this->sanitizer = new Sanitizer();
$this->sanitizer->minify( true );

add_action( 'init', array( $this, 'setup_blocks' ) );
// Allow SVG uploads from specific contexts.
add_action( 'load-upload.php', array( $this, 'allow_svg_from_upload' ) );
add_action( 'load-post-new.php', array( $this, 'allow_svg_from_upload' ) );
add_action( 'load-post.php', array( $this, 'allow_svg_from_upload' ) );
add_action( 'load-site-editor.php', array( $this, 'allow_svg_from_upload' ) );

// Init all the things.
add_action( 'init', array( $this, 'setup_blocks' ) );
add_filter( 'wp_handle_sideload_prefilter', array( $this, 'check_for_svg' ) );
add_filter( 'wp_handle_upload_prefilter', array( $this, 'check_for_svg' ) );
add_filter( 'wp_prepare_attachment_for_js', array( $this, 'fix_admin_preview' ), 10, 3 );
Expand Down

0 comments on commit 8af17da

Please sign in to comment.