I’m building post to email plugin and I need to add a checkbox to the publish post widget like this one:
My idea is to add a checkbox that says “Send this by email”, and get that info inside the publish_post listener:
add_action('publish_post', function($post_id) {
// Was the checkbox checked?
}
How can this be done?
Hook into post_submitbox_misc_actions
and print the checkbox:
add_action( 'post_submitbox_misc_actions', function() {
?>
<div class="misc-pub-section">
<label><input type="checkbox"> click me</label>
</div>
<?php
});
Wrap the code in a <div class="misc-pub-section">
, otherwise the spacing looks a little bit weird.
Examples: language selector, noindex checkbox, public preview checkbox.