1

How do you add a custom field to the comments "Quick Edit" screen?

The code below only shows on the posts quick edit screen:

function tips_quick_edit_fields( $column, $post_type ) {
?>
    <fieldset>
    <div class="inline-edit-col">
        <label>
            <input type="checkbox" name="featured"> Is this a tip?
        </label>
    </div>
    </fieldset>
<?php
}
add_action( 'quick_edit_custom_box',  'tips_quick_edit_fields', 10, 2 );

I can't find information anywhere on how to make it appear on the comments "Quick Edit" screen though.

Is it even possible?

3
  • Does this question help at all? It's not specific to the comment's section but you might be able to tweak the answer from there.
    – YourManDan
    Mar 22 at 14:14
  • Thanks, but I looked at that post before posting this and still couldn't figure out how to edit the "quick edit" for comments box. Mar 23 at 7:21
  • @BrianSmith it's true that you can use the wp_comment_reply filter to add your custom field to the inline comment editor form, but the Quick Edit is a JS feature, so I'd use PHP+JS to add the custom field - i.e. using another hook to echo the HTML in your function. After all, you'd still need to use JS to make the rest work, e.g. to auto-check the field after saving the edited comment.
    – Sally CJ
    Mar 29 at 17:33

1 Answer 1

0

Here's the function responsible for rendering the comments quick edit form: wp_comment_reply.

Looking at its code, it seems you can short-circuit it using the wp_comment_reply filter. That only lets you start from scratch though (e.g. you can't add to the existing form).

The only way around this that I can think of is some (unholy) code like:

function your_custom_quick_edit_form($content) {
    remove_filter('wp_comment_reply', 'your_custom_quick_edit_form', 10, 2);

    ob_start();
    wp_comment_reply();
    $content = ob_get_clean();

    // Do horrible stuff here with str_replace and the likes
    $content = str_replace('<fieldset class="comment-reply">', '<fieldset class="comment-reply">I shouldn\'t be here', $content);

    return $content;
}

add_filter('wp_comment_reply', 'your_custom_quick_edit_form', 10);

But really, you probably shouldn't do that. It seems this area of the dashboard isn't really meant for customization.

Your Answer

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

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