Skip to content

Instantly share code, notes, and snippets.

@EdwardBock
Last active October 17, 2021 10:28
Show Gist options
  • Save EdwardBock/bcafd4f36942dc3e778b1f9d7181a001 to your computer and use it in GitHub Desktop.
Save EdwardBock/bcafd4f36942dc3e778b1f9d7181a001 to your computer and use it in GitHub Desktop.
Add reading time field to document setting panel
import { registerPlugin } from "@wordpress/plugins";
import { PluginDocumentSettingPanel } 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 <PluginDocumentSettingPanel
title="Reading time"
>
<TextControl
label="Estimated time in minutes"
onChange={setValue}
value={value}
/>
</PluginDocumentSettingPanel>
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment