Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a client who wants to use the trash feature, but keep items in there indefinitely (I have no idea why, but they insist on it).

From reading this codex article on the trash status, I see that you can set the EMPTY_TRASH_DAYS constant to zero. But it says that this will disable Trash functionality altogether. I don't want to do this...I just want to disable the auto-trash emptying.

Is there any way to do this? Or am I stuck with just entering some huge number for the EMPTY_TRASH_DAYS value?

share|improve this question
add comment

2 Answers 2

up vote 0 down vote accepted

My guess is - yes, you are stuck with exactly that.

Checks for EMPTY_TRASH_DAYS seem to be hardcoded as condition for switching interface between trash and delete in several places.

share|improve this answer
    
Thank you for the help. Question though--I see that trash collection is scheduled as an event in wp-admin/admin.php (wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');). Do you think it's possible to simply unschedule the event at some point? Maybe on every admin init? Or do you think that's just fighting against the system? –  MathSmath Jan 25 '11 at 20:14
    
@MathSmath hmmm... I don't think it's worth it to fight with schedule (schedules are persistent = messy db reads/writes), but you can try to remove wp_scheduled_delete() function from wp_scheduled_delete hook. I am not sure about at what hook/stage it would be best for that in cron environment. –  Rarst Jan 25 '11 at 20:29
    
Cool. Thanks for the help! –  MathSmath Jan 25 '11 at 20:58
add comment

You can do the following:

  • Set EMPTY_TRASH_DAYS to a very high number. E.g.: define( 'EMPTY_TRASH_DAYS', 1000000 );

  • Or remove the wp_schedule_delete action:

    function my_remove_schedule_delete() {
        remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
    }
    add_action( 'init', 'my_remove_schedule_delete' );
    
share|improve this answer
    
Thank you for the answer! I actually worked it out with Rarst just a few minutes before you posted. I'm giving you a vote and Rarst the answer. Thanks again! –  MathSmath Jan 25 '11 at 20:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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