method_core_extensions_config
apply_filters( 'method_core_extensions_config', array $config )
Filters which core blocks get Method’s responsive spacing and typography system on the server, and which CSS properties each one generates.
Description
method_core_extensions_get_config() returns the PHP side of the Core Extensions system: an array keyed by block name, each entry listing the cssargs that method_get_block_responsive_styles() may emit for that block at the mobile, tablet and wide tiers (base styling is left to core). The result decides two things: which core blocks get a responsiveSettings attribute registered (register_block_type_args) and, on render_block, which blocks get an id injected and per-tier CSS collected.
The editor has its own copy of this configuration in lib/blocks/method-core-extensions/src/config.js (blockConfig: the spacing and typography controls to show and the editor CSS map), compiled into the extension script and not read from PHP. So this filter can trim or extend the CSS properties generated for the three blocks it knows, but giving a new core block the controls needs both sides changed.
Parameters
$config (array) :
Block name ⇒ array( 'cssargs' => string[] ). Default blocks: core/paragraph (padding and margin, font size, line height, text align, font family, style, weight, transform, letter spacing), core/heading (the same without padding) and core/list (the same as paragraph without text align).
Source
File: lib/blocks/method-core-extensions/method-core-extensions.php, function method_core_extensions_get_config()
return apply_filters( 'method_core_extensions_config', $config );
Usage
// Stop headings from generating letter-spacing, whatever the editor stored.
add_filter( 'method_core_extensions_config', function ( array $config ) {
$config['core/heading']['cssargs'] = array_diff( $config['core/heading']['cssargs'], array( 'letterSpacing' ) );
return $config;
} );
Notes
- CSS is only generated for a block when at least one of its mobile, tablet or wide tiers is enabled; the generated rules are scoped to a
method-ce-id injected into the block’s root element. - Removing a block from the array stops both the attribute registration and the render, so content saved with
responsiveSettingskeeps the attribute in its markup but renders without the per-tier CSS.
Related
- Core Extensions — the system page
method_get_block_responsive_styles()— the CSS generator the config feeds