<!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>[54155] trunk: Blocks: Allow registering multiple items for all supported asset types</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/54155">54155</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/54155","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-09-14 10:50:26 +0000 (Wed, 14 Sep 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'>Blocks: Allow registering multiple items for all supported asset types
Follow-up <a href="https://core.trac.wordpress.org/ticket/54337">#54337</a>, <a href="https://core.trac.wordpress.org/changeset/52069">[52069]</a>. Part of https://github.com/WordPress/gutenberg/issues/41236. More details in https://github.com/WordPress/gutenberg/issues/33542.
Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.
This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.
Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes <a href="https://core.trac.wordpress.org/ticket/56408">#56408</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesblockeditorphp">trunk/src/wp-includes/block-editor.php</a></li>
<li><a href="#trunksrcwpincludesblocksphp">trunk/src/wp-includes/blocks.php</a></li>
<li><a href="#trunksrcwpincludesclasswpblocktypephp">trunk/src/wp-includes/class-wp-block-type.php</a></li>
<li><a href="#trunksrcwpincludesclasswpblockphp">trunk/src/wp-includes/class-wp-block.php</a></li>
<li><a href="#trunksrcwpincludesdeprecatedphp">trunk/src/wp-includes/deprecated.php</a></li>
<li><a href="#trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp">trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunktestsphpunitdatablocksnoticeblockjson">trunk/tests/phpunit/data/blocks/notice/block.json</a></li>
<li><a href="#trunktestsphpunittestsblocksregisterphp">trunk/tests/phpunit/tests/blocks/register.php</a></li>
<li><a href="#trunktestsphpunittestsrestapirestblocktypecontrollerphp">trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesblockeditorphp"></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-editor.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/block-editor.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/block-editor.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -324,17 +324,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $block_registry = WP_Block_Type_Registry::get_instance();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $block_registry->get_all_registered() as $block_type ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $block_type->style ) ) {
- $style_handles[] = $block_type->style;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $style_handles = array_merge(
+ $style_handles,
+ $block_type->style_handles,
+ $block_type->editor_style_handles
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! empty( $block_type->editor_style ) ) {
- $style_handles[] = $block_type->editor_style;
- }
-
- if ( ! empty( $block_type->script ) ) {
- $script_handles[] = $block_type->script;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script_handles = array_merge(
+ $script_handles,
+ $block_type->script_handles
+ );
</ins><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"> $style_handles = array_unique( $style_handles );
</span></span></pre></div>
<a id="trunksrcwpincludesblocksphp"></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/blocks.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/blocks.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/blocks.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -35,12 +35,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * and the field name provided.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Added `$index` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $block_name Name of the block.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $field_name Name of the metadata field.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $index Optional. Index of the asset when multiple items passed.
+ * Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string Generated asset name for the block's field.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function generate_block_asset_handle( $block_name, $field_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function generate_block_asset_handle( $block_name, $field_name, $index = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( 0 === strpos( $block_name, 'core/' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $asset_handle = str_replace( 'core/', 'wp-block-', $block_name );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 0 === strpos( $field_name, 'editor' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -49,6 +52,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 0 === strpos( $field_name, 'view' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $asset_handle .= '-view';
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $index > 0 ) {
+ $asset_handle .= '-' . ( $index + 1 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> return $asset_handle;
</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">@@ -59,8 +65,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'editorStyle' => 'editor-style',
</span><span class="cx" style="display: block; padding: 0 10px"> 'style' => 'style',
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return str_replace( '/', '-', $block_name ) .
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $asset_handle = str_replace( '/', '-', $block_name ) .
</ins><span class="cx" style="display: block; padding: 0 10px"> '-' . $field_mappings[ $field_name ];
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $index > 0 ) {
+ $asset_handle .= '-' . ( $index + 1 );
+ }
+ return $asset_handle;
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,23 +80,34 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * generated handle name. It returns unprocessed script handle otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Added `$index` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $metadata Block metadata.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $field_name Field name to pick from metadata.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $index Optional. Index of the script to register when multiple items passed.
+ * Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Script handle provided directly or created through
</span><span class="cx" style="display: block; padding: 0 10px"> * script's registration, or false on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function register_block_script_handle( $metadata, $field_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function register_block_script_handle( $metadata, $field_name, $index = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $metadata[ $field_name ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $script_handle = $metadata[ $field_name ];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $script_path = remove_block_asset_path_prefix( $metadata[ $field_name ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $script_handle ) ) {
+ if ( empty( $script_handle[ $index ] ) ) {
+ return false;
+ }
+ $script_handle = $script_handle[ $index ];
+ }
+
+ $script_path = remove_block_asset_path_prefix( $script_handle );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $script_handle === $script_path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $script_handle;
</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">- $script_handle = generate_block_asset_handle( $metadata['name'], $field_name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index );
</ins><span class="cx" style="display: block; padding: 0 10px"> $script_asset_path = wp_normalize_path(
</span><span class="cx" style="display: block; padding: 0 10px"> realpath(
</span><span class="cx" style="display: block; padding: 0 10px"> dirname( $metadata['file'] ) . '/' .
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -145,33 +166,49 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * generated handle name. It returns unprocessed style handle otherwise.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Added `$index` parameter.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param array $metadata Block metadata.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $field_name Field name to pick from metadata.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param int $index Optional. Index of the style to register when multiple items passed.
+ * Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string|false Style handle provided directly or created through
</span><span class="cx" style="display: block; padding: 0 10px"> * style's registration, or false on failure.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function register_block_style_handle( $metadata, $field_name ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function register_block_style_handle( $metadata, $field_name, $index = 0 ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $metadata[ $field_name ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $theme_path_norm = wp_normalize_path( get_theme_file_path() );
</span><span class="cx" style="display: block; padding: 0 10px"> $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Skip registering individual styles for each core block when a bundled version provided.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</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">- // Check whether styles should have a ".min" suffix or not.
- $suffix = SCRIPT_DEBUG ? '' : '.min';
-
</del><span class="cx" style="display: block; padding: 0 10px"> $style_handle = $metadata[ $field_name ];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $style_path = remove_block_asset_path_prefix( $metadata[ $field_name ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_array( $style_handle ) ) {
+ if ( empty( $style_handle[ $index ] ) ) {
+ return false;
+ }
+ $style_handle = $style_handle[ $index ];
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $style_handle === $style_path && ! $is_core_block ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $style_path = remove_block_asset_path_prefix( $style_handle );
+ $is_style_handle = $style_handle === $style_path;
+ // Allow only passing style handles for core blocks.
+ if ( $is_core_block && ! $is_style_handle ) {
+ return false;
+ }
+ // Return the style handle unless it's the first item for every core block that requires special treatment.
+ if ( $is_style_handle && ! ( $is_core_block && 0 === $index ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return $style_handle;
</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">+ // Check whether styles should have a ".min" suffix or not.
+ $suffix = SCRIPT_DEBUG ? '' : '.min';
</ins><span class="cx" style="display: block; padding: 0 10px"> $style_uri = plugins_url( $style_path, $metadata['file'] );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $is_core_block ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $style_path = "style$suffix.css";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -185,9 +222,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) );
</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">- $style_handle = generate_block_asset_handle( $metadata['name'], $field_name );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $style_handle = generate_block_asset_handle( $metadata['name'], $field_name, $index );
</ins><span class="cx" style="display: block; padding: 0 10px"> $block_dir = dirname( $metadata['file'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $style_file = realpath( "$block_dir/$style_path" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $style_file = wp_normalize_path( realpath( "$block_dir/$style_path" ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $has_style_file = false !== $style_file;
</span><span class="cx" style="display: block; padding: 0 10px"> $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
</span><span class="cx" style="display: block; padding: 0 10px"> $style_uri = $has_style_file ? $style_uri : false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -311,41 +348,71 @@
</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 ( ! empty( $metadata['editorScript'] ) ) {
- $settings['editor_script'] = register_block_script_handle(
- $metadata,
- 'editorScript'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $script_fields = array(
+ 'editorScript' => 'editor_script_handles',
+ 'script' => 'script_handles',
+ 'viewScript' => 'view_script_handles',
+ );
+ foreach ( $script_fields as $metadata_field_name => $settings_field_name ) {
+ if ( ! empty( $metadata[ $metadata_field_name ] ) ) {
+ $scripts = $metadata[ $metadata_field_name ];
+ $processed_scripts = array();
+ if ( is_array( $scripts ) ) {
+ for ( $index = 0; $index < count( $scripts ); $index++ ) {
+ $result = register_block_script_handle(
+ $metadata,
+ $metadata_field_name,
+ $index
+ );
+ if ( $result ) {
+ $processed_scripts[] = $result;
+ }
+ }
+ } else {
+ $result = register_block_script_handle(
+ $metadata,
+ $metadata_field_name
+ );
+ if ( $result ) {
+ $processed_scripts[] = $result;
+ }
+ }
+ $settings[ $settings_field_name ] = $processed_scripts;
+ }
</ins><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 ( ! empty( $metadata['script'] ) ) {
- $settings['script'] = register_block_script_handle(
- $metadata,
- 'script'
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $style_fields = array(
+ 'editorStyle' => 'editor_style_handles',
+ 'style' => 'style_handles',
+ );
+ foreach ( $style_fields as $metadata_field_name => $settings_field_name ) {
+ if ( ! empty( $metadata[ $metadata_field_name ] ) ) {
+ $styles = $metadata[ $metadata_field_name ];
+ $processed_styles = array();
+ if ( is_array( $styles ) ) {
+ for ( $index = 0; $index < count( $styles ); $index++ ) {
+ $result = register_block_style_handle(
+ $metadata,
+ $metadata_field_name,
+ $index
+ );
+ if ( $result ) {
+ $processed_styles[] = $result;
+ }
+ }
+ } else {
+ $result = register_block_style_handle(
+ $metadata,
+ $metadata_field_name
+ );
+ if ( $result ) {
+ $processed_styles[] = $result;
+ }
+ }
+ $settings[ $settings_field_name ] = $processed_styles;
+ }
</ins><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 ( ! empty( $metadata['viewScript'] ) ) {
- $settings['view_script'] = register_block_script_handle(
- $metadata,
- 'viewScript'
- );
- }
-
- if ( ! empty( $metadata['editorStyle'] ) ) {
- $settings['editor_style'] = register_block_style_handle(
- $metadata,
- 'editorStyle'
- );
- }
-
- if ( ! empty( $metadata['style'] ) ) {
- $settings['style'] = register_block_style_handle(
- $metadata,
- 'style'
- );
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $metadata['render'] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $template_path = wp_normalize_path(
</span><span class="cx" style="display: block; padding: 0 10px"> realpath(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1262,49 +1329,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">- * Allows multiple block styles.
- *
- * @since 5.9.0
- *
- * @param array $metadata Metadata for registering a block type.
- * @return array Metadata for registering a block type.
- */
-function _wp_multiple_block_styles( $metadata ) {
- foreach ( array( 'style', 'editorStyle' ) as $key ) {
- if ( ! empty( $metadata[ $key ] ) && is_array( $metadata[ $key ] ) ) {
- $default_style = array_shift( $metadata[ $key ] );
- foreach ( $metadata[ $key ] as $handle ) {
- $args = array( 'handle' => $handle );
- if ( 0 === strpos( $handle, 'file:' ) && isset( $metadata['file'] ) ) {
- $style_path = remove_block_asset_path_prefix( $handle );
- $theme_path_norm = wp_normalize_path( get_theme_file_path() );
- $style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) );
- $is_theme_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $theme_path_norm );
-
- $style_uri = plugins_url( $style_path, $metadata['file'] );
-
- if ( $is_theme_block ) {
- $style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) );
- }
-
- $args = array(
- 'handle' => sanitize_key( "{$metadata['name']}-{$style_path}" ),
- 'src' => $style_uri,
- );
- }
-
- wp_enqueue_block_style( $metadata['name'], $args );
- }
-
- // Only return the 1st item in the array.
- $metadata[ $key ] = $default_style;
- }
- }
- return $metadata;
-}
-add_filter( 'block_type_metadata', '_wp_multiple_block_styles' );
-
-/**
</del><span class="cx" style="display: block; padding: 0 10px"> * Helper function that constructs a comment query vars array from the passed
</span><span class="cx" style="display: block; padding: 0 10px"> * block properties.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpblocktypephp"></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/class-wp-block-type.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-block-type.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/class-wp-block-type.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -166,46 +166,60 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $provides_context = null;
</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">- * Block type editor only script handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block type editor only script handles.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
- * @var string|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0
+ * @var string[]
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $editor_script = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $editor_script_handles = array();
</ins><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">- * Block type front end and editor script handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block type front end and editor script handles.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
- * @var string|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0
+ * @var string[]
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $script = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $script_handles = array();
</ins><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">- * Block type front end only script handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block type front end only script handles.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.9.0
- * @var string|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0
+ * @var string[]
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $view_script = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $view_script_handles = array();
</ins><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">- * Block type editor only style handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block type editor only style handles.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
- * @var string|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0
+ * @var string[]
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $editor_style = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $editor_style_handles = array();
</ins><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">- * Block type front end and editor style handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Block type front end and editor style handles.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @since 5.0.0
- * @var string|null
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0
+ * @var string[]
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public $style = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $style_handles = array();
</ins><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">+ * Deprecated block type properties for script and style handles.
+ *
+ * @since 6.1.0
+ * @var string[]
+ */
+ private $deprecated_properties = array(
+ 'editor_script',
+ 'script',
+ 'view_script',
+ 'editor_style',
+ 'style',
+ );
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Attributes supported by every block.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.0.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -228,6 +242,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.8.0 Added the `variations` property.
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.9.0 Added the `view_script` property.
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 6.0.0 Added the `ancestor` property.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.1.0 Added the `editor_script_handles`, `script_handles`, `view_script_handles,
+ * `editor_style_handles`, and `style_handles` properties.
+ * Deprecated the `editor_script`, `script`, `view_script`, `editor_style`, and `style` properties.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @see register_block_type()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -236,32 +253,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Optional. Array or string of arguments for registering a block type. Any arguments may be defined,
</span><span class="cx" style="display: block; padding: 0 10px"> * however the ones described below are supported by default. Default empty 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">- * @type string $api_version Block API version.
- * @type string $title Human-readable block type label.
- * @type string|null $category Block type category classification, used in
- * search interfaces to arrange block types by category.
- * @type string[]|null $parent Setting parent lets a block require that it is only
- * available when nested within the specified blocks.
- * @type string[]|null $ancestor Setting ancestor makes a block available only inside the specified
- * block types at any position of the ancestor's block subtree.
- * @type string|null $icon Block type icon.
- * @type string $description A detailed block type description.
- * @type string[] $keywords Additional keywords to produce block type as
- * result in search interfaces.
- * @type string|null $textdomain The translation textdomain.
- * @type array[] $styles Alternative block styles.
- * @type array[] $variations Block variations.
- * @type array|null $supports Supported features.
- * @type array|null $example Structured data for the block preview.
- * @type callable|null $render_callback Block type render callback.
- * @type array|null $attributes Block type attributes property schemas.
- * @type string[] $uses_context Context values inherited by blocks of this type.
- * @type string[]|null $provides_context Context provided by blocks of this type.
- * @type string|null $editor_script Block type editor only script handle.
- * @type string|null $script Block type front end and editor script handle.
- * @type string|null $view_script Block type front end only script handle.
- * @type string|null $editor_style Block type editor only style handle.
- * @type string|null $style Block type front end and editor style handle.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string $api_version Block API version.
+ * @type string $title Human-readable block type label.
+ * @type string|null $category Block type category classification, used in
+ * search interfaces to arrange block types by category.
+ * @type string[]|null $parent Setting parent lets a block require that it is only
+ * available when nested within the specified blocks.
+ * @type string[]|null $ancestor Setting ancestor makes a block available only inside the specified
+ * block types at any position of the ancestor's block subtree.
+ * @type string|null $icon Block type icon.
+ * @type string $description A detailed block type description.
+ * @type string[] $keywords Additional keywords to produce block type as
+ * result in search interfaces.
+ * @type string|null $textdomain The translation textdomain.
+ * @type array[] $styles Alternative block styles.
+ * @type array[] $variations Block variations.
+ * @type array|null $supports Supported features.
+ * @type array|null $example Structured data for the block preview.
+ * @type callable|null $render_callback Block type render callback.
+ * @type array|null $attributes Block type attributes property schemas.
+ * @type string[] $uses_context Context values inherited by blocks of this type.
+ * @type string[]|null $provides_context Context provided by blocks of this type.
+ * @type string[] $editor_script_handles Block type editor only script handles.
+ * @type string[] $script_handles Block type front end and editor script handles.
+ * @type string[] $view_script_handles Block type front end only script handles.
+ * @type string[] $editor_style_handles Block type editor only style handles.
+ * @type string[] $style_handles Block type front end and editor style handles.
</ins><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"> public function __construct( $block_type, $args = array() ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,6 +288,70 @@
</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><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Proxies getting values for deprecated properties for script and style handles for backward compatibility.
+ * Gets the value for the corresponding new property if the first item in the array provided.
+ *
+ * @since 6.1.0
+ *
+ * @param string $name Deprecated property name.
+ *
+ * @return string|null|void The value read from the new property if the first item in the array provided,
+ * null when value not found, or void when unknown property name provided.
+ */
+ public function __get( $name ) {
+ if ( ! in_array( $name, $this->deprecated_properties ) ) {
+ return;
+ }
+
+ $new_name = $name . '_handles';
+ return isset( $this->{$new_name }[0] ) ? $this->{$new_name }[0] : null;
+ }
+
+ /**
+ * Proxies checking for deprecated properties for script and style handles for backward compatibility.
+ * Checks whether the corresponding new property has the first item in the array provided.
+ *
+ * @since 6.1.0
+ *
+ * @param string $name Deprecated property name.
+ *
+ * @return boolean Returns true when for the new property the first item in the array exists,
+ * or false otherwise.
+ */
+ public function __isset( $name ) {
+ if ( ! in_array( $name, $this->deprecated_properties ) ) {
+ return false;
+ }
+
+ $new_name = $name . '_handles';
+ return isset( $this->{$new_name }[0] );
+ }
+
+ /**
+ * Proxies setting values for deprecated properties for script and style handles for backward compatibility.
+ * Sets the value for the corresponding new property as the first item in the array.
+ * It also allows setting custom properties for backward compatibility.
+ *
+ * @since 6.1.0
+ *
+ * @param string $name Property name.
+ * @param mixed $value Property value.
+ */
+ public function __set( $name, $value ) {
+ if ( ! in_array( $name, $this->deprecated_properties ) ) {
+ $this->{$name} = $value;
+ return;
+ }
+
+ if ( ! is_string( $value ) ) {
+ return;
+ }
+
+ $new_name = $name . '_handles';
+ $this->{$new_name }[0] = $value;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * Renders the block type output for given attributes.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 5.0.0
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpblockphp"></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/class-wp-block.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-block.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/class-wp-block.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,16 +260,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $post = $global_post;
</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 ( ! empty( $this->block_type->script ) ) {
- wp_enqueue_script( $this->block_type->script );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( ! empty( $this->block_type->script_handles ) ) ) {
+ foreach ( $this->block_type->script_handles as $script_handle ) {
+ wp_enqueue_script( $script_handle );
+ }
</ins><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 ( ! empty( $this->block_type->view_script ) && empty( $this->block_type->render_callback ) ) {
- wp_enqueue_script( $this->block_type->view_script );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! empty( $this->block_type->view_script_handles ) && empty( $this->block_type->render_callback ) ) {
+ foreach ( $this->block_type->view_script_handles as $view_script_handle ) {
+ wp_enqueue_script( $view_script_handle );
+ }
</ins><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 ( ! empty( $this->block_type->style ) ) {
- wp_enqueue_style( $this->block_type->style );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ( ! empty( $this->block_type->style_handles ) ) ) {
+ foreach ( $this->block_type->style_handles as $style_handle ) {
+ wp_enqueue_style( $style_handle );
+ }
</ins><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></span></pre></div>
<a id="trunksrcwpincludesdeprecatedphp"></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/deprecated.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/deprecated.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/deprecated.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4442,3 +4442,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+/**
+ * Allows multiple block styles.
+ *
+ * @since 5.9.0
+ * @deprecated 6.1.0
+ *
+ * @param array $metadata Metadata for registering a block type.
+ * @return array Metadata for registering a block type.
+ */
+ function _wp_multiple_block_styles( $metadata ) {
+ _deprecated_function( __FUNCTION__, '6.1.0' );
+ return $metadata;
+}
</ins></span></pre></div>
<a id="trunksrcwpincludesrestapiendpointsclasswprestblocktypescontrollerphp"></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/rest-api/endpoints/class-wp-rest-block-types-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -256,30 +256,41 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $data['is_dynamic'] = $block_type->is_dynamic();
</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">- $schema = $this->get_item_schema();
- $extra_fields = array(
- 'api_version',
- 'name',
- 'title',
- 'description',
- 'icon',
- 'category',
- 'keywords',
- 'parent',
- 'ancestor',
- 'provides_context',
- 'uses_context',
- 'supports',
- 'styles',
- 'textdomain',
- 'example',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $schema = $this->get_item_schema();
+ // Fields deprecated in WordPress 6.1, but left in the schema for backwards compatibility.
+ $deprecated_fields = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'editor_script',
</span><span class="cx" style="display: block; padding: 0 10px"> 'script',
</span><span class="cx" style="display: block; padding: 0 10px"> 'view_script',
</span><span class="cx" style="display: block; padding: 0 10px"> 'editor_style',
</span><span class="cx" style="display: block; padding: 0 10px"> 'style',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'variations',
</del><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $extra_fields = array_merge(
+ array(
+ 'api_version',
+ 'name',
+ 'title',
+ 'description',
+ 'icon',
+ 'category',
+ 'keywords',
+ 'parent',
+ 'ancestor',
+ 'provides_context',
+ 'uses_context',
+ 'supports',
+ 'styles',
+ 'textdomain',
+ 'example',
+ 'editor_script_handles',
+ 'script_handles',
+ 'view_script_handles',
+ 'editor_style_handles',
+ 'style_handles',
+ 'variations',
+ ),
+ $deprecated_fields
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $extra_fields as $extra_field ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( rest_is_field_included( $extra_field, $fields ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $block_type->$extra_field ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -437,12 +448,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</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">- $schema = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->schema = array(
</ins><span class="cx" style="display: block; padding: 0 10px"> '$schema' => 'http://json-schema.org/draft-04/schema#',
</span><span class="cx" style="display: block; padding: 0 10px"> 'title' => 'block-type',
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'api_version' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'api_version' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Version of block API.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'integer',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => 1,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -449,7 +460,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'title' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'title' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Title of block type.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'string',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -456,7 +467,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'name' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'name' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Unique name identifying the block type.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'string',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -463,7 +474,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'description' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'description' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Description of block type.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'string',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => '',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -470,8 +481,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'icon' => $icon_definition,
- 'attributes' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'icon' => $icon_definition,
+ 'attributes' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Block attributes.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => array( 'object', 'null' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -482,7 +493,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'provides_context' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'provides_context' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Context provided by blocks of this type.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="cx" style="display: block; padding: 0 10px"> 'properties' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -493,7 +504,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'uses_context' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'uses_context' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Context values inherited by blocks of this type.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'array',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -503,7 +514,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'supports' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'supports' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Block supports.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'object',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => array(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -511,8 +522,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'category' => $category_definition,
- 'is_dynamic' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'category' => $category_definition,
+ 'is_dynamic' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Is the block dynamically rendered.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'boolean',
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => false,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -519,42 +530,57 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'editor_script' => array(
- 'description' => __( 'Editor script handle.' ),
- 'type' => array( 'string', 'null' ),
- 'default' => null,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'editor_script_handles' => array(
+ 'description' => __( 'Editor script handles.' ),
+ 'type' => array( 'array' ),
+ 'default' => array(),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'script' => array(
- 'description' => __( 'Public facing and editor script handle.' ),
- 'type' => array( 'string', 'null' ),
- 'default' => null,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'script_handles' => array(
+ 'description' => __( 'Public facing and editor script handles.' ),
+ 'type' => array( 'array' ),
+ 'default' => array(),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'view_script' => array(
- 'description' => __( 'Public facing script handle.' ),
- 'type' => array( 'string', 'null' ),
- 'default' => null,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'view_script_handles' => array(
+ 'description' => __( 'Public facing script handles.' ),
+ 'type' => array( 'array' ),
+ 'default' => array(),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'editor_style' => array(
- 'description' => __( 'Editor style handle.' ),
- 'type' => array( 'string', 'null' ),
- 'default' => null,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'editor_style_handles' => array(
+ 'description' => __( 'Editor style handles.' ),
+ 'type' => array( 'array' ),
+ 'default' => array(),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'style' => array(
- 'description' => __( 'Public facing and editor style handle.' ),
- 'type' => array( 'string', 'null' ),
- 'default' => null,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'style_handles' => array(
+ 'description' => __( 'Public facing and editor style handles.' ),
+ 'type' => array( 'array' ),
+ 'default' => array(),
+ 'items' => array(
+ 'type' => 'string',
+ ),
</ins><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'styles' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'styles' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Block style variations.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'array',
</span><span class="cx" style="display: block; padding: 0 10px"> 'items' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -583,7 +609,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'variations' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'variations' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Block variations.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'array',
</span><span class="cx" style="display: block; padding: 0 10px"> 'items' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -635,7 +661,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => null,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'textdomain' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'textdomain' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Public text domain.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => array( 'string', 'null' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'default' => null,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -642,7 +668,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'parent' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'parent' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Parent blocks.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => array( 'array', 'null' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'items' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -652,7 +678,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'context' => array( 'embed', 'view', 'edit' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'readonly' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'ancestor' => array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'ancestor' => array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'description' => __( 'Ancestor blocks.' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => array( 'array', 'null' ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'items' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -667,7 +693,45 @@
</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">- $this->schema = $schema;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Properties deprecated in WordPress 6.1, but left in the schema for backwards compatibility.
+ $deprecated_properties = array(
+ 'editor_script' => array(
+ 'description' => __( 'Editor script handle. DEPRECATED: Use `editor_script_handles` instead.' ),
+ 'type' => array( 'string', 'null' ),
+ 'default' => null,
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
+ 'script' => array(
+ 'description' => __( 'Public facing and editor script handle. DEPRECATED: Use `script_handles` instead.' ),
+ 'type' => array( 'string', 'null' ),
+ 'default' => null,
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
+ 'view_script' => array(
+ 'description' => __( 'Public facing script handle. DEPRECATED: Use `view_script_handles` instead.' ),
+ 'type' => array( 'string', 'null' ),
+ 'default' => null,
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
+ 'editor_style' => array(
+ 'description' => __( 'Editor style handle. DEPRECATED: Use `editor_style_handles` instead.' ),
+ 'type' => array( 'string', 'null' ),
+ 'default' => null,
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
+ 'style' => array(
+ 'description' => __( 'Public facing and editor style handle. DEPRECATED: Use `style_handles` instead.' ),
+ 'type' => array( 'string', 'null' ),
+ 'default' => null,
+ 'context' => array( 'embed', 'view', 'edit' ),
+ 'readonly' => true,
+ ),
+ );
+ $this->schema['properties'] = array_merge( $this->schema['properties'], $deprecated_properties );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->add_additional_fields_schema( $this->schema );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></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/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/src/wp-includes/script-loader.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2531,28 +2531,30 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</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">- $load_editor_scripts = is_admin() && wp_should_load_block_editor_scripts_and_styles();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $load_editor_scripts_and_styles = is_admin() && wp_should_load_block_editor_scripts_and_styles();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $block_registry = WP_Block_Type_Registry::get_instance();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Front-end styles.
- if ( ! empty( $block_type->style ) ) {
- wp_enqueue_style( $block_type->style );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Front-end and editor styles.
+ foreach ( $block_type->style_handles as $style_handle ) {
+ wp_enqueue_style( $style_handle );
</ins><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">- // Front-end script.
- if ( ! empty( $block_type->script ) ) {
- wp_enqueue_script( $block_type->script );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Front-end and editor scripts.
+ foreach ( $block_type->script_handles as $script_handle ) {
+ wp_enqueue_script( $script_handle );
</ins><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">- // Editor styles.
- if ( $load_editor_scripts && ! empty( $block_type->editor_style ) ) {
- wp_enqueue_style( $block_type->editor_style );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $load_editor_scripts_and_styles ) {
+ // Editor styles.
+ foreach ( $block_type->editor_style_handles as $editor_style_handle ) {
+ wp_enqueue_style( $editor_style_handle );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // Editor script.
- if ( $load_editor_scripts && ! empty( $block_type->editor_script ) ) {
- wp_enqueue_script( $block_type->editor_script );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Editor scripts.
+ foreach ( $block_type->editor_script_handles as $editor_script_handle ) {
+ wp_enqueue_script( $editor_script_handle );
+ }
</ins><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></span></pre></div>
<a id="trunktestsphpunitdatablocksnoticeblockjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/data/blocks/notice/block.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/data/blocks/notice/block.json 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/tests/phpunit/data/blocks/notice/block.json 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,8 +57,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><span class="cx" style="display: block; padding: 0 10px"> "editorScript": "tests-notice-editor-script",
</span><span class="cx" style="display: block; padding: 0 10px"> "script": "tests-notice-script",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "viewScript": "tests-notice-view-script",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "viewScript": [ "tests-notice-view-script", "tests-notice-view-script-2" ],
</ins><span class="cx" style="display: block; padding: 0 10px"> "editorStyle": "tests-notice-editor-style",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "style": "tests-notice-style",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "style": [ "tests-notice-style", "tests-notice-style-2" ],
</ins><span class="cx" style="display: block; padding: 0 10px"> "render": "file:./render.php"
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsblocksregisterphp"></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/blocks/register.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/blocks/register.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/tests/phpunit/tests/blocks/register.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,15 +148,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'unit-tests-my-block-script',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- generate_block_asset_handle( $block_name, 'script' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ generate_block_asset_handle( $block_name, 'script', 0 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'unit-tests-my-block-view-script',
- generate_block_asset_handle( $block_name, 'viewScript' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'unit-tests-my-block-view-script-100',
+ generate_block_asset_handle( $block_name, 'viewScript', 99 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'unit-tests-my-block-editor-style',
- generate_block_asset_handle( $block_name, 'editorStyle' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'unit-tests-my-block-editor-style-2',
+ generate_block_asset_handle( $block_name, 'editorStyle', 1 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'unit-tests-my-block-style',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -176,15 +176,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-block-paragraph',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- generate_block_asset_handle( $block_name, 'script' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ generate_block_asset_handle( $block_name, 'script', 0 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wp-block-paragraph-view',
- generate_block_asset_handle( $block_name, 'viewScript' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wp-block-paragraph-view-100',
+ generate_block_asset_handle( $block_name, 'viewScript', 99 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'wp-block-paragraph-editor',
- generate_block_asset_handle( $block_name, 'editorStyle' )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'wp-block-paragraph-editor-2',
+ generate_block_asset_handle( $block_name, 'editorStyle', 1 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span><span class="cx" style="display: block; padding: 0 10px"> 'wp-block-paragraph',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,7 +204,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_empty_value_register_block_script_handle() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_empty_string_value_do_not_register_block_script_handle() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $metadata = array( 'script' => '' );
</span><span class="cx" style="display: block; padding: 0 10px"> $result = register_block_script_handle( $metadata, 'script' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -211,6 +211,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $result );
</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">+ public function test_empty_array_value_do_not_register_block_script_handle() {
+ $metadata = array( 'script' => array() );
+ $result = register_block_script_handle( $metadata, 'script' );
+
+ $this->assertFalse( $result );
+ }
+
+ public function test_wrong_array_index_do_not_register_block_script_handle() {
+ $metadata = array( 'script' => array( 'test-script-handle' ) );
+ $result = register_block_script_handle( $metadata, 'script', 1 );
+
+ $this->assertFalse( $result );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @expectedIncorrectUsage register_block_script_handle
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -231,13 +245,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_handle_passed_register_block_script_handle() {
</span><span class="cx" style="display: block; padding: 0 10px"> $metadata = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'editorScript' => 'test-script-handle',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'script' => 'test-script-handle',
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = register_block_script_handle( $metadata, 'editorScript' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = register_block_script_handle( $metadata, 'script' );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'test-script-handle', $result );
</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">+ public function test_handles_passed_register_block_script_handles() {
+ $metadata = array(
+ 'script' => array( 'test-script-handle', 'test-script-handle-2' ),
+ );
+
+ $result = register_block_script_handle( $metadata, 'script' );
+ $this->assertSame( 'test-script-handle', $result );
+
+ $result = register_block_script_handle( $metadata, 'script', 1 );
+ $this->assertSame( 'test-script-handle-2', $result, 1 );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,7 +307,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function test_empty_value_found_register_block_style_handle() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_empty_string_value_do_not_register_block_style_handle() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $metadata = array( 'style' => '' );
</span><span class="cx" style="display: block; padding: 0 10px"> $result = register_block_style_handle( $metadata, 'style' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -288,6 +314,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $result );
</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">+ public function test_empty_array_value_do_not_register_block_style_handle() {
+ $metadata = array( 'style' => array() );
+ $result = register_block_style_handle( $metadata, 'style' );
+
+ $this->assertFalse( $result );
+ }
+
+ public function test_wrong_array_index_do_not_register_block_style_handle() {
+ $metadata = array( 'style' => array( 'test-style-handle' ) );
+ $result = register_block_style_handle( $metadata, 'style', 1 );
+
+ $this->assertFalse( $result );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,6 +340,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( 'test-style-handle', $result );
</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">+ public function test_handles_passed_register_block_style_handles() {
+ $metadata = array(
+ 'style' => array( 'test-style-handle', 'test-style-handle-2' ),
+ );
+
+ $result = register_block_style_handle( $metadata, 'style' );
+ $this->assertSame( 'test-style-handle', $result );
+
+ $result = register_block_style_handle( $metadata, 'style', 1 );
+ $this->assertSame( 'test-style-handle-2', $result, 1 );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50263
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 50328
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -442,11 +494,26 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> $result->example
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( 'tests-notice-editor-script', $result->editor_script );
- $this->assertSame( 'tests-notice-script', $result->script );
- $this->assertSame( 'tests-notice-view-script', $result->view_script );
- $this->assertSame( 'tests-notice-editor-style', $result->editor_style );
- $this->assertSame( 'tests-notice-style', $result->style );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets(
+ array( 'tests-notice-editor-script' ),
+ $result->editor_script_handles
+ );
+ $this->assertSameSets(
+ array( 'tests-notice-script' ),
+ $result->script_handles
+ );
+ $this->assertSameSets(
+ array( 'tests-notice-view-script', 'tests-notice-view-script-2' ),
+ $result->view_script_handles
+ );
+ $this->assertSameSets(
+ array( 'tests-notice-editor-style' ),
+ $result->editor_style_handles
+ );
+ $this->assertSameSets(
+ array( 'tests-notice-style', 'tests-notice-style-2' ),
+ $result->style_handles
+ );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // @ticket 50328
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame(
</span></span></pre></div>
<a id="trunktestsphpunittestsrestapirestblocktypecontrollerphp"></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/rest-api/rest-block-type-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php 2022-09-14 10:46:51 UTC (rev 54154)
+++ trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php 2022-09-14 10:50:26 UTC (rev 54155)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -237,11 +237,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '1', $data['title'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '1', $data['description'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['icon'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $data['editor_script'] );
- $this->assertNull( $data['script'] );
- $this->assertNull( $data['view_script'] );
- $this->assertNull( $data['editor_style'] );
- $this->assertNull( $data['style'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array(), $data['editor_script_handles'] );
+ $this->assertSameSets( array(), $data['script_handles'] );
+ $this->assertSameSets( array(), $data['view_script_handles'] );
+ $this->assertSameSets( array(), $data['editor_style_handles'] );
+ $this->assertSameSets( array(), $data['style_handles'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['provides_context'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSetsWithIndex(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -260,6 +260,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['textdomain'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $data['is_dynamic'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array( array() ), $data['variations'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Deprecated properties.
+ $this->assertNull( $data['editor_script'] );
+ $this->assertNull( $data['script'] );
+ $this->assertNull( $data['view_script'] );
+ $this->assertNull( $data['editor_style'] );
+ $this->assertNull( $data['style'] );
+
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -299,11 +306,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', $data['title'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', $data['description'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['icon'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertNull( $data['editor_script'] );
- $this->assertNull( $data['script'] );
- $this->assertNull( $data['view_script'] );
- $this->assertNull( $data['editor_style'] );
- $this->assertNull( $data['style'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertSameSets( array(), $data['editor_script_handles'] );
+ $this->assertSameSets( array(), $data['script_handles'] );
+ $this->assertSameSets( array(), $data['view_script_handles'] );
+ $this->assertSameSets( array(), $data['editor_style_handles'] );
+ $this->assertSameSets( array(), $data['style_handles'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSetsWithIndex(
</span><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'lock' => array( 'type' => 'object' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -323,6 +330,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $data['textdomain'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $data['is_dynamic'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSameSets( array(), $data['variations'] );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Deprecated properties.
+ $this->assertNull( $data['editor_script'] );
+ $this->assertNull( $data['script'] );
+ $this->assertNull( $data['view_script'] );
+ $this->assertNull( $data['editor_style'] );
+ $this->assertNull( $data['style'] );
</ins><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"> public function test_get_variation() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -392,7 +405,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $response = rest_get_server()->dispatch( $request );
</span><span class="cx" style="display: block; padding: 0 10px"> $data = $response->get_data();
</span><span class="cx" style="display: block; padding: 0 10px"> $properties = $data['schema']['properties'];
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertCount( 23, $properties );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertCount( 28, $properties );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'api_version', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'title', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'icon', $properties );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -405,11 +418,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'supports', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'category', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'is_dynamic', $properties );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertArrayHasKey( 'editor_script', $properties );
- $this->assertArrayHasKey( 'script', $properties );
- $this->assertArrayHasKey( 'view_script', $properties );
- $this->assertArrayHasKey( 'editor_style', $properties );
- $this->assertArrayHasKey( 'style', $properties );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertArrayHasKey( 'editor_script_handles', $properties );
+ $this->assertArrayHasKey( 'script_handles', $properties );
+ $this->assertArrayHasKey( 'view_script_handles', $properties );
+ $this->assertArrayHasKey( 'editor_style_handles', $properties );
+ $this->assertArrayHasKey( 'style_handles', $properties );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'parent', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'example', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'uses_context', $properties );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -416,6 +429,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'provides_context', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'variations', $properties );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertArrayHasKey( 'ancestor', $properties );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Deprecated properties.
+ $this->assertArrayHasKey( 'editor_script', $properties );
+ $this->assertArrayHasKey( 'script', $properties );
+ $this->assertArrayHasKey( 'view_script', $properties );
+ $this->assertArrayHasKey( 'editor_style', $properties );
+ $this->assertArrayHasKey( 'style', $properties );
+
</ins><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><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -518,11 +538,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'api_version',
</span><span class="cx" style="display: block; padding: 0 10px"> 'name',
</span><span class="cx" style="display: block; padding: 0 10px"> 'category',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'editor_script',
- 'script',
- 'view_script',
- 'editor_style',
- 'style',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'editor_script_handles',
+ 'script_handles',
+ 'view_script_handles',
+ 'editor_style_handles',
+ 'style_handles',
</ins><span class="cx" style="display: block; padding: 0 10px"> 'title',
</span><span class="cx" style="display: block; padding: 0 10px"> 'icon',
</span><span class="cx" style="display: block; padding: 0 10px"> 'description',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -534,6 +554,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'styles',
</span><span class="cx" style="display: block; padding: 0 10px"> 'textdomain',
</span><span class="cx" style="display: block; padding: 0 10px"> 'example',
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Deprecated fields.
+ 'editor_script',
+ 'script',
+ 'view_script',
+ 'editor_style',
+ 'style',
</ins><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"> foreach ( $extra_fields as $extra_field ) {
</span></span></pre>
</div>
</div>
</body>
</html>