-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Latest Posts: Fix selected category on existing blocks (#21359)
* Add fallback for displaying single-category restrictions * Add a block deprecation to convert string-categories to an array * Remove extra suggestions object * Latest Posts: Fix type schema for array "categories" * Latest Posts: Shim server-side deprecation for string-based categories * Reverts the change to `render_block_core_latest_posts` * Update packages/block-library/src/latest-posts/index.php Co-Authored-By: Andrew Duthie <[email protected]> Co-authored-by: Miguel Fonseca <[email protected]> Co-authored-by: Andrew Duthie <[email protected]>
- Loading branch information
1 parent
d69aae1
commit 0c37ba8
Showing
5 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import metadata from './block.json'; | ||
|
||
const { attributes } = metadata; | ||
|
||
export default [ | ||
{ | ||
attributes: { | ||
...attributes, | ||
categories: { | ||
type: 'string', | ||
}, | ||
}, | ||
supports: { | ||
align: true, | ||
html: false, | ||
}, | ||
migrate: ( oldAttributes ) => { | ||
// This needs the full category object, not just the ID. | ||
return { | ||
...oldAttributes, | ||
categories: [ { id: Number( oldAttributes.categories ) } ], | ||
}; | ||
}, | ||
isEligible: ( { categories } ) => | ||
categories && 'string' === typeof categories, | ||
save: () => null, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters