Plugin Topics: Meta Boxes and Cron
The next few items (Meta Boxes, and Cron) are nice to have, require a lot more work, and are not necessary for the majority of plugin projects. I include them here because I'm interested in what they do and can think of a few projects that would benefit from one or more of them. ## Custom Meta Boxes [Custom Meta Boxes](https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/) allows you to create custom sections of the editor screen where users can enter custom data and you can then sanitize it and save it to the database. Because they allow custom data we need to follow all the security rules: sanitize the input and check roles and capabilities before we do anything with the data we're working with. Since this has admin-facing data we should also take care of internationalization for the UI labels and strings. ### Adding the box The first step is to add a meta box to the editor screen. [add\_meta\_box()](https://developer.wordpress.org/reference/functions/add_meta_box/) create an empty box. The [add\_meta\_boxes()](https://developer.wordpress.org/reference/hooks/add_meta_boxes/) takes three parameters: * the name of the action to take, `add_meta_boxes` * A callback function with the specific code we want to run * The post type we want to run this meta box for **Potential Gotcha** The function is `add_meta_box()` (singular). The hook to register the metaboxes is `add_meta_boxes()` (plural). Keep this in mind when writing code that adds meta boxes to the editor. ```php ID ); ?>