Created
August 4, 2025 13:25
-
-
Save diggeddy/f6a28f21ce071a6db7f970f2f82cd8a3 to your computer and use it in GitHub Desktop.
classic theme - enable block spacing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'wp_theme_json_data_theme', function( $theme_json ) { | |
| $new_data = array( | |
| 'version' => 3, | |
| 'settings' => array( | |
| 'spacing' => array( | |
| // default gap between sibling blocks | |
| 'blockGap' => '1.5rem', | |
| // enable per-block margin and padding controls | |
| 'margin' => true, | |
| 'padding' => true, | |
| // define which units users can choose in the UI | |
| 'units' => array( 'px', 'rem', '%', 'em', 'vh', 'vw' ), | |
| // optional: a spacing scale / presets to surface in the UI | |
| 'spacingScale' => array( | |
| '0.25rem', | |
| '0.5rem', | |
| '1rem', | |
| '2rem', | |
| '4rem', | |
| ), | |
| ), | |
| ), | |
| ); | |
| return $theme_json->update_with( $new_data ); | |
| } ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Want the Position prorperty: