method_get_responsive_setting()
method_get_responsive_setting( $block_attributes, $breakpoint, $setting, $fallback = false )
Safely retrieves a value from nested responsive settings.
Description
Navigates the responsiveSettings structure within block attributes to retrieve a specific setting at a specific breakpoint. Returns the fallback if any key in the chain is missing or empty. This is the primary accessor for the responsive settings system on the PHP side.
Parameters
$block_attributes (array) :
The full block attributes array.
$breakpoint (string) :
The breakpoint key: 'base', 'mobile', 'tablet', or 'wide'.
$setting (string) :
The setting key to retrieve (e.g., 'gridCols', 'padding', 'fontSize').
$fallback (mixed) :
Value to return if the setting is not found. Default false.
Return
(mixed) The setting value, or $fallback if not found.
Source
File: lib/blocks.php
Usage
$cols = method_get_responsive_setting( $attrs, 'base', 'gridCols', 8 );
$enabled = method_get_responsive_setting( $attrs, 'mobile', 'enabled' );
$gap = method_get_responsive_setting( $attrs, 'base', 'gap' ); // returns array or falseChangelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |