Remove "Save draft" button without using CSS

Is there a way to remove "Save draft" button without the use of CSS?

Topic buttons draft customization Wordpress

Category Web


You cannot just remove the "Save draft" as the button is tied up in the submitdiv metabox HTML defined in the function post_submit_meta_box().

However we can alter the callback for this metabox and replace it with our own function.

We can bind to the submitpost_box event and give the binding a height weight so it fires last...

add_action('submitpost_box', 'my_module_edit_form_after_editor', 100);

Then when our action is called we can swap out the metabox callback:

function my_module_edit_form_after_editor() {
    global $wp_meta_boxes;

    $post_type = 'feed';
    $context   = 'side';
    $priority  = 'core';

    $wp_meta_boxes[$post_type][$context][$priority]['submitdiv']['callback'] = 'my_custom_post_submit_meta_box';

}

And then we just need to define what our custom metabox will look like. You could just take the core function post_submit_meta_box() and put it into your own plugin removing the unneeded sections, however I would recommend using an actual template and not just closing php tags half way though a function as that just leads to difficult to follow horrible spaghetti code.


Please put the below lines in your wp-config.php

define('WP_POST_REVISIONS', 'false');

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.