From f7c2299a0ea2d7242d2fa8955f8780e98206ee14 Mon Sep 17 00:00:00 2001 From: David Baumwald Date: Tue, 7 Feb 2023 17:59:44 +0000 Subject: [PATCH] Editor: Introduce sticky position block support. In the Gutenberg plugin, a position block support feature was introduced last year, that allows a Group block to be set to a "sticky" position, meaning that when the page scrolls, the block will stick to the top of the window. This change merges the "sticky" position feature for blocks introduced in Gutenberg 15.0. Props andrewserong, flixos90, mukesh27. Fixes #57618. git-svn-id: https://develop.svn.wordpress.org/trunk@55285 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-theme-json.php | 10 ++++++++-- src/wp-settings.php | 1 + tests/phpunit/tests/theme/wpThemeJson.php | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index eb803c42ea..30c24173f4 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -304,7 +304,8 @@ class WP_Theme_JSON { * and `typography`, and renamed others according to the new schema. * @since 6.0.0 Added `color.defaultDuotone`. * @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`. - * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', and 'shadow.defaultPresets'. + * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', 'shadow.defaultPresets', + * `position.fixed` and `position.sticky`. * @var array */ const VALID_SETTINGS = array( @@ -339,6 +340,10 @@ class WP_Theme_JSON { 'definitions' => null, 'wideSize' => null, ), + 'position' => array( + 'fixed' => null, + 'sticky' => null, + ), 'spacing' => array( 'customSpacingSize' => null, 'spacingSizes' => null, @@ -513,7 +518,7 @@ class WP_Theme_JSON { * Options that settings.appearanceTools enables. * * @since 6.0.0 - * @since 6.2.0 Added `dimensions.minHeight`. + * @since 6.2.0 Added `dimensions.minHeight` and `position.sticky`. * @var array */ const APPEARANCE_TOOLS_OPT_INS = array( @@ -523,6 +528,7 @@ class WP_Theme_JSON { array( 'border', 'width' ), array( 'color', 'link' ), array( 'dimensions', 'minHeight' ), + array( 'position', 'sticky' ), array( 'spacing', 'blockGap' ), array( 'spacing', 'margin' ), array( 'spacing', 'padding' ), diff --git a/src/wp-settings.php b/src/wp-settings.php index 231303ddbe..a11b07ca28 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -336,6 +336,7 @@ require ABSPATH . WPINC . '/block-supports/duotone.php'; require ABSPATH . WPINC . '/block-supports/elements.php'; require ABSPATH . WPINC . '/block-supports/generated-classname.php'; require ABSPATH . WPINC . '/block-supports/layout.php'; +require ABSPATH . WPINC . '/block-supports/position.php'; require ABSPATH . WPINC . '/block-supports/spacing.php'; require ABSPATH . WPINC . '/block-supports/typography.php'; require ABSPATH . WPINC . '/block-supports/settings.php'; diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 79d5b1d779..b2d05d9fe3 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -274,6 +274,9 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 'dimensions' => array( 'minHeight' => true, ), + 'position' => array( + 'sticky' => true, + ), 'spacing' => array( 'blockGap' => false, 'margin' => true, @@ -301,6 +304,9 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase { 'dimensions' => array( 'minHeight' => true, ), + 'position' => array( + 'sticky' => true, + ), 'spacing' => array( 'blockGap' => false, 'margin' => true,