PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.0.0
GenerateBlocks v2.0.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / query-loop / block.js
generateblocks / src / blocks / query-loop Last commit date
components 2 years ago hoc 4 years ago hooks 4 years ago attributes.js 2 years ago block.js 1 year ago edit.js 2 years ago editor.scss 2 years ago query-parameters.js 3 years ago templates.js 3 years ago
block.js
47 lines
1 import { registerBlockType } from '@wordpress/blocks';
2 import { __ } from '@wordpress/i18n';
3 import getIcon from '../../utils/get-icon';
4 import attributes from './attributes';
5 import { InnerBlocks } from '@wordpress/block-editor';
6 import edit from './edit';
7 import './editor.scss';
8 import withUniqueId from '../../hoc/withUniqueId';
9
10 registerBlockType( 'generateblocks/query-loop', {
11 apiVersion: 3,
12 title: __( 'Query Loop', 'generateblocks' ),
13 description: __( 'Build a list of posts from any post type using advanced query parameters.', 'generateblocks' ),
14 icon: getIcon( 'query-loop' ),
15 category: 'generateblocks',
16 keywords: [
17 __( 'query' ),
18 __( 'loop' ),
19 __( 'generate' ),
20 ],
21 attributes,
22 supports: {
23 className: false,
24 customClassName: false,
25 },
26 providesContext: {
27 'generateblocks/query': 'query',
28 'generateblocks/queryId': 'uniqueId',
29 'generateblocks/inheritQuery': 'inheritQuery',
30 },
31 edit: withUniqueId( edit ),
32 save: () => {
33 return (
34 <InnerBlocks.Content />
35 );
36 },
37 __experimentalLabel: ( attrs, { context } ) => {
38 const customName = attrs?.metadata?.name || attrs?.blockLabel;
39
40 if ( 'list-view' === context && customName ) {
41 return customName;
42 }
43
44 return __( 'Query Loop', 'generateblocks' );
45 },
46 } );
47