/** * Checks if the Optimizer is enabled. * * @return bool */ public function is_enabled(): bool { $has_svg_allowed_tags = has_filter( 'svg_allowed_tags' ); $has_svg_allowed_attributes = has_filter( 'svg_allowed_attributes' );
/** * If a dev has added allowed tags or attributes, we should not * optimize the SVGs, because the optimizer will not respect their exclusions. */ if ( $has_svg_allowed_tags || $has_svg_allowed_attributes ) { return false; }
/** * Filter to enable the optimizer. * * Note: this feature is disabled by default. * * @since 2.2.0 * @hook safe_svg_optimizer_enabled * * @param bool $enabled Whether the optimizer is enabled. * @return bool */ return apply_filters( 'safe_svg_optimizer_enabled', false ); }
/** * The SVGO parameters. * * @return mixed|null */ public function svgo_params() { /** * Filter the params we pass to SVGO. * * @since 2.2.0 * @hook safe_svg_svgo_params * * @param array $params The params we pass to SVGO. * @return array */ return apply_filters( 'safe_svg_svgo_params', [ 'multipass' => true, ] ); }
/** * Enqueue the necessary scripts. * * @param string $hook The current admin page. * * @return void */ public function enqueues( $hook ) { $allowed_hooks = [ 'options-media.php', 'post.php', 'post-new.php', 'upload.php', 'media-new.php', ];