Summery Summery

Makes sure that the file that was requested to be edited is allowed to be edited.

Syntax Syntax

validate_file_to_edit( string $file, string[] $allowed_files = array() )

Description Description

Function will die if you are not allowed to edit the file.

Parameters Parameters


(string) (Required) File the user is attempting to edit.


(string[]) (Optional) Array of allowed files to edit. $file must match an entry exactly.

Default value: array()

Return Return

(string|void) Returns the file name on success, dies on failure.

Source Source

File: wp-admin/includes/file.php

function validate_file_to_edit( $file, $allowed_files = array() ) {
	$code = validate_file( $file, $allowed_files );

	if ( ! $code ) {
		return $file;

	switch ( $code ) {
		case 1:
			wp_die( __( 'Sorry, that file cannot be edited.' ) );

			// case 2 :
			// wp_die( __('Sorry, can’t call files with their real path.' ));

		case 3:
			wp_die( __( 'Sorry, that file cannot be edited.' ) );


Changelog Changelog

Version Description
1.5.0 Introduced.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.