method_block_theme_button_styles
apply_filters( 'method_block_theme_button_styles', mixed $styles )
Filters the button style presets available in the Theme Button block.
This filter is not meant to replace traditionally-registered block styles. Instead, this filter is intended to provide a mechanism to register a second dimension of class driven styles.
Description
Registers named button style options that appear in a “Button Styles” dropdown in the Theme Button block’s Inspector panel. Each style maps to a CSS class applied to the button wrapper element on the frontend.
When this filter returns false (the default), the style selector is hidden entirely.
Parameters
$styles (array|false) : An associative array of style definitions where keys are CSS class suffixes and values are display labels. Pass false to hide the control.
array(
'' => 'Default',
'sm' => 'Small',
'lg' => 'Large',
'xl' => 'Extra Large',
)Source
'buttonStyles' => apply_filters( 'method_block_theme_button_styles', $defaults ),File: lib/blocks/method-buttons/method-buttons.php, function method_theme_button_enqueue_block_assets()
Usage
add_filter( 'method_block_theme_button_styles', 'mytheme_button_styles' );
function mytheme_button_styles( $styles ) {
return array(
'' => 'Default',
'sm' => 'Small',
'lg' => 'Large',
'xl' => 'Extra Large',
);
}Notes
- The selected style key is stored in the block’s
btnStyleattribute and rendered as a class:method-theme-button-{key}(e.g.,method-theme-button-primary). - You must define the corresponding CSS in your child theme’s stylesheet. Method does not provide default styling for these classes.
- The data is passed to the editor via
wp_localize_scripton thethemeButtonData.buttonStylesglobal.
Related
method_block_theme_button_styles_label— Customize the dropdown labelmethod_block_theme_label_styles— Label style optionsmethod_block_theme_button_icons— Icon options- Buttons block
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |