-
Notifications
You must be signed in to change notification settings - Fork 146
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
Introduce Posts and Post Carousel block deprecations #1638
Conversation
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! On the issue with the blank token in the field, we can actually fix this during the attribute migration.
The functionality I'm seeing in the block using it new is the REST API response data is saved for each category in the attribute. Personally this seems way too verbose but maybe there is a reason. Regardless, we can perform an API request to get this additional data for the category ID's we find. Here's an example I've used in my own plugins:
import apiFetch from '@wordpress/api-fetch';
import { addQueryArgs } from '@wordpress/url';
import { decodeEntities } from '@wordpress/html-entities';
apiFetch( {
path: addQueryArgs(
'/wp/v2/categories',
{
per_page: 100, // should be set to the number of categories we are querying.
_fields: 'id,name',
include: categoryIDs.join( ',' ),
}
)
} )
.then(
( entities ) => entities.map(
( entity ) => (
{
id: entity.id,
name: decodeEntities( entity.name ),
}
)
)
)
So this PR would migrate to this:
<!-- wp:coblocks/post-carousel {"columns":3,"categories":[{"id":3}]} /-->
but we need at least this:
<!-- wp:coblocks/post-carousel {"columns":3,"categories":[{"id":3,"name": "Category 2"}]} /-->
Description
Closes #1632
Following the lead of the Gutenberg team, this PR introduces measures that will allow proper migration/deprecation from previously configured and published blocks into a working state using modern interface and features.
In this case, the
core/latest-posts
block had a number of breaking changes related to the implementation of a tokenized category selector. The new selector requires new logic and a new attribute schema.This change is inspired by this PR in Gutenberg. This PR resolves a bug with migration from old-style
coblocks/posts
andcoblocks/post-carousel
attributes.This can be replicated using old markup:
Please note This fix will successfully migrate the chosen category from a previously configured block into a category token within the new interface. While the token exists and works as expected as a filter, the token is missing contextual language. This is a known issue with migration.
Types of changes
JavaScript changes and PHP changes.
How has this been tested?
Tested manually migrating from 5.4.2 -> 5.5
Tested with and without the Gutenberg plugin.
Tested migration from CoBlocks 1.23.0 -> 2.2.2
Checklist: