Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
622 views
in Q2A Core by
Since I am not using a plugin for that... I want to share a little jquery trick to delete all hidden posts at once:

1. Go to page: admin/hidden

2. Open the scratch pad of firefox (SHIFT + F4)

3. Enter the following:

$('.qa-form-light-button-delete').each( function() {
  $(this).trigger('click');  
})

4. Click on Run and wait

Done.
Q2A version: 1.7.4
by
is this better than the official, because it takes care of the dependency issue?

Go to page: Admin/stats

[Delete hidden posts] - all hidden questions, answer and comments without dependents

1 Answer

+4 votes
by

Good tip, I actually use something similar for moderating posts. A couple of tips:

1. As donshakespeare said you can use the "delete hidden posts" button on the Admin > Stats page, which will delete all of them.

2. In your code you can actually shorten that to remove "each" as jQuery applies functions to all matching elements by default. You can also do click() instead of using trigger. Example:

$('.qa-form-light-button-delete').click();

3. Depending on your server settings "clicking" 50+ posts simultaneously may not work or it may overload your server. You can use slice() to click a limited amount. In this method you should also use ":visible" in the selector because when deleting posts the HTML is only hidden in the page, not removed entirely (until you reload the page). If you run it twice on the same page it will try and click the deleted posts again. This will delete the first 10 posts that have not been deleted:

$('.qa-form-light-button-delete:visible').slice(0,10).click();

For the moderation page, I first skim over the posts and approve any real posts. Then I run this to reject all the spam:

$('.qa-q-list-item:visible .qa-form-light-button-reject').slice(0,10).click();
by
Very excellent!
...