How to change option recently_edited?

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?

Read More

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.

Related posts

Leave a Reply

2 comments

  1. 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 );
    }
    
  2. 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?