Title: update_recently_edited
Published: April 25, 2014
Last modified: August 20, 2026

---

# update_recently_edited( string $file )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#wp--skip-link--target)

Updates the “recently-edited” file for the plugin or theme file editor.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#parameters)󠁿

 `$file`stringrequired

Path to the recently edited file.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#source)󠁿

    ```php
    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 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/misc.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-admin/includes/misc.php#L339)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-admin/includes/misc.php#L339-L356)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#related)󠁿

| Uses | Description | 
| [update_option()](https://developer.wordpress.org/reference/functions/update_option/)`wp-includes/option.php` |

Updates the value of an option that was already added.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/update_recently_edited/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fupdate_recently_edited%2F)
before being able to contribute a note or feedback.