-
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.
Terms List block: Add Categories-specific variation (#65434)
Add two variations to the Terms List block (i.e. `core/categories` -- previously named "Categories List"): One for Categories, and another one for all other taxonomies. This is mostly for better discoverability of what used to be the Categories List block under its new name. Co-authored-by: ockham <bernhard-reiter@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
- Loading branch information
1 parent
c754c78
commit 5aafffc
Showing
3 changed files
with
45 additions
and
1 deletion.
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
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,40 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { category as icon } from '@wordpress/icons'; | ||
|
||
const variations = [ | ||
{ | ||
name: 'terms', | ||
title: __( 'Terms List' ), | ||
icon, | ||
attributes: { | ||
// We need to set an attribute here that will be set when inserting the block. | ||
// We cannot leave this empty, as that would be interpreted as the default value, | ||
// which is `category` -- for which we're defining a distinct variation below, | ||
// for backwards compatibility reasons. | ||
// The logical fallback is thus the only other built-in and public taxonomy: Tags. | ||
taxonomy: 'post_tag', | ||
}, | ||
isActive: ( blockAttributes ) => | ||
// This variation is used for any taxonomy other than `category`. | ||
blockAttributes.taxonomy !== 'category', | ||
}, | ||
{ | ||
name: 'categories', | ||
title: __( 'Categories List' ), | ||
description: __( 'Display a list of all categories.' ), | ||
icon, | ||
attributes: { | ||
taxonomy: 'category', | ||
}, | ||
isActive: [ 'taxonomy' ], | ||
// The following is needed to prevent "Terms List" from showing up twice in the inserter | ||
// (once for the block, once for the variation). Fortunately, it does not collide with | ||
// `categories` being the default value of the `taxonomy` attribute. | ||
isDefault: true, | ||
}, | ||
]; | ||
|
||
export default variations; |