PluginProbe
BeyondWords – AI audio for publishers / 4.1.1
BeyondWords – AI audio for publishers v4.1.1
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 4.7.0 All 43 releases
speechkit / src / Component / Post / DisplayPlayer / index.js

index.js in BeyondWords – AI audio for publishers 4.1.1, at src/Component/Post/DisplayPlayer/index.js

52 lines 1.2 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 { CheckboxControl } from '@wordpress/components';
6 import { useEntityProp } from '@wordpress/core-data';
7 import { useSelect } from '@wordpress/data';
8 import { Fragment } from '@wordpress/element';
9
10 /**
11 * Internal dependencies
12 */
13 import DisplayPlayerCheck from './check';
14
15 export function DisplayPlayer( { wrapper } ) {
16 const Wrapper = wrapper || Fragment;
17
18 const postType = useSelect(
19 ( select ) => select( 'core/editor' ).getCurrentPostType(),
20 []
21 );
22
23 const [ meta, setMeta ] = useEntityProp( 'postType', postType, 'meta' );
24
25 // todo get from AJAX
26 const displayPlayer = meta.beyondwords_disabled !== '1';
27
28 const onUpdateDisplayPlayer = ( newDisplayPlayer ) => {
29 setMeta( {
30 ...meta,
31 beyondwords_disabled: newDisplayPlayer ? '' : '1',
32 } );
33 };
34
35 return (
36 <DisplayPlayerCheck>
37 <Wrapper>
38 <CheckboxControl
39 className="beyondwords--display-player"
40 label={ __( 'Display player', 'speechkit' ) }
41 checked={ displayPlayer }
42 onChange={ () => {
43 onUpdateDisplayPlayer( ! displayPlayer );
44 } }
45 />
46 </Wrapper>
47 </DisplayPlayerCheck>
48 );
49 }
50
51 export default DisplayPlayer;
52