4

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.

2 Answers 2

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 );
}
5
  • 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... Commented Sep 12, 2012 at 7:44
  • 1
    just note that a core update may overwrite your changes! I don't see another option in this case though.
    – Milo
    Commented Sep 12, 2012 at 16:01
  • What about sending a patch or request for feature to the wordpress team?
    – Stephan
    Commented Dec 22, 2012 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
    Commented Dec 22, 2012 at 18:18
  • this is not a solution, it's an answer to the question of where this option is set.
    – Milo
    Commented Dec 23, 2012 at 21:19
5

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?

1
  • One should write a(nother) dashboard widget for it ;) I guess this is used by those "security"/paranoia plugins only.
    – kaiser
    Commented Dec 23, 2012 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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