<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[53076] trunk: Editor: Backport block support changes from the Gutenberg plugin</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53076">53076</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53076","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>gziolo</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-04-05 12:06:48 +0000 (Tue, 05 Apr 2022)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Editor: Backport block support changes from the Gutenberg plugin
Migrate spacing, border, color, dimensions, elements and typography and associated tests for block supports in the block editor.
Related changes in Gutenberg:
- Include individual serialization changes from https://github.com/WordPress/gutenberg/commit/6de16981c7fef3db7cc4a9d6cfcb0ad85c916c62
- Skip Style Engine integration from https://github.com/WordPress/gutenberg/commit/44925a947fde29feaab512e0adf4291272209d59%60
Props ramonopoly, aaronrobertshaw.
See <a href="https://core.trac.wordpress.org/ticket/55505">#55505</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportsborderphp">trunk/src/wp-includes/block-supports/border.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportscolorsphp">trunk/src/wp-includes/block-supports/colors.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportsdimensionsphp">trunk/src/wp-includes/block-supports/dimensions.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportselementsphp">trunk/src/wp-includes/block-supports/elements.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportsspacingphp">trunk/src/wp-includes/block-supports/spacing.php</a></li>
<li><a href="#trunksrcwpincludesblocksupportstypographyphp">trunk/src/wp-includes/block-supports/typography.php</a></li>
<li><a href="#trunksrcwpsettingsphp">trunk/src/wp-settings.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportscolorsphp">trunk/tests/phpunit/tests/block-supports/colors.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportstypographyphp">trunk/tests/phpunit/tests/block-supports/typography.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblocksupportsutilsphp">trunk/src/wp-includes/block-supports/utils.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportsborderphp">trunk/tests/phpunit/tests/block-supports/border.php</a></li>
<li><a href="#trunktestsphpunittestsblocksupportsspacingphp">trunk/tests/phpunit/tests/block-supports/spacing.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblocksupportsborderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/border.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/border.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/border.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,7 +50,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Border CSS classes and inline styles.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_apply_border_support( $block_type, $block_attributes ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( wp_skip_border_serialization( $block_type ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_should_skip_block_supports_serialization( $block_type, 'border' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -60,7 +60,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Border radius.
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> wp_has_border_feature_support( $block_type, 'radius' ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- isset( $block_attributes['style']['border']['radius'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ isset( $block_attributes['style']['border']['radius'] ) &&
+ ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'radius' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $border_radius = $block_attributes['style']['border']['radius'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,7 +85,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Border style.
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> wp_has_border_feature_support( $block_type, 'style' ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- isset( $block_attributes['style']['border']['style'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ isset( $block_attributes['style']['border']['style'] ) &&
+ ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $border_style = $block_attributes['style']['border']['style'];
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = sprintf( 'border-style: %s;', $border_style );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -93,7 +95,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Border width.
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> wp_has_border_feature_support( $block_type, 'width' ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- isset( $block_attributes['style']['border']['width'] )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ isset( $block_attributes['style']['border']['width'] ) &&
+ ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $border_width = $block_attributes['style']['border']['width'];
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,7 +109,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Border color.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( wp_has_border_feature_support( $block_type, 'color' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if (
+ wp_has_border_feature_support( $block_type, 'color' ) &&
+ ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_border_color = array_key_exists( 'borderColor', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_border_color = isset( $block_attributes['style']['border']['color'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,25 +143,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Checks whether serialization of the current block's border properties should
- * occur.
- *
- * @since 5.8.0
- * @access private
- *
- * @param WP_Block_Type $block_type Block type.
- * @return bool Whether serialization of the current block's border properties
- * should occur.
- */
-function wp_skip_border_serialization( $block_type ) {
- $border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );
-
- return is_array( $border_support ) &&
- array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
- $border_support['__experimentalSkipSerialization'];
-}
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Checks whether the current block type supports the border feature requested.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * If the `__experimentalBorder` support flag is a boolean `true` all border
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportscolorsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/colors.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/colors.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/colors.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -75,8 +75,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if (
</span><span class="cx" style="display: block; padding: 0 10px"> is_array( $color_support ) &&
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- array_key_exists( '__experimentalSkipSerialization', $color_support ) &&
- $color_support['__experimentalSkipSerialization']
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_should_skip_block_supports_serialization( $block_type, 'color' )
</ins><span class="cx" style="display: block; padding: 0 10px"> ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,7 +88,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Text colors.
</span><span class="cx" style="display: block; padding: 0 10px"> // Check support for text colors.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_text_colors_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_text_colors_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'text' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_text_color = array_key_exists( 'textColor', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_text_color = isset( $block_attributes['style']['color']['text'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,7 +105,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Background colors.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_background_colors_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_background_colors_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'background' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_background_color = array_key_exists( 'backgroundColor', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_background_color = isset( $block_attributes['style']['color']['background'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,7 +122,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Gradients.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_gradients_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_gradients_support && ! wp_should_skip_block_supports_serialization( $block_type, 'color', 'gradients' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_gradient = array_key_exists( 'gradient', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_gradient = isset( $block_attributes['style']['color']['gradient'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportsdimensionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/dimensions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/dimensions.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/dimensions.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,7 +4,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This does not include the `spacing` block support even though that visually
</span><span class="cx" style="display: block; padding: 0 10px"> * appears under the "Dimensions" panel in the editor. It remains in its
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * original `spacing.php` file for backwards compatibility.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * original `spacing.php` file for compatibility with core.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @package WordPress
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,7 +51,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Block dimensions CSS classes and inline styles.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_apply_dimensions_support( $block_type, $block_attributes ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( wp_skip_dimensions_serialization( $block_type ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_should_skip_block_supports_serialization( $block_type, '__experimentalDimensions' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,23 +63,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return empty( $styles ) ? array() : array( 'style' => implode( ' ', $styles ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Checks whether serialization of the current block's dimensions properties
- * should occur.
- *
- * @since 5.9.0
- * @access private
- *
- * @param WP_Block_type $block_type Block type.
- * @return bool Whether to serialize spacing support styles & classes.
- */
-function wp_skip_dimensions_serialization( $block_type ) {
- $dimensions_support = _wp_array_get( $block_type->supports, array( '__experimentalDimensions' ), false );
- return is_array( $dimensions_support ) &&
- array_key_exists( '__experimentalSkipSerialization', $dimensions_support ) &&
- $dimensions_support['__experimentalSkipSerialization'];
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Register the block support.
</span><span class="cx" style="display: block; padding: 0 10px"> WP_Block_Supports::get_instance()->register(
</span><span class="cx" style="display: block; padding: 0 10px"> 'dimensions',
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportselementsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/elements.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/elements.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/elements.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -21,6 +21,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $block_content;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
+ $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' );
+
+ if ( $skip_link_color_serialization ) {
+ return $block_content;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $link_color = null;
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $block['attrs'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null );
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportsspacingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/spacing.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/spacing.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/spacing.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,15 +44,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array Block spacing CSS classes and inline styles.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_apply_spacing_support( $block_type, $block_attributes ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( wp_skip_spacing_serialization( $block_type ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_should_skip_block_supports_serialization( $block_type, 'spacing' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $skip_padding = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'padding' );
+ $skip_margin = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'margin' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $styles = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_padding_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_padding_support && ! $skip_padding ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $padding_value = _wp_array_get( $block_attributes, array( 'style', 'spacing', 'padding' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $padding_value ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $padding_value as $key => $value ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -63,7 +65,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_margin_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_margin_support && ! $skip_margin ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $margin_value = _wp_array_get( $block_attributes, array( 'style', 'spacing', 'margin' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $margin_value ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $margin_value as $key => $value ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,24 +79,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return empty( $styles ) ? array() : array( 'style' => implode( ' ', $styles ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/**
- * Checks whether serialization of the current block's spacing properties should
- * occur.
- *
- * @since 5.9.0
- * @access private
- *
- * @param WP_Block_Type $block_type Block type.
- * @return bool Whether to serialize spacing support styles & classes.
- */
-function wp_skip_spacing_serialization( $block_type ) {
- $spacing_support = _wp_array_get( $block_type->supports, array( 'spacing' ), false );
-
- return is_array( $spacing_support ) &&
- array_key_exists( '__experimentalSkipSerialization', $spacing_support ) &&
- $spacing_support['__experimentalSkipSerialization'];
-}
-
</del><span class="cx" style="display: block; padding: 0 10px"> // Register the block support.
</span><span class="cx" style="display: block; padding: 0 10px"> WP_Block_Supports::get_instance()->register(
</span><span class="cx" style="display: block; padding: 0 10px"> 'spacing',
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportstypographyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/block-supports/typography.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/typography.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-includes/block-supports/typography.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -81,8 +81,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $skip_typography_serialization = _wp_array_get( $typography_supports, array( '__experimentalSkipSerialization' ), false );
- if ( $skip_typography_serialization ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( wp_should_skip_block_supports_serialization( $block_type, 'typography' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,7 +98,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $has_text_decoration_support = _wp_array_get( $typography_supports, array( '__experimentalTextDecoration' ), false );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_text_transform_support = _wp_array_get( $typography_supports, array( '__experimentalTextTransform' ), false );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_font_size_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_font_size_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontSize' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_font_size = array_key_exists( 'fontSize', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_font_size = isset( $block_attributes['style']['typography']['fontSize'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,7 +109,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_font_family_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_font_family_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontFamily' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_named_font_family = array_key_exists( 'fontFamily', $block_attributes );
</span><span class="cx" style="display: block; padding: 0 10px"> $has_custom_font_family = isset( $block_attributes['style']['typography']['fontFamily'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -129,7 +128,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_font_style_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_font_style_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $font_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontStyle', 'font-style' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $font_style ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = $font_style;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,7 +135,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_font_weight_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_font_weight_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $font_weight = wp_typography_get_css_variable_inline_style( $block_attributes, 'fontWeight', 'font-weight' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $font_weight ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = $font_weight;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,7 +142,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_line_height_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_line_height_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_line_height = isset( $block_attributes['style']['typography']['lineHeight'] );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $has_line_height ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = sprintf( 'line-height: %s;', $block_attributes['style']['typography']['lineHeight'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -150,7 +149,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_text_decoration_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_text_decoration_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $text_decoration_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textDecoration', 'text-decoration' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $text_decoration_style ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = $text_decoration_style;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,7 +156,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_text_transform_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_text_transform_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $text_transform_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'textTransform', 'text-transform' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $text_transform_style ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = $text_transform_style;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -164,7 +163,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $has_letter_spacing_support ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $has_letter_spacing_support && ! wp_should_skip_block_supports_serialization( $block_type, 'typography', 'letterSpacing' ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $letter_spacing_style = wp_typography_get_css_variable_inline_style( $block_attributes, 'letterSpacing', 'letter-spacing' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $letter_spacing_style ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $styles[] = $letter_spacing_style;
</span></span></pre></div>
<a id="trunksrcwpincludesblocksupportsutilsphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/src/wp-includes/block-supports/utils.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-supports/utils.php (rev 0)
+++ trunk/src/wp-includes/block-supports/utils.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,36 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Block support utility functions.
+ *
+ * @package WordPress
+ * @subpackage Block Supports
+ * @since 6.0.0
+ */
+
+/**
+ * Checks whether serialization of the current block's supported properties
+ * should occur.
+ *
+ * @since 6.0.0
+ * @access private
+ *
+ * @param WP_Block_Type $block_type Block type.
+ * @param string $feature_set Name of block support feature set..
+ * @param string $feature Optional name of individual feature to check.
+ *
+ * @return boolean Whether to serialize block support styles & classes.
+ */
+function wp_should_skip_block_supports_serialization( $block_type, $feature_set, $feature = null ) {
+ if ( ! is_object( $block_type ) || ! $feature_set ) {
+ return false;
+ }
+
+ $path = array( $feature_set, '__experimentalSkipSerialization' );
+ $skip_serialization = _wp_array_get( $block_type->supports, $path, false );
+
+ if ( is_array( $skip_serialization ) ) {
+ return in_array( $feature, $skip_serialization, true );
+ }
+
+ return $skip_serialization;
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/src/wp-includes/block-supports/utils.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunksrcwpsettingsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-settings.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-settings.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/src/wp-settings.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -317,6 +317,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/block-editor.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/block-patterns.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/class-wp-block-supports.php';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+require ABSPATH . WPINC . '/block-supports/utils.php';
</ins><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/block-supports/align.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/block-supports/border.php';
</span><span class="cx" style="display: block; padding: 0 10px"> require ABSPATH . WPINC . '/block-supports/colors.php';
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportsborderphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/block-supports/border.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/border.php (rev 0)
+++ trunk/tests/phpunit/tests/block-supports/border.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,148 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group block-supports
+ */
+class Test_Block_Supports_Border extends WP_UnitTestCase {
+
+ /**
+ * @ticket 55505
+ */
+ function test_border_color_slug_with_numbers_is_kebab_cased_properly() {
+ $block_name = 'test/border-color-slug-with-numbers-is-kebab-cased-properly';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'borderColor' => array(
+ 'type' => 'string',
+ ),
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ '__experimentalBorder' => array(
+ 'color' => true,
+ 'radius' => true,
+ 'width' => true,
+ 'style' => true,
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'borderColor' => 'red',
+ 'style' => array(
+ 'border' => array(
+ 'radius' => '10px',
+ 'width' => '1px',
+ 'style' => 'dashed',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_border_support( $block_type, $block_atts );
+ $expected = array(
+ 'class' => 'has-border-color has-red-border-color',
+ 'style' => 'border-radius: 10px; border-style: dashed; border-width: 1px;',
+ );
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_border_with_skipped_serialization_block_supports() {
+ $block_name = 'test/border-with-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ '__experimentalBorder' => array(
+ 'color' => true,
+ 'radius' => true,
+ 'width' => true,
+ 'style' => true,
+ '__experimentalSkipSerialization' => true,
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'border' => array(
+ 'color' => '#eeeeee',
+ 'width' => '1px',
+ 'style' => 'dotted',
+ 'radius' => '10px',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_border_support( $block_type, $block_atts );
+ $expected = array();
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_radius_with_individual_skipped_serialization_block_supports() {
+ $block_name = 'test/radius-with-individual-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ '__experimentalBorder' => array(
+ 'color' => true,
+ 'radius' => true,
+ 'width' => true,
+ 'style' => true,
+ '__experimentalSkipSerialization' => array( 'radius', 'color' ),
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'border' => array(
+ 'color' => '#eeeeee',
+ 'width' => '1px',
+ 'style' => 'dotted',
+ 'radius' => '10px',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_border_support( $block_type, $block_atts );
+ $expected = array(
+ 'style' => 'border-style: dotted; border-width: 1px;',
+ );
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/block-supports/border.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestsblocksupportscolorsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/block-supports/colors.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/colors.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/tests/phpunit/tests/block-supports/colors.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,4 +44,90 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $actual );
</span><span class="cx" style="display: block; padding: 0 10px"> unregister_block_type( 'test/color-slug-with-numbers' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @ticket 55505
+ */
+ function test_color_with_skipped_serialization_block_supports() {
+ $block_name = 'test/color-with-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'color' => array(
+ 'text' => true,
+ 'gradients' => true,
+ '__experimentalSkipSerialization' => true,
+ ),
+ ),
+ )
+ );
+
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#d92828',
+ 'gradient' => 'linear-gradient(135deg,rgb(6,147,227) 0%,rgb(223,13,13) 46%,rgb(155,81,224) 100%)',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_colors_support( $block_type, $block_atts );
+ $expected = array();
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_gradient_with_individual_skipped_serialization_block_supports() {
+ $block_name = 'test/gradient-with-individual-skipped-serialization-block-support';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'color' => array(
+ 'text' => true,
+ 'gradients' => true,
+ '__experimentalSkipSerialization' => array( 'gradients' ),
+ ),
+ ),
+ )
+ );
+
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'color' => array(
+ 'text' => '#d92828',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_colors_support( $block_type, $block_atts );
+ $expected = array(
+ 'class' => 'has-text-color',
+ 'style' => 'color: #d92828;',
+ );
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksupportsspacingphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/block-supports/spacing.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/spacing.php (rev 0)
+++ trunk/tests/phpunit/tests/block-supports/spacing.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,153 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * @group block-supports
+ */
+class Test_Block_Supports_Spacing extends WP_UnitTestCase {
+
+ /**
+ * @ticket 55505
+ */
+ function test_spacing_style_is_applied() {
+ $block_name = 'test/spacing-style-is-applied';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'spacing' => array(
+ 'margin' => true,
+ 'padding' => true,
+ 'blockGap' => true,
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'spacing' => array(
+ 'margin' => array(
+ 'top' => '1px',
+ 'right' => '2px',
+ 'bottom' => '3px',
+ 'left' => '4px',
+ ),
+ 'padding' => '111px',
+ 'blockGap' => '2em',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_spacing_support( $block_type, $block_atts );
+ $expected = array(
+ 'style' => 'padding: 111px; margin-top: 1px; margin-right: 2px; margin-bottom: 3px; margin-left: 4px;',
+ );
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_spacing_with_skipped_serialization_block_supports() {
+ $block_name = 'test/spacing-with-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'spacing' => array(
+ 'margin' => true,
+ 'padding' => true,
+ 'blockGap' => true,
+ '__experimentalSkipSerialization' => true,
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'spacing' => array(
+ 'margin' => array(
+ 'top' => '1px',
+ 'right' => '2px',
+ 'bottom' => '3px',
+ 'left' => '4px',
+ ),
+ 'padding' => '111px',
+ 'blockGap' => '2em',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_spacing_support( $block_type, $block_atts );
+ $expected = array();
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_margin_with_individual_skipped_serialization_block_supports() {
+ $block_name = 'test/margin-with-individual-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'spacing' => array(
+ 'margin' => true,
+ 'padding' => true,
+ 'blockGap' => true,
+ '__experimentalSkipSerialization' => array( 'margin' ),
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'spacing' => array(
+ 'padding' => array(
+ 'top' => '1px',
+ 'right' => '2px',
+ 'bottom' => '3px',
+ 'left' => '4px',
+ ),
+ 'margin' => '111px',
+ 'blockGap' => '2em',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_spacing_support( $block_type, $block_atts );
+ $expected = array(
+ 'style' => 'padding-top: 1px; padding-right: 2px; padding-bottom: 3px; padding-left: 4px;',
+ );
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/block-supports/spacing.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span><a id="trunktestsphpunittestsblocksupportstypographyphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/block-supports/typography.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/block-supports/typography.php 2022-04-05 11:47:14 UTC (rev 53075)
+++ trunk/tests/phpunit/tests/block-supports/typography.php 2022-04-05 12:06:48 UTC (rev 53076)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,6 +62,86 @@
</span><span class="cx" style="display: block; padding: 0 10px"> unregister_block_type( $block_name );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * @ticket 55505
+ */
+ function test_typography_with_skipped_serialization_block_supports() {
+ $block_name = 'test/typography-with-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'typography' => array(
+ 'fontSize' => true,
+ 'lineHeight' => true,
+ '__experimentalFontFamily' => true,
+ '__experimentalLetterSpacing' => true,
+ '__experimentalSkipSerialization' => true,
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array(
+ 'style' => array(
+ 'typography' => array(
+ 'fontSize' => 'serif',
+ 'lineHeight' => 'serif',
+ 'fontFamily' => '22px',
+ 'letterSpacing' => '22px',
+ ),
+ ),
+ );
+
+ $actual = wp_apply_typography_support( $block_type, $block_atts );
+ $expected = array();
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
+ /**
+ * @ticket 55505
+ */
+ function test_letter_spacing_with_individual_skipped_serialization_block_supports() {
+ $block_name = 'test/letter-spacing-with-individua-skipped-serialization-block-supports';
+ register_block_type(
+ $block_name,
+ array(
+ 'api_version' => 2,
+ 'attributes' => array(
+ 'style' => array(
+ 'type' => 'object',
+ ),
+ ),
+ 'supports' => array(
+ 'typography' => array(
+ '__experimentalLetterSpacing' => true,
+ '__experimentalSkipSerialization' => array(
+ 'letterSpacing',
+ ),
+ ),
+ ),
+ )
+ );
+ $registry = WP_Block_Type_Registry::get_instance();
+ $block_type = $registry->get_registered( $block_name );
+ $block_atts = array( 'style' => array( 'typography' => array( 'letterSpacing' => '22px' ) ) );
+
+ $actual = wp_apply_typography_support( $block_type, $block_atts );
+ $expected = array();
+
+ $this->assertSame( $expected, $actual );
+ unregister_block_type( $block_name );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function test_font_family_with_legacy_inline_styles_using_a_css_var() {
</span><span class="cx" style="display: block; padding: 0 10px"> $block_name = 'test/font-family-with-inline-styles-using-css-var';
</span><span class="cx" style="display: block; padding: 0 10px"> register_block_type(
</span></span></pre>
</div>
</div>
</body>
</html>