You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php/** * Get an icon using Omni Icon plugin if available. * * @param string $iconName Icon name in format "prefix:icon-name" (e.g., "mdi:home", "local:my-logo", "omni:windpress") * @param array $attributes Optional HTML attributes to add to the SVG element * @return null|string the SVG HTML if exists, or null if couldn't found or plugin not active */functionget_icon(string$iconName, array$attributes = [])
{
// Validate icon name formatif (! str_contains($iconName, ':')) {
returnnull;
}
try {
$iconService = \OmniIcon\Plugin::get_instance()->container()->get(\OmniIcon\Services\IconService::class);
// Convert boolean and numeric attributes to string representationforeach ($attributesas$key => $value) {
if (is_bool($value)) {
$attributes[$key] = $value ? 'true' : 'false';
} elseif (is_int($value) || is_float($value)) {
$attributes[$key] = (string) $value;
}
}
// Use Omni Icon plugin's IconService to render the icon as HTML stringreturn$iconService->get_icon($iconName, $attributes);
} catch (\Exception$e) {
// Log errors in debug modeif (defined('WP_DEBUG') && WP_DEBUG) {
error_log("OmniIcon error: {$e->getMessage()}");
}
returnnull;
}
}
Some numbers for this, measured on the 7.7.8 release ZIP (13.4 MB): includes/icons/ holds 44 sets with 34,946 icons, 5.8 MB of the ZIP and 23 MB unpacked on every site. The largest are simple-icons (5.0 MB raw, 2.0 MB zipped), material-design-icons (5 variants, 4.6 MB raw) and tabler (3.5 MB raw).
#185 takes care of the runtime side: whole sets are no longer stored as transients (up to 5 MB per row in wp_options), and the editor fetches a set only when the picker is used. It does not make the ZIP smaller.
Compressing the files on disk (gzip per set) would save disk space but almost nothing in the ZIP (under 2 %, the SVG paths do not compress further). Only shipping less data helps. A shape that would keep everything that works today:
A small core stays in the ZIP, for example fontawesome-free, heroicons, feather, bootstrap and octicons (0.9 MB zipped). The ZIP would go from 13.4 to about 8.5 MB.
The other sets are built by generate-icons.ts as separate files, attached to the release like blockstudio.zip, and installed from the admin on request into wp-content/blockstudio/icons/ (outside the plugin folder, so updates keep them), with checksums in a small manifest in the ZIP.
rest.php and bs_render_icon() share one lookup (core, then the installed sets), with a filter so other icon sources can plug in. A missing set keeps rendering nothing as today and gets a notice in the admin and the picker.
No network request at render time or on the frontend, the stored value {set, subSet, icon} stays the same.
Sites that use a set outside the core would need to install it once after updating, so the update needs a notice. If this direction works for you (or you prefer a different core, or a separate icons plugin or Composer package instead of release assets), I am happy to send a PR.
A revision of my proposal above. The small core is a compromise that still breaks sites using a set outside of it, so I would drop it. The line would not be "core or not" but "existing or new install":
New installs: no icon set in the ZIP at all. A set is fetched the first time it is picked in the editor and stored in wp-content/blockstudio/icons/. The ZIP goes from 13.4 MB to about 7.6 MB.
Existing installs: keep all 44 sets, only in a different place. Rendering stays local, the stored value {set, subSet, icon} stays the same, nobody has to click anything.
Doing this without a gap takes two releases, because WordPress removes the old plugin folder before the new code runs for the first time:
Release A still ships includes/icons/ and copies it once to wp-content/blockstudio/icons/ on its first run (a local copy, no network). From then on rest.php and bs_render_icon() read from there, through one shared lookup with a filter for other icon sources.
Release B drops the folder from the ZIP. Sites that came through A notice nothing.
What remains:
Skipping A: a site that updates from an older version straight to B has no local copy. B would fetch the sets once in the background (5.8 MB, release assets with checksums). Until that has finished icons are missing, and a server without outbound access to GitHub needs an admin notice. This is the only case where anything changes for anyone.
No disk savings on existing installs: the 22 MB stay, just outside the plugin folder. Unused sets could be removable from the admin.
No network request at render time or on the frontend, as before.
Keeping only the sets a site actually uses is not reliable: bs_render_icon() can be called from any template with any set, so usage cannot be detected safely.
If this direction works for you I will send the PR for release A first, since it changes nothing visible and can ship on its own.
Activity
suasgn commentedon Mar 6, 2026
This is example of how our picowind theme integrate the picowind plugin: https://github.com/livecanvas-team/picowind/blob/main/src/Supports/OmniIcon.php
Contributolo commentedon Oct 24, 2026
Some numbers for this, measured on the 7.7.8 release ZIP (13.4 MB):
includes/icons/holds 44 sets with 34,946 icons, 5.8 MB of the ZIP and 23 MB unpacked on every site. The largest are simple-icons (5.0 MB raw, 2.0 MB zipped), material-design-icons (5 variants, 4.6 MB raw) and tabler (3.5 MB raw).#185 takes care of the runtime side: whole sets are no longer stored as transients (up to 5 MB per row in
wp_options), and the editor fetches a set only when the picker is used. It does not make the ZIP smaller.Compressing the files on disk (gzip per set) would save disk space but almost nothing in the ZIP (under 2 %, the SVG paths do not compress further). Only shipping less data helps. A shape that would keep everything that works today:
generate-icons.tsas separate files, attached to the release likeblockstudio.zip, and installed from the admin on request intowp-content/blockstudio/icons/(outside the plugin folder, so updates keep them), with checksums in a small manifest in the ZIP.rest.phpandbs_render_icon()share one lookup (core, then the installed sets), with a filter so other icon sources can plug in. A missing set keeps rendering nothing as today and gets a notice in the admin and the picker.{set, subSet, icon}stays the same.Sites that use a set outside the core would need to install it once after updating, so the update needs a notice. If this direction works for you (or you prefer a different core, or a separate icons plugin or Composer package instead of release assets), I am happy to send a PR.
Contributolo commentedon Nov 11, 2026
A revision of my proposal above. The small core is a compromise that still breaks sites using a set outside of it, so I would drop it. The line would not be "core or not" but "existing or new install":
wp-content/blockstudio/icons/. The ZIP goes from 13.4 MB to about 7.6 MB.{set, subSet, icon}stays the same, nobody has to click anything.Doing this without a gap takes two releases, because WordPress removes the old plugin folder before the new code runs for the first time:
includes/icons/and copies it once towp-content/blockstudio/icons/on its first run (a local copy, no network). From then onrest.phpandbs_render_icon()read from there, through one shared lookup with a filter for other icon sources.What remains:
Keeping only the sets a site actually uses is not reliable:
bs_render_icon()can be called from any template with any set, so usage cannot be detected safely.If this direction works for you I will send the PR for release A first, since it changes nothing visible and can ship on its own.