Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes for 6.3 RC2 #52863

Merged
merged 17 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b107e07
Filter out patterns that are not allowed in the inserter (#52675)
carolinan Jul 18, 2023
114a638
Remove autofocus and improve placeholder text consistency. (#52634)
afercia Jul 18, 2023
99d55d1
Do not navigate to the styles pages unless you're in a random listing…
youknowriad Jul 18, 2023
88e1896
Patterns: Don't override the rootClientID in create menu - only set …
glendaviesnz Jul 19, 2023
5a3ac19
Footnotes: store in revisions (#52686)
ellatrix Jul 19, 2023
c77d9f5
Fix: Block toolbar obscuring document tools when Top Toolbar is enabl…
jameskoster Jul 19, 2023
ffd69e0
Site Editor: Fix site link accessibility issues (#52744)
glendaviesnz Jul 19, 2023
2283b13
Add id to pattern inserted notice to stop multiple notices stacking (…
glendaviesnz Jul 19, 2023
24e1886
Global Styles: Don't use named arguments for 'sprintf' (#52782)
Mamaduka Jul 20, 2023
5b8a1c5
Footnotes: Use static closures when not using '' (#52781)
Mamaduka Jul 20, 2023
d84b12d
removes check for active preview device type to enable the fixed tool…
draganescu Jul 20, 2023
790b744
Parser / Site Editor: Ensure autop is not run when freeform block is …
andrewserong Jul 21, 2023
39ac8b0
Adding @since annotation for relevant 6.3 changes. (#52820)
ramonjd Jul 21, 2023
c98607b
Navigation: Load the raw property on the navigation fallback (#52758)
scruffian Jul 21, 2023
cb35dee
Allow styles to be changed dynamically through editor settings (#52767)
ellatrix Jul 21, 2023
4b52967
ResizableFrame: Fix styling in Firefox (#52700)
mirka Jul 18, 2023
94995ef
Patterns: Fix empty general template parts category (#52747)
kevin940726 Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.3/navigation-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ function gutenberg_add_fields_to_navigation_fallback_embeded_links( $schema ) {
$schema['properties']['content']['context'] = array_merge( $schema['properties']['content']['context'], array( 'embed' ) );

// Expose sub properties of content field.
// These aren't exposed by the posts controller by default, see:
// https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2425.
$schema['properties']['content']['properties']['raw']['context'] = array_merge( $schema['properties']['content']['properties']['raw']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['rendered']['context'] = array_merge( $schema['properties']['content']['properties']['rendered']['context'], array( 'embed' ) );
$schema['properties']['content']['properties']['block_version']['context'] = array_merge( $schema['properties']['content']['properties']['block_version']['context'], array( 'embed' ) );

// Expose sub properties of title field.
// These aren't exposed by the posts controller by default, see:
// https://github.com/WordPress/wordpress-develop/blob/5c3c6258e468c67ba00bbd13db29994f1a57a52a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L2401.
$schema['properties']['title']['properties']['raw']['context'] = array_merge( $schema['properties']['title']['properties']['raw']['context'], array( 'embed' ) );

return $schema;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,15 @@
// for the block inserter the publish button
@include break-large() {
&.is-fixed {
width: auto;
}
.is-fullscreen-mode &.is-fixed {
// in full screen mode we need to account for
// the combined with of the tools at the right of the header and the margin left
// of the toolbar which includes four buttons
width: calc(100% - 240px - #{4 * $grid-unit-80});
}
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const usePatternsState = ( onInsert, rootClientId ) => {
),
{
type: 'snackbar',
id: 'block-pattern-inserted-notice',
}
);
},
Expand Down
10 changes: 5 additions & 5 deletions packages/block-editor/src/store/test/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe( 'selectors', () => {
parent: [ 'core/test-block-b' ],
} );

registerBlockType( 'core/test-freeform', {
registerBlockType( 'core/freeform', {
save: ( props ) => <RawHTML>{ props.attributes.content }</RawHTML>,
category: 'text',
title: 'Test Freeform Content Handler',
Expand Down Expand Up @@ -177,7 +177,7 @@ describe( 'selectors', () => {
ancestor: [ 'core/test-block-ancestor' ],
} );

setFreeformContentHandlerName( 'core/test-freeform' );
setFreeformContentHandlerName( 'core/freeform' );

cachedSelectors.forEach( ( { clear } ) => clear() );
} );
Expand All @@ -187,7 +187,7 @@ describe( 'selectors', () => {
unregisterBlockType( 'core/test-block-a' );
unregisterBlockType( 'core/test-block-b' );
unregisterBlockType( 'core/test-block-c' );
unregisterBlockType( 'core/test-freeform' );
unregisterBlockType( 'core/freeform' );
unregisterBlockType( 'core/post-content-child' );
unregisterBlockType( 'core/test-block-ancestor' );
unregisterBlockType( 'core/test-block-parent' );
Expand Down Expand Up @@ -3450,7 +3450,7 @@ describe( 'selectors', () => {
expect( firstBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
'core/test-block-a',
'core/test-block-b',
'core/test-freeform',
'core/freeform',
'core/test-block-ancestor',
'core/test-block-parent',
'core/block/1',
Expand All @@ -3466,7 +3466,7 @@ describe( 'selectors', () => {
expect( secondBlockFirstCall.map( ( item ) => item.id ) ).toEqual( [
'core/test-block-a',
'core/test-block-b',
'core/test-freeform',
'core/freeform',
'core/test-block-ancestor',
'core/test-block-parent',
'core/block/1',
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/comment-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Function that recursively renders a list of nested comments.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @global int $comment_depth
*
* @param WP_Comment[] $comments The array of comments.
Expand Down
138 changes: 138 additions & 0 deletions packages/block-library/src/footnotes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/footnotes` block on the server.
*
* @since 6.3.0
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down Expand Up @@ -57,6 +59,8 @@ function render_block_core_footnotes( $attributes, $content, $block ) {

/**
* Registers the `core/footnotes` block on the server.
*
* @since 6.3.0
*/
function register_block_core_footnotes() {
foreach ( array( 'post', 'page' ) as $post_type ) {
Expand All @@ -78,3 +82,137 @@ function register_block_core_footnotes() {
);
}
add_action( 'init', 'register_block_core_footnotes' );

add_action(
'wp_after_insert_post',
/**
* Saves the footnotes meta value to the revision.
*
* @since 6.3.0
*
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
$post_id = wp_is_post_revision( $revision_id );

if ( $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $revision_id, 'footnotes', $footnotes );
}
}
}
);

add_action(
'_wp_put_post_revision',
/**
* Keeps track of the revision ID for "rest_after_insert_{$post_type}".
*
* @param int $revision_id The revision ID.
*/
static function( $revision_id ) {
global $_gutenberg_revision_id;
$_gutenberg_revision_id = $revision_id;
}
);

foreach ( array( 'post', 'page' ) as $post_type ) {
add_action(
"rest_after_insert_{$post_type}",
/**
* This is a specific fix for the REST API. The REST API doesn't update
* the post and post meta in one go (through `meta_input`). While it
* does fix the `wp_after_insert_post` hook to be called correctly after
* updating meta, it does NOT fix hooks such as post_updated and
* save_post, which are normally also fired after post meta is updated
* in `wp_insert_post()`. Unfortunately, `wp_save_post_revision` is
* added to the `post_updated` action, which means the meta is not
* available at the time, so we have to add it afterwards through the
* `"rest_after_insert_{$post_type}"` action.
*
* @since 6.3.0
*
* @param WP_Post $post The post object.
*/
static function( $post ) {
global $_gutenberg_revision_id;

if ( $_gutenberg_revision_id ) {
$revision = get_post( $_gutenberg_revision_id );
$post_id = $revision->post_parent;

// Just making sure we're updating the right revision.
if ( $post->ID === $post_id ) {
$footnotes = get_post_meta( $post_id, 'footnotes', true );

if ( $footnotes ) {
// Can't use update_post_meta() because it doesn't allow revisions.
update_metadata( 'post', $_gutenberg_revision_id, 'footnotes', $footnotes );
}
}
}
}
);
}

add_action(
'wp_restore_post_revision',
/**
* Restores the footnotes meta value from the revision.
*
* @since 6.3.0
*
* @param int $post_id The post ID.
* @param int $revision_id The revision ID.
*/
static function( $post_id, $revision_id ) {
$footnotes = get_post_meta( $revision_id, 'footnotes', true );

if ( $footnotes ) {
update_post_meta( $post_id, 'footnotes', $footnotes );
} else {
delete_post_meta( $post_id, 'footnotes' );
}
},
10,
2
);

add_filter(
'_wp_post_revision_fields',
/**
* Adds the footnotes field to the revision.
*
* @since 6.3.0
*
* @param array $fields The revision fields.
* @return array The revision fields.
*/
static function( $fields ) {
$fields['footnotes'] = __( 'Footnotes' );
return $fields;
}
);

add_filter(
'wp_post_revision_field_footnotes',
/**
* Gets the footnotes field from the revision.
*
* @since 6.3.0
*
* @param string $revision_field The field value, but $revision->$field
* (footnotes) does not exist.
* @param string $field The field name, in this case "footnotes".
* @param object $revision The revision object to compare against.
* @return string The field value.
*/
static function( $revision_field, $field, $revision ) {
return get_metadata( 'post', $revision->ID, $field, true );
},
10,
3
);
2 changes: 2 additions & 0 deletions packages/block-library/src/pattern/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function register_block_core_pattern() {
/**
* Renders the `core/pattern` block on the server.
*
* @since 6.3.0 Backwards compatibility: blocks with no `syncStatus` attribute do not receive block wrapper.
*
* @param array $attributes Block attributes.
*
* @return string Returns the output of the pattern.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-template/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function block_core_post_template_uses_featured_image( $inner_blocks ) {
/**
* Renders the `core/post-template` block on the server.
*
* @since 6.3.0 Changed render_block_context priority to `1`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/post-title/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Renders the `core/post-title` block on the server.
*
* @since 6.3.0 Omitting the $post argument from the `get_the_title`.
*
* @param array $attributes Block attributes.
* @param string $content Block default content.
* @param WP_Block $block Block instance.
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/**
* Dynamically renders the `core/search` block.
*
* @since 6.3.0 Using block.json `viewScript` to register script, and update `view_script_handles()` only when needed.
*
* @param array $attributes The block attributes.
* @param string $content The saved content.
* @param WP_Block $block The parsed block.
Expand Down
1 change: 1 addition & 0 deletions packages/blocks/src/api/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function normalizeRawBlock( rawBlock, options ) {
// meaning there are no negative consequences to repeated autop calls.
if (
rawBlockName === fallbackBlockName &&
rawBlockName === 'core/freeform' &&
! options?.__unstableSkipAutop
) {
rawInnerHTML = autop( rawInnerHTML ).trim();
Expand Down
23 changes: 17 additions & 6 deletions packages/blocks/src/api/parser/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,30 @@ describe( 'block parser', () => {
} );

it( 'should fall back to the freeform content handler if block type not specified', () => {
registerBlockType( 'core/freeform-block', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform-block' );
registerBlockType( 'core/freeform', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform' );

const block = parseRawBlock( {
innerHTML: 'content',
} );
expect( block.name ).toEqual( 'core/freeform-block' );
expect( block.name ).toEqual( 'core/freeform' );
expect( block.attributes ).toEqual( { content: '<p>content</p>' } );
} );

it( 'skips adding paragraph tags if freeform block is set to core/html', () => {
registerBlockType( 'core/html', unknownBlockSettings );
setFreeformContentHandlerName( 'core/html' );

const block = parseRawBlock( {
innerHTML: 'content',
} );
expect( block.name ).toEqual( 'core/html' );
expect( block.attributes ).toEqual( { content: 'content' } );
} );

it( 'skips adding paragraph tags if __unstableSkipAutop is passed as an option', () => {
registerBlockType( 'core/freeform-block', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform-block' );
registerBlockType( 'core/freeform', unknownBlockSettings );
setFreeformContentHandlerName( 'core/freeform' );

const block = parseRawBlock(
{
Expand All @@ -112,7 +123,7 @@ describe( 'block parser', () => {
__unstableSkipAutop: true,
}
);
expect( block.name ).toEqual( 'core/freeform-block' );
expect( block.name ).toEqual( 'core/freeform' );
expect( block.attributes ).toEqual( { content: 'content' } );
} );

Expand Down
3 changes: 2 additions & 1 deletion packages/blocks/src/api/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ export function __unstableSerializeAndClean( blocks ) {
// pre-block-editor removep'd content formatting.
if (
blocks.length === 1 &&
blocks[ 0 ].name === getFreeformContentHandlerName()
blocks[ 0 ].name === getFreeformContentHandlerName() &&
blocks[ 0 ].name === 'core/freeform'
) {
content = removep( content );
}
Expand Down
Loading
Loading