2

For my custom post type, I only want to have "Published" and "Draft" as the available options in the bulk edit and quick edit screens, i.e.

screenshot

I tried hooking on to the filter quick_edit_dropdown_pages_args but it doesn't seem to get fired. I inserted a wp_die() in my callback but the admin screen lists all posts like nothing changed. Any idea?

Thanks in advance.

1
  • ok, so i found the wp_die() IS getting fired, but it doesn't stop the whole page from displaying -- only the drop-down menu. just clarifying. thanks, y'all.
    – Ana Ban
    Jun 27, 2012 at 8:01

1 Answer 1

1

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>
2
  • so frustrating. had to settle for a core edit. thanks for validating my suspicion that this couldn't be hooked for now. :D
    – Ana Ban
    Jun 27, 2012 at 7:59
  • @AnaBan : Edited the Answer and posted a jQuery workaround ;)
    – brasofilo
    Jul 11, 2012 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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