內容簡介
SVG Forge Icon Manager 外掛可讓使用者加載中心化的 SVG 精靈檔案,並在編輯器中提供圖示選擇器,方便插入選定的圖示,提升網站的圖示管理效率。
【主要功能】
• 加載中心化的 SVG 精靈檔案
• 編輯器中提供即時預覽的圖示選擇器
• 支援從子目錄分組的圖示
• 可自訂圖示的填充顏色與大小
• 提供經過嚴格清理的上傳功能
• 支援經典佈景主題的圖示輸出
外掛標籤
開發者團隊
原文外掛簡介
The SVG Forge Icon Manager Block loads a central SVG sprite file (by default the bundled i.svg), shows all contained
A W3C standard: every icon is referenced with the
Who is this plugin for?
Developers who maintain their own sprite file. Every icon must exist as a
WordPress 7.1 ships its own icon system (wp_register_icon(), wp_get_icon()). That is enough for a few icons registered in PHP. If you run a sprite, use this plugin: no frontend code, and it works on WordPress 6.6 and later.
Features
Settings page to upload the sprite file (.svg or .svgz).
Uploaded sprites are sanitized with a strict allowlist: no scripts, no event handlers, no foreignObject, no unknown tags. Same engine as Safe SVG.
Upload a sprite you already have, or build one with svgforge-cli.
sfim_sprite_url filter overrides the sprite file (e.g. get_theme_file_uri()).
Symbol picker in the editor with a live preview.
Icons from sprite subdirectories are grouped.
Icons can be linked (new tab, rel including noopener/noreferrer).
Aria-label for screen readers.
Fill and stroke colour as well as size per block.
Server-side rendering with get_block_wrapper_attributes().
Alignment, anchor and additional CSS classes.
Optional switch to remove the core Icon block (core/icon) from the editor.
Icon helper for classic themes: echo sfim_get_icon( 'close', [ 'size' => 20 ] );
Honest limitations
Adding or editing icons means rebuilding the sprite file — typically with svgforge-cli.
Configure the sprite file
The SVG sprite file is resolved in this order (first existing source wins):
Filter sfim_sprite_url – the canonical override (has priority).
Uploaded file from Settings → SVG Forge Icon Manager (backend upload).
Fallback: sprite.svg in the plugin directory.
Override with a filter (recommended, versionable with the theme) in the theme’s functions.php:
add_filter( 'sfim_sprite_url', fn () => get_theme_file_uri( 'assets/ico.svg' ) );
or point it at a CDN:
add_filter( 'sfim_sprite_url', fn () => 'https://cdn.example.com/icons/ico.svg' );
If you have no sprite yet, this tutorial walks you through building your own icon set step by step.
Icons in theme templates
Classic themes (and any other custom PHP) can print icons from the sprite without using the block:
// Decorative icon: hidden from screen readers, sizes with the font (1em).
echo sfim_get_icon( 'close' );
// Sized, labelled and linked.
echo sfim_get_icon( 'close', [ 'size' => 20, 'label' => 'Close', 'link' => get_permalink() ] );
sfim_get_icon() returns the same `
Development
Development is done on GitHub.
