File "block.js"
Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/blocks/query-loop/block.js
File
size: 1.23 B
MIME-type: text/x-java
Charset: utf-8
Download Open Edit Advanced Editor &nnbsp; Back
import { registerBlockType } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import getIcon from '../../utils/get-icon';
import attributes from './attributes';
import { InnerBlocks } from '@wordpress/block-editor';
import edit from './edit';
import './editor.scss';
import withUniqueId from '../../hoc/withUniqueId';
registerBlockType( 'generateblocks/query-loop', {
apiVersion: 3,
title: __( 'Query Loop', 'generateblocks' ),
description: __( 'Build a list of posts from any post type using advanced query parameters.', 'generateblocks' ),
icon: getIcon( 'query-loop' ),
category: 'generateblocks',
keywords: [
__( 'query' ),
__( 'loop' ),
__( 'generate' ),
],
attributes,
supports: {
className: false,
customClassName: false,
},
providesContext: {
'generateblocks/query': 'query',
'generateblocks/queryId': 'uniqueId',
'generateblocks/inheritQuery': 'inheritQuery',
},
edit: withUniqueId( edit ),
save: () => {
return (
<InnerBlocks.Content />
);
},
__experimentalLabel: ( attrs, { context } ) => {
const customName = attrs?.metadata?.name || attrs?.blockLabel;
if ( 'list-view' === context && customName ) {
return customName;
}
return __( 'Query Loop', 'generateblocks' );
},
} );