Any way to create a revision of a post ONLY with a new button in the Meta Box?

This is not yet a complete answer, for lack of time, though I’ll try to return later with a more complete example but I just wanted to add a couple of notes. Possibly someone else will jump in soon.

To get the ball rolling…

Firstly,

Yes this is entirely possible, you can create this functionality and in your snippet you’ll see some of the relevant hooks you need to be working with.

add_action('_wp_put_post_revision', 'your_function");

Found in ../wp-includes/post.php along with other relevant hooks relating to revisions.

Secondly,

To add a Save Revision button next to or on top of the Publish button you would use the following hook;

add_action( 'post_submitbox_misc_actions', 'custom_button' );

function custom_button(){
        $html="<div id="major-publishing-actions" style="overflow:hidden">";
        $html .= '<div id="publishing-action">';
        $html .= '<input type="submit" accesskey="p" tabindex="5" value="Customize Me!" class="button-primary" id="custom" name="publish">';
        $html .= '</div>';
        $html .= '</div>';
        echo $html;
}

That’s a working example and the html formatting (divs, id's, etc) are there to preserve some kind of consistent UI experience but feel free to change any of that to your liking, especially if you want a custom look and feel or special padding, margins and so forth.

PS. Try and attempt, regardless of the outcome, to write your own function hooking onto _wp_put_post_revision in conjunction with the custom button hook above. Paste your results in the meantime.

Leave a Comment