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 |