# speechkit/4.0.6/src/Component/Post/DisplayPlayer/index.js

BeyondWords – AI audio for publishers, version 4.0.6. 52 lines.

- Page: https://pluginprobe.com/plugins/speechkit/4.0.6/code/src/Component/Post/DisplayPlayer/index.js
- Raw: https://pluginprobe.com/plugins/speechkit/4.0.6/raw/src/Component/Post/DisplayPlayer/index.js
- Modified: 2023-09-07T17:37:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/speechkit/4.0.6/code/src/Component/Post/DisplayPlayer/index.js#L10-L20`.

```javascript
/**
 * WordPress dependencies
 */
import { __ } from '@wordpress/i18n';
import { CheckboxControl } from '@wordpress/components';
import { useEntityProp } from '@wordpress/core-data';
import { useSelect } from '@wordpress/data';
import { Fragment } from '@wordpress/element';

/**
 * Internal dependencies
 */
import DisplayPlayerCheck from './check';

export function DisplayPlayer( { wrapper } ) {
	const Wrapper = wrapper || Fragment;

	const postType = useSelect(
		( select ) => select( 'core/editor' ).getCurrentPostType(),
		[]
	);

	const [ meta, setMeta ] = useEntityProp( 'postType', postType, 'meta' );

	// todo get from AJAX
	const displayPlayer = meta.beyondwords_disabled !== '1';

	const onUpdateDisplayPlayer = ( newDisplayPlayer ) => {
		setMeta( {
			...meta,
			beyondwords_disabled: newDisplayPlayer ? '' : '1',
		} );
	};

	return (
		<DisplayPlayerCheck>
			<Wrapper>
				<CheckboxControl
					className="beyondwords--display-player"
					label={ __( 'Display player', 'speechkit' ) }
					checked={ displayPlayer }
					onChange={ () => {
						onUpdateDisplayPlayer( ! displayPlayer );
					} }
				/>
			</Wrapper>
		</DisplayPlayerCheck>
	);
}

export default DisplayPlayer;

```
