Skip to content

Commit 38d6e5b

Browse files
committed
prep build 03/02
2 parents b5bcded + 63acff0 commit 38d6e5b

File tree

155 files changed

+4013
-2604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+4013
-2604
lines changed

changelog.txt

+9-529
Large diffs are not rendered by default.

docs/contributors/versions-in-wordpress.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ If anything looks incorrect here, please bring it up in #core-editor in [WordPre
66

77
| Gutenberg Versions | WordPress Version |
88
| ------------------ | ----------------- |
9+
| 16.8-17.7 | 6.5 |
910
| 16.2-16.7 | 6.4.3 |
1011
| 16.2-16.7 | 6.4.2 |
1112
| 16.2-16.7 | 6.4.1 |

docs/reference-guides/theme-json-reference/theme-json-living.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ Setting that enables the following UI tools:
3333

3434
- background: backgroundImage, backgroundSize
3535
- border: color, radius, style, width
36-
- color: link
36+
- color: link, heading, button, caption
3737
- dimensions: aspectRatio, minHeight
3838
- position: sticky
3939
- spacing: blockGap, margin, padding
4040
- typography: lineHeight
41+
- shadow: defaultPresets
4142

4243

4344
---
@@ -203,6 +204,19 @@ Generate custom CSS custom properties of the form `--wp--custom--{key}--{nested-
203204
## Styles
204205

205206

207+
### background
208+
209+
Background styles
210+
211+
| Property | Type | Props |
212+
| --- | --- |--- |
213+
| backgroundImage | string, object | |
214+
| backgroundPosition | string, object | |
215+
| backgroundRepeat | string, object | |
216+
| backgroundSize | string, object | |
217+
218+
---
219+
206220
### border
207221

208222
Border styles.

lib/block-supports/background.php

+25-28
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,28 @@ function gutenberg_register_background_support( $block_type ) {
3030
}
3131
}
3232

33+
/**
34+
* Given a theme.json or block background styles, returns the background styles for a block.
35+
*
36+
* @since 6.6.0
37+
*
38+
* @param array $background_styles Background style properties.
39+
* @return array Style engine array of CSS string and style declarations.
40+
*/
41+
function gutenberg_get_background_support_styles( $background_styles = array() ) {
42+
$background_image_source = isset( $background_styles['backgroundImage']['source'] ) ? $background_styles['backgroundImage']['source'] : null;
43+
$background_styles['backgroundSize'] = ! empty( $background_styles['backgroundSize'] ) ? $background_styles['backgroundSize'] : 'cover';
44+
45+
if ( 'file' === $background_image_source && ! empty( $background_styles['backgroundImage']['url'] ) ) {
46+
// If the background size is set to `contain` and no position is set, set the position to `center`.
47+
if ( 'contain' === $background_styles['backgroundSize'] && ! isset( $background_styles['backgroundPosition'] ) ) {
48+
$background_styles['backgroundPosition'] = 'center';
49+
}
50+
}
51+
52+
return gutenberg_style_engine_get_styles( array( 'background' => $background_styles ) );
53+
}
54+
3355
/**
3456
* Renders the background styles to the block wrapper.
3557
* This block support uses the `render_block` hook to ensure that
@@ -46,38 +68,13 @@ function gutenberg_render_background_support( $block_content, $block ) {
4668

4769
if (
4870
! $has_background_image_support ||
49-
wp_should_skip_block_supports_serialization( $block_type, 'background', 'backgroundImage' )
71+
wp_should_skip_block_supports_serialization( $block_type, 'background', 'backgroundImage' ) ||
72+
! isset( $block_attributes['style']['background'] )
5073
) {
5174
return $block_content;
5275
}
5376

54-
$background_image_source = $block_attributes['style']['background']['backgroundImage']['source'] ?? null;
55-
$background_image_url = $block_attributes['style']['background']['backgroundImage']['url'] ?? null;
56-
$background_size = $block_attributes['style']['background']['backgroundSize'] ?? 'cover';
57-
$background_position = $block_attributes['style']['background']['backgroundPosition'] ?? null;
58-
$background_repeat = $block_attributes['style']['background']['backgroundRepeat'] ?? null;
59-
60-
$background_block_styles = array();
61-
62-
if (
63-
'file' === $background_image_source &&
64-
$background_image_url
65-
) {
66-
// Set file based background URL.
67-
// TODO: In a follow-up, similar logic could be added to inject a featured image url.
68-
$background_block_styles['backgroundImage']['url'] = $background_image_url;
69-
// Only output the background size and repeat when an image url is set.
70-
$background_block_styles['backgroundSize'] = $background_size;
71-
$background_block_styles['backgroundRepeat'] = $background_repeat;
72-
$background_block_styles['backgroundPosition'] = $background_position;
73-
74-
// If the background size is set to `contain` and no position is set, set the position to `center`.
75-
if ( 'contain' === $background_size && ! isset( $background_position ) ) {
76-
$background_block_styles['backgroundPosition'] = 'center';
77-
}
78-
}
79-
80-
$styles = gutenberg_style_engine_get_styles( array( 'background' => $background_block_styles ) );
77+
$styles = gutenberg_get_background_support_styles( $block_attributes['style']['background'] );
8178

8279
if ( ! empty( $styles['css'] ) ) {
8380
// Inject background styles to the first element, presuming it's the wrapper, if it exists.

lib/block-supports/layout.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
594594
'declarations' => $child_layout_declarations,
595595
);
596596

597-
/**
597+
/*
598598
* If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set,
599599
* the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive.
600600
* But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't
@@ -606,7 +606,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
606606
$parent_column_value = floatval( $parent_column_width );
607607
$parent_column_unit = explode( $parent_column_value, $parent_column_width );
608608

609-
/**
609+
/*
610610
* If there is no unit, the width has somehow been mangled so we reset both unit and value
611611
* to defaults.
612612
* Additionally, the unit should be one of px, rem or em, so that also needs to be checked.
@@ -622,7 +622,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
622622
}
623623
}
624624

625-
/**
625+
/*
626626
* A default gap value is used for this computation because custom gap values may not be
627627
* viable to use in the computation of the container query value.
628628
*/
@@ -639,7 +639,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
639639
);
640640
}
641641

642-
/**
642+
/*
643643
* Add to the style engine store to enqueue and render layout styles.
644644
* Return styles here just to check if any exist.
645645
*/
@@ -800,7 +800,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
800800
}
801801
}
802802

803-
/**
803+
/*
804804
* Attempts to refer to the inner-block wrapping element by its class attribute.
805805
*
806806
* When examining a block's inner content, if a block has inner blocks, then
@@ -890,13 +890,13 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
890890
return $processor->get_updated_html();
891891
}
892892

893-
/**
893+
/*
894894
* Add a `render_block_data` filter to fetch the parent block layout data.
895895
*/
896896
add_filter(
897897
'render_block_data',
898898
function ( $parsed_block, $source_block, $parent_block ) {
899-
/**
899+
/*
900900
* Check if the parent block exists and if it has a layout attribute.
901901
* If it does, add the parent layout to the parsed block.
902902
*/
@@ -945,7 +945,7 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
945945
return $block_content;
946946
}
947947

948-
/**
948+
/*
949949
* This filter runs after the layout classnames have been added to the block, so they
950950
* have to be removed from the outer wrapper and then added to the inner.
951951
*/
@@ -961,7 +961,7 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
961961
}
962962
}
963963
} else {
964-
/**
964+
/*
965965
* The class_list method was only added in 6.4 so this needs a temporary fallback.
966966
* This fallback should be removed when the minimum supported version is 6.4.
967967
*/

lib/class-wp-theme-json-gutenberg.php

+18-1
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,18 @@ class WP_Theme_JSON_Gutenberg {
203203
* removed the `--wp--style--block-gap` property.
204204
* @since 6.2.0 Added `outline-*`, and `min-height` properties.
205205
* @since 6.3.0 Added `writing-mode` property.
206+
* @since 6.6.0 Added `background-[image|position|repeat|size]` properties.
206207
*
207208
* @var array
208209
*/
209210
const PROPERTIES_METADATA = array(
210211
'aspect-ratio' => array( 'dimensions', 'aspectRatio' ),
211212
'background' => array( 'color', 'gradient' ),
212213
'background-color' => array( 'color', 'background' ),
214+
'background-image' => array( 'background', 'backgroundImage' ),
215+
'background-position' => array( 'background', 'backgroundPosition' ),
216+
'background-repeat' => array( 'background', 'backgroundRepeat' ),
217+
'background-size' => array( 'background', 'backgroundSize' ),
213218
'border-radius' => array( 'border', 'radius' ),
214219
'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ),
215220
'border-top-right-radius' => array( 'border', 'radius', 'topRight' ),
@@ -461,10 +466,17 @@ class WP_Theme_JSON_Gutenberg {
461466
* added new property `shadow`,
462467
* updated `blockGap` to be allowed at any level.
463468
* @since 6.2.0 Added `outline`, and `minHeight` properties.
469+
* @since 6.6.0 Added `background` sub properties to top-level only.
464470
*
465471
* @var array
466472
*/
467473
const VALID_STYLES = array(
474+
'background' => array(
475+
'backgroundImage' => 'top',
476+
'backgroundPosition' => 'top',
477+
'backgroundRepeat' => 'top',
478+
'backgroundSize' => 'top',
479+
),
468480
'border' => array(
469481
'color' => null,
470482
'radius' => null,
@@ -1334,7 +1346,6 @@ public function get_block_custom_css_nodes() {
13341346
return $block_nodes;
13351347
}
13361348

1337-
13381349
/**
13391350
* Returns the global styles custom CSS for a single block.
13401351
*
@@ -2120,6 +2131,12 @@ protected static function compute_style_properties( $styles, $settings = array()
21202131
}
21212132
}
21222133

2134+
// Processes background styles.
2135+
if ( 'background' === $value_path[0] && isset( $styles['background'] ) ) {
2136+
$background_styles = gutenberg_get_background_support_styles( $styles['background'] );
2137+
$value = $background_styles['declarations'][ $css_property ] ?? $value;
2138+
}
2139+
21232140
// Skip if empty and not "0" or value represents array of longhand values.
21242141
$has_missing_value = empty( $value ) && ! is_numeric( $value );
21252142
if ( $has_missing_value || is_array( $value ) ) {

lib/compat/wordpress-6.5/block-bindings/pattern-overrides.php

+22-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,30 @@
1515
* @return mixed The value computed for the source.
1616
*/
1717
function gutenberg_block_bindings_pattern_overrides_callback( $source_attrs, $block_instance, $attribute_name ) {
18-
if ( empty( $block_instance->attributes['metadata']['id'] ) ) {
18+
if ( ! isset( $block_instance->context['pattern/overrides'] ) ) {
1919
return null;
2020
}
21-
$block_id = $block_instance->attributes['metadata']['id'];
22-
return _wp_array_get( $block_instance->context, array( 'pattern/overrides', $block_id, 'values', $attribute_name ), null );
21+
22+
$override_content = $block_instance->context['pattern/overrides'];
23+
24+
// Back compat. Pattern overrides previously used a metadata `id` instead of `name`.
25+
// We check first for the name, and if it exists, use that value.
26+
if ( isset( $block_instance->attributes['metadata']['name'] ) ) {
27+
$metadata_name = $block_instance->attributes['metadata']['name'];
28+
if ( array_key_exists( $metadata_name, $override_content ) ) {
29+
return _wp_array_get( $override_content, array( $metadata_name, $attribute_name ), null );
30+
}
31+
}
32+
33+
// Next check for the `id`.
34+
if ( isset( $block_instance->attributes['metadata']['id'] ) ) {
35+
$metadata_id = $block_instance->attributes['metadata']['id'];
36+
if ( array_key_exists( $metadata_id, $override_content ) ) {
37+
return _wp_array_get( $override_content, array( $metadata_id, $attribute_name ), null );
38+
}
39+
}
40+
41+
return null;
2342
}
2443

2544
/**

lib/compat/wordpress-6.5/compat.php

+15
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,18 @@ function array_is_list( $arr ) {
3636
return true;
3737
}
3838
}
39+
40+
/**
41+
* Sets a global JS variable used to flag whether to direct the Site Logo block's admin urls
42+
* to the Customizer. This allows Gutenberg running on versions of WordPress < 6.5.0 to
43+
* support the previous location for the Site Icon settings. This function should not be
44+
* backported to core, and should be removed when the required WP core version for Gutenberg
45+
* is >= 6.5.0.
46+
*/
47+
function gutenberg_add_use_customizer_site_logo_url_flag() {
48+
if ( ! is_wp_version_compatible( '6.5' ) ) {
49+
wp_add_inline_script( 'wp-block-editor', 'window.__experimentalUseCustomizerSiteLogoUrl = true', 'before' );
50+
}
51+
}
52+
53+
add_action( 'admin_init', 'gutenberg_add_use_customizer_site_logo_url_flag' );

lib/compat/wordpress-6.5/fonts/class-wp-rest-font-faces-controller.php

+16-3
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,21 @@ protected function sanitize_src( $value ) {
858858
*/
859859
protected function handle_font_file_upload( $file ) {
860860
add_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );
861-
add_filter( 'upload_dir', 'wp_get_font_dir' );
861+
862+
/*
863+
* Set the upload directory to the fonts directory.
864+
*
865+
* wp_get_font_dir() contains the 'font_dir' hook, whose callbacks are
866+
* likely to call wp_get_upload_dir().
867+
*
868+
* To avoid an infinite loop, don't hook wp_get_font_dir() to 'upload_dir'.
869+
* Instead, just pass its return value to the 'upload_dir' callback.
870+
*/
871+
$font_dir = wp_get_font_dir();
872+
$set_upload_dir = function () use ( $font_dir ) {
873+
return $font_dir;
874+
};
875+
add_filter( 'upload_dir', $set_upload_dir );
862876

863877
$overrides = array(
864878
'upload_error_handler' => array( $this, 'handle_font_file_upload_error' ),
@@ -875,8 +889,7 @@ protected function handle_font_file_upload( $file ) {
875889
);
876890

877891
$uploaded_file = wp_handle_upload( $file, $overrides );
878-
879-
remove_filter( 'upload_dir', 'wp_get_font_dir' );
892+
remove_filter( 'upload_dir', $set_upload_dir );
880893
remove_filter( 'upload_mimes', array( 'WP_Font_Utils', 'get_allowed_font_mime_types' ) );
881894

882895
return $uploaded_file;

lib/compat/wordpress-6.5/fonts/fonts.php

+9-18
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,6 @@ function gutenberg_register_font_collections() {
201201
*
202202
* @since 6.5.0
203203
*
204-
* @param array $defaults {
205-
* Array of information about the upload directory.
206-
*
207-
* @type string $path Base directory and subdirectory or full path to the fonts upload directory.
208-
* @type string $url Base URL and subdirectory or absolute URL to the fonts upload directory.
209-
* @type string $subdir Subdirectory
210-
* @type string $basedir Path without subdir.
211-
* @type string $baseurl URL path without subdir.
212-
* @type string|false $error False or error message.
213-
* }
214204
* @return array $defaults {
215205
* Array of information about the upload directory.
216206
*
@@ -222,19 +212,20 @@ function gutenberg_register_font_collections() {
222212
* @type string|false $error False or error message.
223213
* }
224214
*/
225-
function wp_get_font_dir( $defaults = array() ) {
215+
function wp_get_font_dir() {
226216
$site_path = '';
227217
if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) {
228218
$site_path = '/sites/' . get_current_blog_id();
229219
}
230220

231-
// Sets the defaults.
232-
$defaults['path'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path;
233-
$defaults['url'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path;
234-
$defaults['subdir'] = '';
235-
$defaults['basedir'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path;
236-
$defaults['baseurl'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path;
237-
$defaults['error'] = false;
221+
$defaults = array(
222+
'path' => path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path,
223+
'url' => untrailingslashit( content_url( 'fonts' ) ) . $site_path,
224+
'subdir' => '',
225+
'basedir' => path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path,
226+
'baseurl' => untrailingslashit( content_url( 'fonts' ) ) . $site_path,
227+
'error' => false,
228+
);
238229

239230
/**
240231
* Filters the fonts directory data.

0 commit comments

Comments
 (0)