How do I limit the status options for bulk/quick edit to only Published and Draft?

Answering this Question, came to a jQuery solution to Ana Ban’s one.

add_action( 'admin_head', 'wpse_56551_script_enqueuer' );

function wpse_56551_script_enqueuer() 
{
    global $current_screen;

    /**
       /wp-admin/edit.php?post_type=post
       /wp-admin/edit.php?post_type=page
       /wp-admin/edit.php?post_type=cpt  == gallery in this example
     */
    if( 'edit-gallery' == $current_screen->id ) 
    {
        ?>
        <script type="text/javascript">         
        jQuery(document).ready( function($) {
            $("a.editinline").live("click", function () {
                var ilc_qe_id = inlineEditPost.getId(this);
                setTimeout(function() {
                        $('#edit-'+ilc_qe_id+' select[name="_status"] option[value="pending"]').remove();  
                        $('#edit-'+ilc_qe_id+' select[name="_status"] option[value="private"]').remove();  
                    }, 100);
            });

            $('#doaction, #doaction2').live("click", function () {
                setTimeout(function() {
                        $('#bulk-edit select[name="_status"] option[value="pending"]').remove();  
                        $('#bulk-edit select[name="_status"] option[value="private"]').remove();  
                    }, 100);
            });       
        });    
        </script>
    <?php
    }

    /**
       /wp-admin/post.php?post=21&action=edit
     */
    if( 'gallery' == $current_screen->id ) 
    {
        ?>
        <script type="text/javascript">
        jQuery(document).ready( function($) {
            $('#post_status option[value="pending"]').remove();
            $('#post_status option[value="private"]').remove();
        });
        </script>
    <?php
    }
}

[Original Answer]

Searching for this filter in /wp-admin/, we find it located at
/wp-admin/includes/class-wp-posts-list-table.php. And we see that it
deals with the hierarchy of posts, not with the status…

Further down in this file we find the status group, but it don’t have
any filter, so I suspect there won’t be a hooked solution…

// starting at line 950
<div class="inline-edit-group">
<label class="inline-edit-status alignleft">
  <span class="title"><?php _e( 'Status' ); ?></span>
  <select name="_status">
<?php if ( $bulk ) : ?>
      <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
  <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
      <option value="publish"><?php _e( 'Published' ); ?></option>
      <option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
      <option value="private"><?php _e( 'Private' ) ?></option>
<?php endif; // $bulk ?>
  <?php endif; ?>
      <option value="pending"><?php _e( 'Pending Review' ); ?></option>
      <option value="draft"><?php _e( 'Draft' ); ?></option>
  </select>
</label>

Leave a Comment