PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 1.8.2
GenerateBlocks v1.8.2
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 / extend / dynamic-content / inspector-controls / DynamicSourceControl.js
generateblocks / src / extend / dynamic-content / inspector-controls Last commit date
AuthorMetaControl.js 3 years ago CommentsControl.js 4 years ago ContentTypeControl.js 4 years ago DynamicSourceControl.js 3 years ago ExcerptControl.js 4 years ago LinkTypeControl.js 3 years ago PostDateControl.js 4 years ago PostMetaControl.js 3 years ago TermsControl.js 4 years ago
DynamicSourceControl.js
47 lines
1 import { __ } from '@wordpress/i18n';
2 import SelectPostType from '../components/SelectPostType';
3 import PostTypeRecordsSelect from '../../../components/post-type-records-select';
4 import SelectSource from '../components/SelectSource';
5
6 export default ( { dynamicSource, postType, postId, setAttributes, dynamicContentType } ) => {
7 return (
8 <>
9 <SelectSource
10 source={ dynamicSource }
11 onChange={ ( option ) => {
12 setAttributes( {
13 dynamicSource: option.value,
14 postId: '',
15 postType: 'post',
16 } );
17 } }
18 dynamicContentType={ dynamicContentType }
19 />
20
21 { dynamicSource === 'post-type' &&
22 <>
23 <SelectPostType
24 postType={ postType }
25 onChange={ ( option ) => {
26 setAttributes( { postType: option.value, postId: '' } );
27 } }
28 />
29
30 <PostTypeRecordsSelect
31 postId={ postId }
32 postType={ postType }
33 value={ !! postId ? [ postId ] : [] }
34 id={ 'gblocks-select-post' }
35 label={ __( 'Select source post', 'generateblocks' ) }
36 help={ __( 'Search by name or ID.', 'generateblocks' ) }
37 onChange={ ( option ) => {
38 setAttributes( { postId: option.value } );
39 } }
40 isMulti={ false }
41 />
42 </>
43 }
44 </>
45 );
46 };
47