Adds collection list to query loop variations.
This commit is contained in:
parent
82a120912f
commit
25c4ac3a62
|
@ -1,7 +1,52 @@
|
|||
const { registerBlockVariation } = wp.blocks;
|
||||
const { __ } = wp.i18n;
|
||||
import icon from '../blocks/items-list/icon';
|
||||
import itemsIcon from '../blocks/items-list/icon';
|
||||
import collectionsIcon from '../blocks/collections-list/icon';
|
||||
|
||||
/**
|
||||
* Adds Tainacan Collections as a query loop variation
|
||||
*/
|
||||
registerBlockVariation( 'core/query', {
|
||||
name: 'tainacan-collection',
|
||||
title: __( 'Tainacan collections', 'tainacan'),
|
||||
icon: collectionsIcon,
|
||||
category: 'tainacan-blocks-variations',
|
||||
description: __('Displays a list of Tainacan collections', 'tainacan'),
|
||||
isActive: ( { namespace, query } ) => {
|
||||
return (
|
||||
namespace === 'tainacan-collection'
|
||||
&& query.postType === 'tainacan-collection'
|
||||
);
|
||||
},
|
||||
attributes: {
|
||||
namespace: 'tainacan-collection',
|
||||
query: {
|
||||
postType: 'tainacan-collection',
|
||||
perPage: 12,
|
||||
offset: 0
|
||||
},
|
||||
align: 'wide',
|
||||
displayLayout: {
|
||||
type: 'flex',
|
||||
columns: 4
|
||||
}
|
||||
},
|
||||
allowedControls: [ 'inherit', 'order', 'taxQuery', 'search' ],
|
||||
innerBlocks: [
|
||||
[
|
||||
'core/post-template',
|
||||
{},
|
||||
[
|
||||
[ 'core/post-featured-image' ],
|
||||
[ 'core/post-title' ]
|
||||
],
|
||||
]
|
||||
]
|
||||
} );
|
||||
|
||||
/**
|
||||
* Loops on Tainacan Collections post types to create items list variations
|
||||
*/
|
||||
const POST_TYPES = tainacan_blocks.collections_post_types;
|
||||
|
||||
Object.keys(POST_TYPES).forEach((postType) => {
|
||||
|
@ -11,9 +56,9 @@ Object.keys(POST_TYPES).forEach((postType) => {
|
|||
registerBlockVariation( 'core/query', {
|
||||
name: VARIATION_NAME,
|
||||
title: postName,
|
||||
icon: icon,
|
||||
icon: itemsIcon,
|
||||
category: 'tainacan-blocks-variations',
|
||||
description: __('Displays a list of Tainacan itens', 'tainacan'),
|
||||
description: __('Displays a list of Tainacan itens from a collection', 'tainacan'),
|
||||
isActive: ( { namespace, query } ) => {
|
||||
return (
|
||||
namespace === VARIATION_NAME
|
||||
|
|
Loading…
Reference in New Issue