Last active
October 1, 2021 15:47
-
-
Save EdwardBock/b19cce2422c66c61821946f29551877f to your computer and use it in GitHub Desktop.
Add reading time field to post status info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { registerPlugin } from "@wordpress/plugins"; | |
import { PluginPostStatusInfo } from "@wordpress/edit-post"; | |
import { TextControl } from "@wordpress/components"; | |
import {useReadingTime} from "./reading-time-hooks.js"; | |
registerPlugin( | |
'reading-time', | |
{ | |
render: ()=> { | |
const [value, setValue] = useReadingTime(); | |
return <PluginPostStatusInfo> | |
<TextControl | |
label="Reading time" | |
onChange={setValue} | |
value={value} | |
/> | |
</PluginPostStatusInfo> | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment