Quick edit screen customization

I use this to add form fields to the quick edit. It’s not entirely easy to do this in WP (yet) and it can be very difficult to find info on how to do it. You have to really dig through the source to find it too.

Add Form fields to Quick Edit

<?php
add_action('quick_edit_custom_box', 'quickedit_posts_custom_box', 10, 2);
add_action('admin_head-edit.php', 'quick_add_script');

function quickedit_posts_custom_box( $col, $type ) {
    if( $col != 'COLUMN_NAME' || $type != 'post' ) {
        return;
    } ?>
    <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
        <div class="inline-edit-group">
            <label class="alignleft">
                <input type="checkbox" name="yourformfield" id="yourformfield_check">
                <span class="checkbox-title">This Post Has Cake</span>
            </label>
        </div>
    </fieldset>
    <?php
}

function quick_add_script() { ?>
    <script type="text/javascript">
    jQuery(document).ready(function() {
        jQuery('a.editinline').live('click', function() {
            var id = inlineEditPost.getId(this);
            var val = parseInt(jQuery('#inline_' + id + '_yourformfield').text());
            jQuery('#yourformfield_check').attr('checked', !!val);
        });
    });
    </script>
    <?php
}

Leave a Comment