Skip to content

Instantly share code, notes, and snippets.

@EdwardBock
Last active October 1, 2021 15:47
Show Gist options
  • Save EdwardBock/b19cce2422c66c61821946f29551877f to your computer and use it in GitHub Desktop.
Save EdwardBock/b19cce2422c66c61821946f29551877f to your computer and use it in GitHub Desktop.
Add reading time field to post status info
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