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.

WP recently_edited option can be very useful - it tracks last 5 files that you've made changes to. Only problem is - well, that's all, 5 files.

What if I've been made numerous changes to Wordpress theme files by using default WP admin editor?

It would be helpfull if I had list of, say last 20 files edited and time when that happened.

Do anyone know where is stored function or some else mechanism that allow only 5 item to reside into array of recently_edited WP option?

I've tried with wp-admin/includes/schema.php and wp-includes/option.php where it, as I tohught, should be - no results.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

The function is update_recently_edited in wp-admin/includes/misc.php. unfortunately it is fixed at 5:

function update_recently_edited( $file ) {
    $oldfiles = (array) get_option( 'recently_edited' );
    if ( $oldfiles ) {
        $oldfiles = array_reverse( $oldfiles );
        $oldfiles[] = $file;
        $oldfiles = array_reverse( $oldfiles );
        $oldfiles = array_unique( $oldfiles );
        if ( 5 < count( $oldfiles ))
            array_pop( $oldfiles );
    } else {
        $oldfiles[] = $file;
    }
    update_option( 'recently_edited', $oldfiles );
}
share|improve this answer
    
Milo, thanks very much for answer. It is defined to 5, but, as I see, it can be easily changed to any other number. Let me see if it works... –  Miloshio Sep 12 '12 at 7:44
    
Yes. It works. Thanks again. –  Miloshio Sep 12 '12 at 7:50
1  
just note that a core update may overwrite your changes! I don't see another option in this case though. –  Milo Sep 12 '12 at 16:01
    
What about sending a patch or request for feature to the wordpress team? –  Alex Dec 22 '12 at 16:05
    
It is was fine, that the patch get a filter hook for the value. Current is this solution not usefull, it's a problem on updates. –  bueltge Dec 22 '12 at 18:18
show 1 more comment

The process of saving option conveniently offers filter for new value, with access to old value as well. We only need to combine both and give it to WP as value to save:

add_filter( 'pre_update_option_recently_edited', 'increase_recently_edited_list', 10, 2 );

function increase_recently_edited_list( $newvalue, $oldvalue ) {

    return array_slice( array_unique( array_merge( $newvalue, $oldvalue ) ), 0, 20 );
}

PS curiously I can't figure out where is this list actually used?.. Or is it just there for those who want something to do with it in extensions?

share|improve this answer
    
One should write a(nother) dashboard widget for it ;) I guess this is used by those "security"/paranoia plugins only. –  kaiser Dec 23 '12 at 9:45
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.