The author told me to clone his plugin and extend it to support what we require. Oh well.
Andrew
if you go into the plugin and find
wp-sweep.php
find line 557 which says
foreach ( $query as $id ) {
wp_delete_post_revision( (int) $id );
}
and amend to
foreach ( $query as $id ) {
$post_parent_id = wp_get_post_parent_id ($id) ;
$type = get_post_type ($post_parent_id) ;
if ($type != 'topic' && $type != 'reply' )
wp_delete_post_revision( (int) $id );
}
that should do it
Thanks. I will try this on my beta site tomorrow.
Will this work for both:
Revision
Tag
?
Andy
Actually, this is the (I hope) correct code for revisions
foreach ( $query as $id ) {
$post_parent_id = wp_get_post_parent_id ($id) ;
$type = get_post_type ($post_parent_id) ;
if ($type != 'topic' && $type != 'reply' )
wp_delete_post_revision( (int) $id );
}
I can’t see an option for tags in the code
Hi @robin-w
Thanks for the revised code which I have yet to try.
There are two aspects in general to consider with respects to the plugin:
1. The actual sweeping (which you have been looking at)
2. The actual stats provided on the plugin page.
Both ideally need to be addressed. For example, you mention about the tags, but in his backend they are referred to as terms:
View post on imgur.com
I think terms are unused_terms in the function you referred to. But as mentioned, for this sweeping change to make sense the stats also need revising so they are not included in the counts or detail lists.
Your new code is working fine for “revisions” 🙂
It turns out that in the backend after I run your code I am left with two revisions. Both of which are forum posts 🙂 Cool .. well done.
Maybe we can do the same for the terms (tags)?
Andrew
the ‘term’ code deletes orphaned and unused stuff in the database. By definition these belong to nothing, so there is no bbpress relationship (or indeed other relationship) that you can select against
Ok! Then I will go ahead and sweep those terms. Thanks.
Here are the results after running the sweep for revisions:
View post on imgur.com
So 3 are good. I am not sure about the two “null” ones though?
The terms are now purged. 🙂
Thanks for your help.
no idea ! but I think you are there in terms of getting rid of 99.9999% !
I have delved into the database using php admin on my domain portal to see what is happening.
All of the “null” entries are where we have revisions for “replies” to “topics”. So if a “topic” has a revision it is listed. But if it is a reply, it is not listed. I verified this by doing the sql query in the database and those fields are empty.
So whilst it looks “odd” that there is these null items they are valid. Technically the wp sweep should be improved to obtain those names from the primary topic and list it rather than null.
But at least we know why now.