From 6bfcb74744c12a0880ec29663046f63deb317d38 Mon Sep 17 00:00:00 2001 From: ramon Date: Thu, 29 Feb 2024 10:46:47 +1100 Subject: [PATCH] Reverting source:theme support --- lib/block-supports/background.php | 15 +++------------ phpunit/block-supports/background-test.php | 10 ---------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/lib/block-supports/background.php b/lib/block-supports/background.php index 85cd3a95f7121d..64a9dbaf7f2774 100644 --- a/lib/block-supports/background.php +++ b/lib/block-supports/background.php @@ -33,6 +33,8 @@ function gutenberg_register_background_support( $block_type ) { /** * Given a theme.json or block background styles, returns the background styles for a block. * + * @since 6.6.0 + * * @param array $background_styles Background style properties. * @return array Style engine array of CSS string and style declarations. */ @@ -40,24 +42,13 @@ function gutenberg_get_background_support_styles( $background_styles = array() ) $background_image_source = isset( $background_styles['backgroundImage']['source'] ) ? $background_styles['backgroundImage']['source'] : null; $background_styles['backgroundSize'] = ! empty( $background_styles['backgroundSize'] ) ? $background_styles['backgroundSize'] : 'cover'; - /* - * @TODO document - * $background_styles['backgroundImage']['url'] and file source implies an image URL path. - */ - if ( ( 'file' === $background_image_source || 'theme' === $background_image_source ) && ! empty( $background_styles['backgroundImage']['url'] ) ) { + if ( 'file' === $background_image_source && ! empty( $background_styles['backgroundImage']['url'] ) ) { // If the background size is set to `contain` and no position is set, set the position to `center`. if ( 'contain' === $background_styles['backgroundSize'] && ! isset( $background_styles['backgroundPosition'] ) ) { $background_styles['backgroundPosition'] = 'center'; } } - /* - * "theme" source implies relative path to the theme directory - */ - if ( 'theme' === $background_image_source ) { - $background_styles['backgroundImage']['url'] = esc_url( get_theme_file_uri( $background_styles['backgroundImage']['url'] ) ); - } - return gutenberg_style_engine_get_styles( array( 'background' => $background_styles ) ); } diff --git a/phpunit/block-supports/background-test.php b/phpunit/block-supports/background-test.php index 490b51957f1608..645948b6a34b85 100644 --- a/phpunit/block-supports/background-test.php +++ b/phpunit/block-supports/background-test.php @@ -279,16 +279,6 @@ public function data_get_background_support_styles() { ), 'expected_css' => "background-image:url('https://example.com/image.jpg');background-position:center;background-size:contain;", ), - 'css generated with theme source' => array( - 'background_style' => array( - 'backgroundImage' => array( - 'url' => 'assets/image/1024x768_e2e_test_image_size.jpeg', - 'source' => 'theme', - ), - 'backgroundSize' => 'contain', - ), - 'expected_css' => "background-image:url('http://localhost:8889/wp-content/plugins/gutenberg/phpunit/data/themedir1/block-theme/assets/image/1024x768_e2e_test_image_size.jpeg');background-position:center;background-size:contain;", - ), ); } }