1

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

  • 1
    What's wrong with CSS? – fuxia Jan 19 '17 at 13:24
0

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.

-2

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

define('WP_POST_REVISIONS', 'false');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.