Disable the visibility options in WP

Is there a way to disable the public vs private vs password-protected visibility UI when editing or quick-editing a post?

A quick scan in the code yields #visibility, which I could hide using jQuery, but I was wondering if there was a documented way to do this “properly”.

1 Answer
1

Quick hack to get the job done, in case anyone else needs to do this:

add_action('add_meta_boxes', function() {
    add_action('admin_head', function() {
        echo <<<EOS
<style type="text/css">
#visibility {
    display: none;
}
</style>

EOS;
    });
});

add_action('restrict_manage_posts', function() {
    echo <<<EOS
<script type="text/javascript">
jQuery(document).ready(function($) {
    $("input[name="keep_private"]").parents("div.inline-edit-group:first").hide();
});
</script>

EOS;
});

(Still curious to know if there’s a better way.)

Leave a Comment