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
PostDateControl.js
33 lines
| 1 | import { SelectControl, ToggleControl } from '@wordpress/components'; |
| 2 | import { __ } from '@wordpress/i18n'; |
| 3 | |
| 4 | export default function PostDateControl( props ) { |
| 5 | const { isActive = false, dateType, dateReplacePublished, setAttributes } = props; |
| 6 | |
| 7 | return ( |
| 8 | <> |
| 9 | { isActive && |
| 10 | <> |
| 11 | <SelectControl |
| 12 | label={ __( 'Date type', 'generateblocks' ) } |
| 13 | value={ dateType } |
| 14 | options={ [ |
| 15 | { value: 'published', label: __( 'Published', 'generateblocks' ) }, |
| 16 | { value: 'updated', label: __( 'Updated', 'generateblocks' ) }, |
| 17 | ] } |
| 18 | onChange={ ( value ) => setAttributes( { dateType: value } ) } |
| 19 | /> |
| 20 | |
| 21 | { 'published' === dateType && |
| 22 | <ToggleControl |
| 23 | label={ __( 'Replace with updated date', 'generateblocks' ) } |
| 24 | checked={ !! dateReplacePublished } |
| 25 | onChange={ ( value ) => setAttributes( { dateReplacePublished: value } ) } |
| 26 | /> |
| 27 | } |
| 28 | </> |
| 29 | } |
| 30 | </> |
| 31 | ); |
| 32 | } |
| 33 |