method_get_theme_icons()

The set of SVG icons a child theme registers for Method’s controls — swiper arrows, theme button icons, the modal close button — assembled from the method_theme_icons filter.


Description

Builds the icon set by running an empty array through two filters: first method_block_theme_button_icons — the older hook, kept so child themes that already supply Theme Button icons work unchanged — then method_theme_icons. Each entry is keyed by slug and holds a label and the inline svg markup; an optional omit keeps the icon out of WordPress’s icon library while leaving it available to Method’s own controls. Registration and the full picture are on the Theme Icons page.


Parameters

None.


Return

(array|false) Slug ⇒ array( 'label' => string, 'svg' => string, 'omit' => bool ), or false when no icon is registered — callers test with is_array().


Source

File: lib/blocks.php


Usage

child-theme/functions.php
add_filter( 'method_theme_icons', function ( array $icons ) {
    $icons['arrow-right'] = array(
        'label' => 'Arrow right',
        'svg'   => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor"><path d="M1 8h12M9 4l4 4-4 4" stroke="currentColor" stroke-width="1.5" fill="none"/></svg>',
    );
    $icons['sparkle'] = array(
        'label' => 'Sparkle',
        'svg'   => '<svg …></svg>',
        'omit'  => true, // Method controls only, not the WordPress icon library
    );
    return $icons;
} );

Notes

  • Read on the page by the Swiper and Swiper Gallery arrows (method_swiper_get_nav_icons()), the Theme Button before / after icons and the Modal close button; in the editor the same set is localised as methodGlobalData.icons, which the icon dropdowns read.
  • method_register_theme_icons() (same file, on init) registers the non-omitted icons with WordPress’s icon library as the Method collection (wp_register_icon_collection() / wp_register_icon()) when those functions exist, so they appear in core’s icon pickers.
  • Icons are inline SVG: keep fill="currentColor" (or stroke) so the blocks’ color controls apply, and give each a viewBox so it scales.

Changelog

VersionDescription
2.0.0-beta18Introduced, with the method_theme_icons filter and method_register_theme_icons() (3064cd9).