method_block_theme_button_after_label

 
 
 
 

apply_filters( 'method_block_theme_button_after_label', string $html )

Filters the default icon HTML displayed after the Theme Button label.


Description

Sets the HTML content (typically an SVG icon) that appears after the label text in every Theme Button instance. This filter serves as a global default — when method_block_theme_button_icons is registered, per‑button icon selections take priority over this value.


Parameters

$html (string) : HTML markup to render after the label. Default: '' (empty string — no icon).


Source

PHP
'afterLabel' => apply_filters( 'method_block_theme_button_after_label', '' ),

File: lib/blocks/method-buttons/method-buttons.php, function method_theme_button_enqueue_block_assets()


Usage

PHP
add_filter( 'method_block_theme_button_after_label', 'mytheme_button_after_icon' );

function mytheme_button_after_icon( $html ) {
    return '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"/></svg>';
}

Notes

  • The HTML is rendered inside <span class="method-button-icon method-button-icon-after"> on the frontend.
  • In the editor, it is rendered via dangerouslySetInnerHTML.
  • When method_block_theme_button_icons returns a non‑false value and the block has an afterIcon attribute set, the per‑button icon selection overrides this global default.
  • If neither this filter nor method_block_theme_button_icons provides content, no after‑label icon element is rendered.
  • The data is passed to the editor via themeButtonData.afterLabel.

Related


Changelog

VersionDescription
2.0.0Introduced.