PluginProbe
BeyondWords – AI audio for publishers / 4.4.0
BeyondWords – AI audio for publishers v4.4.0
7.2.0 7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 All 44 releases
speechkit / src / Component / Post / Panel / Prepublish / index.js

index.js in BeyondWords – AI audio for publishers 4.4.0, at src/Component/Post/Panel/Prepublish/index.js

53 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 import { __ } from '@wordpress/i18n';
5 import { PanelBody, PanelRow, ToggleControl } from '@wordpress/components';
6 import { compose } from '@wordpress/compose';
7 import { withDispatch, withSelect } from '@wordpress/data';
8
9 const panel = ( { generateAudio, onGenerateAudioChange } ) => (
10 <PanelBody title={ __( 'BeyondWords', 'speechkit' ) } initialOpen={ true }>
11 <PanelRow>
12 <ToggleControl
13 label={ __( 'Generate audio', 'speechkit' ) }
14 checked={ generateAudio }
15 onChange={ ( value ) => {
16 onGenerateAudioChange( value );
17 } }
18 />
19 </PanelRow>
20 </PanelBody>
21 );
22
23 export default compose(
24 withSelect( ( select ) => {
25 const { getEditedPostAttribute } = select( 'core/editor' );
26
27 const beyondwordsGenerateAudio =
28 getEditedPostAttribute( 'meta' ).beyondwords_generate_audio;
29 const speechkitGenerateAudio =
30 getEditedPostAttribute( 'meta' ).speechkit_generate_audio;
31
32 // todo get from AJAX
33 return {
34 generateAudio:
35 beyondwordsGenerateAudio === '1' ||
36 speechkitGenerateAudio === '1',
37 };
38 } ),
39 withDispatch( ( dispatch ) => {
40 const { editPost } = dispatch( 'core/editor' );
41
42 return {
43 onGenerateAudioChange: ( value ) => {
44 editPost( {
45 meta: {
46 beyondwords_generate_audio: value ? '1' : '0',
47 },
48 } );
49 },
50 };
51 } )
52 )( panel );
53