Skip to content

Commit

Permalink
Update @WordPress packages
Browse files Browse the repository at this point in the history
Update packages to include these bug fixes from Gutenberg:

- Site Logo: Add option to set site icon from Site Logo block
- Navigation: Enable even more compact setup state.
- Remove template parts from post content inserter an __unstable filter
- Template Editor Mode: Hide editor mode switcher
- Avoid using CSS variables for block gap styles
- Try to fix auto resizing in template part focus mode
- Lower the specificity of font size CSS Custom Properties in the editor
- Site icon: Fix site icon styling to display non-square site icons within a square button
- [Site Editor]: Register block editor shortcuts
- Update regex to handle 404 template slug
- Site Editor: Remove dead code
- [Block Editor]: Restrict delete multi selected blocks shortcut
- Fix: Gradients are not being applied by class
- Update: Make the global styles subtitles font smaller
- Post Content/Title: Reflect changes when previewing post
- ServerSideRender: Fix loading state
- [Block Library]: Fix editable post blocks in Query Loop with zero queryId
- Post Excerpt: Fix previews
- WP59: Contextualize "Export" string to differentiate it from other occurrences in WP Core
- Tools Panel: Fix race conditions caused by conditionally displayed ToolsPanelItems
- ToolsPanel: Allow items to register when panelId is null
- Font Size Picker: Allow non-integers as simple CSS values and in hints
- [Components - FontSizePicker]: Use incremental sequence of numbers as labels for the available font-sizes at the segmented control (conditionally)

See #54487.

Built from https://develop.svn.wordpress.org/trunk@52434


git-svn-id: http://core.svn.wordpress.org/trunk@52026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
noisysocks committed Jan 4, 2022
1 parent 15b614a commit 28a12c8
Show file tree
Hide file tree
Showing 43 changed files with 733 additions and 285 deletions.
2 changes: 1 addition & 1 deletion wp-includes/assets/script-loader-packages.php

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions wp-includes/block-supports/layout.php
Expand Up @@ -39,9 +39,10 @@ function wp_register_layout_support( $block_type ) {
* @param array $layout Layout object. The one that is passed has already checked
* the existence of default block layout.
* @param bool $has_block_gap_support Whether the theme has support for the block gap.
* @param string $gap_value The block gap value to apply.
* @return string CSS style.
*/
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false ) {
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null ) {
$layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';

$style = '';
Expand Down Expand Up @@ -72,8 +73,9 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
$style .= "$selector .alignleft { float: left; margin-right: 2em; }";
$style .= "$selector .alignright { float: right; margin-left: 2em; }";
if ( $has_block_gap_support ) {
$style .= "$selector > * { margin-top: 0; margin-bottom: 0; }";
$style .= "$selector > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }";
$gap_style = $gap_value ? $gap_value : 'var( --wp--style--block-gap )';
$style .= "$selector > * { margin-top: 0; margin-bottom: 0; }";
$style .= "$selector > * + * { margin-top: $gap_style; margin-bottom: 0; }";
}
} elseif ( 'flex' === $layout_type ) {
$layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] : 'horizontal';
Expand All @@ -96,7 +98,8 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
$style = "$selector {";
$style .= 'display: flex;';
if ( $has_block_gap_support ) {
$style .= 'gap: var( --wp--style--block-gap, 0.5em );';
$gap_style = $gap_value ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';
$style .= "gap: $gap_style;";
} else {
$style .= 'gap: 0.5em;';
}
Expand Down Expand Up @@ -156,8 +159,13 @@ function wp_render_layout_support_flag( $block_content, $block ) {
$used_layout = $default_layout;
}

$id = uniqid();
$style = wp_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support );
$id = uniqid();
$gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) );
// Skip if gap value contains unsupported characters.
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
// because we only want to match against the value, not the CSS attribute.
$gap_value = preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value;
$style = wp_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support, $gap_value );
// This assumes the hook only applies to blocks with a single wrapper.
// I think this is a reasonable limitation for that particular hook.
$content = preg_replace(
Expand Down
55 changes: 0 additions & 55 deletions wp-includes/block-supports/spacing.php
Expand Up @@ -95,59 +95,6 @@ function wp_skip_spacing_serialization( $block_type ) {
$spacing_support['__experimentalSkipSerialization'];
}

/**
* Renders the spacing gap support to the block wrapper, to ensure
* that the CSS variable is rendered in all environments.
*
* @since 5.9.0
* @access private
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
* @return string Filtered block content.
*/
function wp_render_spacing_gap_support( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$has_gap_support = block_has_support( $block_type, array( 'spacing', 'blockGap' ), false );
if ( ! $has_gap_support || ! isset( $block['attrs']['style']['spacing']['blockGap'] ) ) {
return $block_content;
}

$gap_value = $block['attrs']['style']['spacing']['blockGap'];

// Skip if gap value contains unsupported characters.
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
// because we only want to match against the value, not the CSS attribute.
if ( preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ) {
return $block_content;
}

$style = sprintf(
'--wp--style--block-gap: %s',
esc_attr( $gap_value )
);

// Attempt to update an existing style attribute on the wrapper element.
$injected_style = preg_replace(
'/^([^>.]+?)(' . preg_quote( 'style="', '/' ) . ')(?=.+?>)/',
'$1$2' . $style . '; ',
$block_content,
1
);

// If there is no existing style attribute, add one to the wrapper element.
if ( $injected_style === $block_content ) {
$injected_style = preg_replace(
'/<([a-zA-Z0-9]+)([ >])/',
'<$1 style="' . $style . '"$2',
$block_content,
1
);
};

return $injected_style;
}

// Register the block support.
WP_Block_Supports::get_instance()->register(
'spacing',
Expand All @@ -156,5 +103,3 @@ function wp_render_spacing_gap_support( $block_content, $block ) {
'apply' => 'wp_apply_spacing_support',
)
);

add_filter( 'render_block', 'wp_render_spacing_gap_support', 10, 2 );
3 changes: 1 addition & 2 deletions wp-includes/blocks/columns/block.json
Expand Up @@ -23,11 +23,10 @@
"link": true
},
"spacing": {
"blockGap": true,
"margin": [ "top", "bottom" ],
"padding": true,
"__experimentalDefaultControls": {
"blockGap": true
"padding": true
}
}
},
Expand Down
12 changes: 1 addition & 11 deletions wp-includes/blocks/navigation/block.json
Expand Up @@ -98,17 +98,7 @@
}
},
"spacing": {
"blockGap": true,
"units": [
"px",
"em",
"rem",
"vh",
"vw"
],
"__experimentalDefaultControls": {
"blockGap": true
}
"units": [ "px", "em", "rem", "vh", "vw" ]
},
"__experimentalLayout": {
"allowSwitching": false,
Expand Down
19 changes: 13 additions & 6 deletions wp-includes/blocks/navigation/editor-rtl.css
Expand Up @@ -293,7 +293,6 @@
}

.wp-block-navigation-placeholder__controls {
padding: 8px;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
Expand All @@ -302,19 +301,23 @@
display: none;
position: relative;
z-index: 1;
padding: 4px 8px;
float: right;
width: 100%;
}
.is-large .wp-block-navigation-placeholder__controls {
padding: 4px 8px;
}
.wp-block-navigation.is-selected .wp-block-navigation-placeholder__controls {
display: flex;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions, .is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions {
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions__indicator,
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions__indicator + hr,
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions > :nth-last-child(3),
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions > :nth-last-child(2) {
display: none;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions {
flex-direction: column;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr, .is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr {
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr {
display: none;
}
.wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__icon {
Expand All @@ -334,6 +337,10 @@
margin-left: 4px;
}

.wp-block-navigation .components-placeholder.is-medium .components-placeholder__fieldset {
flex-direction: row !important;
}

.wp-block-navigation-placeholder__actions {
display: flex;
font-size: 13px;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/blocks/navigation/editor-rtl.min.css

Large diffs are not rendered by default.

19 changes: 13 additions & 6 deletions wp-includes/blocks/navigation/editor.css
Expand Up @@ -293,7 +293,6 @@
}

.wp-block-navigation-placeholder__controls {
padding: 8px;
border-radius: 2px;
background-color: #fff;
box-shadow: inset 0 0 0 1px #1e1e1e;
Expand All @@ -302,19 +301,23 @@
display: none;
position: relative;
z-index: 1;
padding: 4px 8px;
float: left;
width: 100%;
}
.is-large .wp-block-navigation-placeholder__controls {
padding: 4px 8px;
}
.wp-block-navigation.is-selected .wp-block-navigation-placeholder__controls {
display: flex;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions, .is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions {
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions__indicator,
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions__indicator + hr,
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions > :nth-last-child(3),
.is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions > :nth-last-child(2) {
display: none;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions {
flex-direction: column;
}
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr, .is-medium .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr {
.is-small .wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__actions hr {
display: none;
}
.wp-block-navigation-placeholder__controls .wp-block-navigation-placeholder__icon {
Expand All @@ -334,6 +337,10 @@
margin-right: 4px;
}

.wp-block-navigation .components-placeholder.is-medium .components-placeholder__fieldset {
flex-direction: row !important;
}

.wp-block-navigation-placeholder__actions {
display: flex;
font-size: 13px;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/blocks/navigation/editor.min.css

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion wp-includes/blocks/post-content.php
Expand Up @@ -36,11 +36,16 @@ function render_block_core_post_content( $attributes, $content, $block ) {

$seen_ids[ $post_id ] = true;

// Check is needed for backward compatibility with third-party plugins
// that might rely on the `in_the_loop` check; calling `the_post` sets it to true.
if ( ! in_the_loop() && have_posts() ) {
the_post();
}

$content = get_the_content( null, false, $post_id );
// When inside the main loop, we want to use queried object
// so that `the_preview` for the current post can apply.
// We force this behavior by omitting the third argument (post ID) from the `get_the_content`.
$content = get_the_content( null, false );
/** This filter is documented in wp-includes/post-template.php */
$content = apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', $content ) );
unset( $seen_ids[ $post_id ] );
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/blocks/post-excerpt.php
Expand Up @@ -18,7 +18,7 @@ function render_block_core_post_excerpt( $attributes, $content, $block ) {
return '';
}

$excerpt = get_the_excerpt( $block->context['postId'] );
$excerpt = get_the_excerpt();

if ( empty( $excerpt ) ) {
return '';
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/blocks/post-title.php
Expand Up @@ -20,7 +20,7 @@ function render_block_core_post_title( $attributes, $content, $block ) {
}

$post_ID = $block->context['postId'];
$title = get_the_title( $post_ID );
$title = get_the_title();

if ( ! $title ) {
return '';
Expand Down
17 changes: 17 additions & 0 deletions wp-includes/blocks/site-logo.php
Expand Up @@ -76,6 +76,23 @@ function register_block_core_site_logo_setting() {

add_action( 'rest_api_init', 'register_block_core_site_logo_setting', 10 );

/**
* Register a core site setting for a site icon
*/
function register_block_core_site_icon_setting() {
register_setting(
'general',
'site_icon',
array(
'show_in_rest' => true,
'type' => 'integer',
'description' => __( 'Site icon.' ),
)
);
}

add_action( 'rest_api_init', 'register_block_core_site_icon_setting', 10 );

/**
* Registers the `core/site-logo` block on the server.
*/
Expand Down
6 changes: 5 additions & 1 deletion wp-includes/blocks/site-logo/block.json
Expand Up @@ -16,12 +16,16 @@
"linkTarget": {
"type": "string",
"default": "_self"
},
"shouldSyncIcon": {
"type": "boolean"
}
},
"example": {
"viewportWidth": 500,
"attributes": {
"width": 350
"width": 350,
"className": "block-editor-block-types-list__site-logo-example"
}
},
"supports": {
Expand Down
17 changes: 14 additions & 3 deletions wp-includes/class-wp-theme-json.php
Expand Up @@ -317,7 +317,7 @@ class WP_Theme_JSON {
'spacing' => array(
'margin' => null,
'padding' => null,
'blockGap' => null,
'blockGap' => 'top',
),
'typography' => array(
'fontFamily' => null,
Expand Down Expand Up @@ -472,17 +472,28 @@ private static function sanitize( $input, $valid_block_names, $valid_element_nam

$output = array_intersect_key( $input, array_flip( self::VALID_TOP_LEVEL_KEYS ) );

// Some styles are only meant to be available at the top-level (e.g.: blockGap),
// hence, the schema for blocks & elements should not have them.
$styles_non_top_level = self::VALID_STYLES;
foreach ( array_keys( $styles_non_top_level ) as $section ) {
foreach ( array_keys( $styles_non_top_level[ $section ] ) as $prop ) {
if ( 'top' === $styles_non_top_level[ $section ][ $prop ] ) {
unset( $styles_non_top_level[ $section ][ $prop ] );
}
}
}

// Build the schema based on valid block & element names.
$schema = array();
$schema_styles_elements = array();
foreach ( $valid_element_names as $element ) {
$schema_styles_elements[ $element ] = self::VALID_STYLES;
$schema_styles_elements[ $element ] = $styles_non_top_level;
}
$schema_styles_blocks = array();
$schema_settings_blocks = array();
foreach ( $valid_block_names as $block ) {
$schema_settings_blocks[ $block ] = self::VALID_SETTINGS;
$schema_styles_blocks[ $block ] = self::VALID_STYLES;
$schema_styles_blocks[ $block ] = $styles_non_top_level;
$schema_styles_blocks[ $block ]['elements'] = $schema_styles_elements;
}
$schema['styles'] = self::VALID_STYLES;
Expand Down

0 comments on commit 28a12c8

Please sign in to comment.