Skip to content

Commit 1834d72

Browse files
authored
Merge branch 'trunk' into add/visual-regression-tests-admin-reskin
2 parents 656f698 + 7b3ea1a commit 1834d72

11 files changed

Lines changed: 189 additions & 40 deletions

File tree

src/wp-admin/includes/dashboard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ function wp_welcome_panel() {
21292129
<?php if ( $is_block_theme ) : ?>
21302130
<h3><?php _e( 'Switch up your site&#8217;s look & feel with Styles' ); ?></h3>
21312131
<p><?php _e( 'Tweak your site, or give it a whole new look! Get creative &#8212; how about a new color palette or font?' ); ?></p>
2132-
<a href="<?php echo esc_url( admin_url( '/site-editor.php?path=%2Fwp_global_styles' ) ); ?>"><?php _e( 'Edit styles' ); ?></a>
2132+
<a href="<?php echo esc_url( add_query_arg( 'p', rawurlencode( '/styles' ), admin_url( 'site-editor.php' ) ) ); ?>"><?php _e( 'Edit styles' ); ?></a>
21332133
<?php else : ?>
21342134
<h3><?php _e( 'Discover a new way to build your site.' ); ?></h3>
21352135
<p><?php _e( 'There is a new kind of WordPress theme, called a block theme, that lets you build the site you&#8217;ve always wanted &#8212; with blocks and styles.' ); ?></p>

src/wp-content/themes/twentynineteen/inc/template-tags.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function twentynineteen_entry_footer() {
9292
/* translators: Hidden accessibility text. */
9393
__( 'Posted in', 'twentynineteen' ),
9494
$categories_list
95-
); // WPCS: XSS OK.
95+
);
9696
}
9797

9898
$tags_list = get_the_tag_list( '', wp_get_list_item_separator() );
@@ -104,7 +104,7 @@ function twentynineteen_entry_footer() {
104104
/* translators: Hidden accessibility text. */
105105
__( 'Tags:', 'twentynineteen' ),
106106
$tags_list
107-
); // WPCS: XSS OK.
107+
);
108108
}
109109
}
110110

src/wp-includes/block-supports/typography.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*
1212
* @since 5.6.0
1313
* @since 6.3.0 Added support for text-columns.
14+
* @since 7.0.0 Added support for text-indent.
1415
* @access private
1516
*
1617
* @param WP_Block_Type $block_type Block Type.
@@ -35,6 +36,7 @@ function wp_register_typography_support( $block_type ) {
3536
$has_text_columns_support = $typography_supports['textColumns'] ?? false;
3637
$has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
3738
$has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
39+
$has_text_indent_support = $typography_supports['textIndent'] ?? false;
3840
$has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
3941

4042
$has_typography_support = $has_font_family_support
@@ -47,6 +49,7 @@ function wp_register_typography_support( $block_type ) {
4749
|| $has_text_columns_support
4850
|| $has_text_decoration_support
4951
|| $has_text_transform_support
52+
|| $has_text_indent_support
5053
|| $has_writing_mode_support;
5154

5255
if ( ! $block_type->attributes ) {
@@ -80,6 +83,7 @@ function wp_register_typography_support( $block_type ) {
8083
* @since 5.6.0
8184
* @since 6.1.0 Used the style engine to generate CSS and classnames.
8285
* @since 6.3.0 Added support for text-columns.
86+
* @since 7.0.0 Added support for text-indent.
8387
* @access private
8488
*
8589
* @param WP_Block_Type $block_type Block type.
@@ -110,6 +114,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
110114
$has_text_columns_support = $typography_supports['textColumns'] ?? false;
111115
$has_text_decoration_support = $typography_supports['__experimentalTextDecoration'] ?? false;
112116
$has_text_transform_support = $typography_supports['__experimentalTextTransform'] ?? false;
117+
$has_text_indent_support = $typography_supports['textIndent'] ?? false;
113118
$has_writing_mode_support = $typography_supports['__experimentalWritingMode'] ?? false;
114119

115120
// Whether to skip individual block support features.
@@ -123,6 +128,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
123128
$should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
124129
$should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
125130
$should_skip_letter_spacing = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' );
131+
$should_skip_text_indent = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textIndent' );
126132
$should_skip_writing_mode = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'writingMode' );
127133

128134
$typography_block_styles = array();
@@ -222,6 +228,10 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
222228
$typography_block_styles['writingMode'] = $block_attributes['style']['typography']['writingMode'] ?? null;
223229
}
224230

231+
if ( $has_text_indent_support && ! $should_skip_text_indent && isset( $block_attributes['style']['typography']['textIndent'] ) ) {
232+
$typography_block_styles['textIndent'] = $block_attributes['style']['typography']['textIndent'] ?? null;
233+
}
234+
225235
$attributes = array();
226236
$classnames = array();
227237
$styles = wp_style_engine_get_styles(

src/wp-includes/class-wp-theme-json.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ class WP_Theme_JSON {
215215
'classes' => array(),
216216
'properties' => array( 'border-radius' ),
217217
),
218+
array(
219+
'path' => array( 'dimensions', 'dimensionSizes' ),
220+
'prevent_override' => false,
221+
'use_default_names' => false,
222+
'value_key' => 'size',
223+
'css_vars' => '--wp--preset--dimension--$slug',
224+
'classes' => array(),
225+
'properties' => array( 'width', 'height', 'min-height' ),
226+
),
218227
);
219228

220229
/**
@@ -238,6 +247,7 @@ class WP_Theme_JSON {
238247
* @since 6.6.0 Added `background-[image|position|repeat|size]` properties.
239248
* @since 6.7.0 Added `background-attachment` property.
240249
* @since 7.0.0 Added `dimensions.width` and `dimensions.height`.
250+
* Added `text-indent` property.
241251
* @var array
242252
*/
243253
const PROPERTIES_METADATA = array(
@@ -300,6 +310,7 @@ class WP_Theme_JSON {
300310
'--wp--style--root--padding-left' => array( 'spacing', 'padding', 'left' ),
301311
'text-decoration' => array( 'typography', 'textDecoration' ),
302312
'text-transform' => array( 'typography', 'textTransform' ),
313+
'text-indent' => array( 'typography', 'textIndent' ),
303314
'filter' => array( 'filter', 'duotone' ),
304315
'box-shadow' => array( 'shadow' ),
305316
'height' => array( 'dimensions', 'height' ),
@@ -400,6 +411,7 @@ class WP_Theme_JSON {
400411
* @since 6.9.0 Added support for `border.radiusSizes`.
401412
* @since 7.0.0 Added type markers to the schema for boolean values.
402413
* Added support for `dimensions.width` and `dimensions.height`.
414+
* Added support for `typography.textIndent`.
403415
* @var array
404416
*/
405417
const VALID_SETTINGS = array(
@@ -438,6 +450,7 @@ class WP_Theme_JSON {
438450
'aspectRatio' => null,
439451
'aspectRatios' => null,
440452
'defaultAspectRatios' => null,
453+
'dimensionSizes' => null,
441454
'height' => null,
442455
'minHeight' => null,
443456
'width' => null,
@@ -484,6 +497,7 @@ class WP_Theme_JSON {
484497
'textAlign' => null,
485498
'textColumns' => null,
486499
'textDecoration' => null,
500+
'textIndent' => null,
487501
'textTransform' => null,
488502
'writingMode' => null,
489503
),
@@ -591,6 +605,7 @@ class WP_Theme_JSON {
591605
'textAlign' => null,
592606
'textColumns' => null,
593607
'textDecoration' => null,
608+
'textIndent' => null,
594609
'textTransform' => null,
595610
'writingMode' => null,
596611
),
@@ -2739,6 +2754,48 @@ private static function update_separator_declarations( $declarations ) {
27392754
return $declarations;
27402755
}
27412756

2757+
/**
2758+
* Updates the text indent selector for paragraph blocks based on the textIndent setting.
2759+
*
2760+
* The textIndent setting can be 'subsequent' (default), 'all', or false.
2761+
* When set to 'all', the selector should be '.wp-block-paragraph' instead of
2762+
* '.wp-block-paragraph + .wp-block-paragraph' to apply indent to all paragraphs.
2763+
*
2764+
* @since 7.0.0
2765+
*
2766+
* @param array $feature_declarations The feature declarations keyed by selector.
2767+
* @param array $settings The theme.json settings.
2768+
* @param string $block_name The block name being processed.
2769+
* @return array The updated feature declarations.
2770+
*/
2771+
private static function update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name ) {
2772+
if ( 'core/paragraph' !== $block_name ) {
2773+
return $feature_declarations;
2774+
}
2775+
2776+
// Check block-level settings first, then fall back to global settings.
2777+
$block_settings = $settings['blocks']['core/paragraph'] ?? null;
2778+
$text_indent_setting = $block_settings['typography']['textIndent']
2779+
?? $settings['typography']['textIndent']
2780+
?? 'subsequent';
2781+
2782+
if ( 'all' !== $text_indent_setting ) {
2783+
return $feature_declarations;
2784+
}
2785+
2786+
// Look for the text indent selector and replace it.
2787+
$old_selector = '.wp-block-paragraph + .wp-block-paragraph';
2788+
$new_selector = '.wp-block-paragraph';
2789+
2790+
if ( isset( $feature_declarations[ $old_selector ] ) ) {
2791+
$declarations = $feature_declarations[ $old_selector ];
2792+
unset( $feature_declarations[ $old_selector ] );
2793+
$feature_declarations[ $new_selector ] = $declarations;
2794+
}
2795+
2796+
return $feature_declarations;
2797+
}
2798+
27422799
/**
27432800
* An internal method to get the block nodes from a theme.json file.
27442801
*
@@ -2900,6 +2957,10 @@ public function get_styles_for_block( $block_metadata ) {
29002957
$feature_declarations = static::get_feature_declarations_for_node( $block_metadata, $node );
29012958
$is_root_selector = static::ROOT_BLOCK_SELECTOR === $selector;
29022959

2960+
// Update text indent selector for paragraph blocks based on the textIndent setting.
2961+
$block_name = $block_metadata['name'] ?? null;
2962+
$feature_declarations = static::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name );
2963+
29032964
// If there are style variations, generate the declarations for them, including any feature selectors the block may have.
29042965
$style_variation_declarations = array();
29052966
$style_variation_custom_css = array();
@@ -2912,6 +2973,9 @@ public function get_styles_for_block( $block_metadata ) {
29122973
// Generate any feature/subfeature style declarations for the current style variation.
29132974
$variation_declarations = static::get_feature_declarations_for_node( $block_metadata, $style_variation_node );
29142975

2976+
// Update text indent selector for paragraph blocks based on the textIndent setting.
2977+
$variation_declarations = static::update_paragraph_text_indent_selector( $variation_declarations, $settings, $block_name );
2978+
29152979
// Combine selectors with style variation's selector and add to overall style variation declarations.
29162980
foreach ( $variation_declarations as $current_selector => $new_declarations ) {
29172981
/*

src/wp-includes/pluggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function wp_set_current_user( $id, $name = '' ) {
3030
// If `$id` matches the current user, there is nothing to do.
3131
if ( isset( $current_user )
3232
&& ( $current_user instanceof WP_User )
33-
&& ( $id === $current_user->ID )
33+
&& ( (int) $id === $current_user->ID )
3434
&& ( null !== $id )
3535
) {
3636
return $current_user;

src/wp-includes/post.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,8 @@ function create_initial_post_types() {
359359

360360
$template_edit_link = 'site-editor.php?' . build_query(
361361
array(
362-
'postType' => '%s',
363-
'postId' => '%s',
364-
'canvas' => 'edit',
362+
'p' => '/%s/%s',
363+
'canvas' => 'edit',
365364
)
366365
);
367366

@@ -531,9 +530,8 @@ function create_initial_post_types() {
531530

532531
$navigation_post_edit_link = 'site-editor.php?' . build_query(
533532
array(
534-
'postId' => '%s',
535-
'postType' => 'wp_navigation',
536-
'canvas' => 'edit',
533+
'p' => '/wp_navigation/%s',
534+
'canvas' => 'edit',
537535
)
538536
);
539537

src/wp-includes/style-engine/class-wp-style-engine.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* @since 6.5.0 Added support for background.backgroundPosition,
2727
* background.backgroundRepeat and dimensions.aspectRatio.
2828
* @since 6.7.0 Added support for typography.writingMode.
29+
* @since 7.0.0 Added support for typography.textIndent.
2930
*/
3031
#[AllowDynamicProperties]
3132
final class WP_Style_Engine {
@@ -215,21 +216,27 @@ final class WP_Style_Engine {
215216
'default' => 'height',
216217
),
217218
'path' => array( 'dimensions', 'height' ),
219+
'css_vars' => array(
220+
'dimension' => '--wp--preset--dimension--$slug',
221+
),
218222
),
219223
'minHeight' => array(
220224
'property_keys' => array(
221225
'default' => 'min-height',
222226
),
223227
'path' => array( 'dimensions', 'minHeight' ),
224228
'css_vars' => array(
225-
'spacing' => '--wp--preset--spacing--$slug',
229+
'dimension' => '--wp--preset--dimension--$slug',
226230
),
227231
),
228232
'width' => array(
229233
'property_keys' => array(
230234
'default' => 'width',
231235
),
232236
'path' => array( 'dimensions', 'width' ),
237+
'css_vars' => array(
238+
'dimension' => '--wp--preset--dimension--$slug',
239+
),
233240
),
234241
),
235242
'spacing' => array(
@@ -309,6 +316,12 @@ final class WP_Style_Engine {
309316
),
310317
'path' => array( 'typography', 'textDecoration' ),
311318
),
319+
'textIndent' => array(
320+
'property_keys' => array(
321+
'default' => 'text-indent',
322+
),
323+
'path' => array( 'typography', 'textIndent' ),
324+
),
312325
'textTransform' => array(
313326
'property_keys' => array(
314327
'default' => 'text-transform',

tests/phpunit/tests/style-engine/styleEngine.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ public function data_wp_style_engine_get_styles() {
119119
),
120120
),
121121

122+
'inline_valid_dimension_preset_style' => array(
123+
'block_styles' => array(
124+
'dimensions' => array(
125+
'width' => 'var:preset|dimension|large',
126+
'height' => 'var:preset|dimension|modestly-small',
127+
),
128+
),
129+
'options' => null,
130+
'expected_output' => array(
131+
'css' => 'height:var(--wp--preset--dimension--modestly-small);width:var(--wp--preset--dimension--large);',
132+
'declarations' => array(
133+
'height' => 'var(--wp--preset--dimension--modestly-small)',
134+
'width' => 'var(--wp--preset--dimension--large)',
135+
),
136+
),
137+
),
138+
122139
'inline_valid_box_model_style' => array(
123140
'block_styles' => array(
124141
'spacing' => array(

0 commit comments

Comments
 (0)