@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
36 lines (32 loc) • 855 B
JavaScript
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { CheckboxControl } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';
function PostPingbacks( { pingStatus = 'open', ...props } ) {
const onTogglePingback = () =>
props.editPost( {
ping_status: pingStatus === 'open' ? 'closed' : 'open',
} );
return (
<CheckboxControl
label={ __( 'Allow pingbacks & trackbacks' ) }
checked={ pingStatus === 'open' }
onChange={ onTogglePingback }
/>
);
}
export default compose( [
withSelect( ( select ) => {
return {
pingStatus: select( 'core/editor' ).getEditedPostAttribute(
'ping_status'
),
};
} ),
withDispatch( ( dispatch ) => ( {
editPost: dispatch( 'core/editor' ).editPost,
} ) ),
] )( PostPingbacks );