функция
since 1.5.0
validate_file_to_edit()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
validate_file_to_edit( string $file, string[] $allowed_files = array() ): string|void
Описание
Функция завершит выполнение, если у вас нет прав на редактирование файла.
Оригинал (английский)
Function will die if you are not allowed to edit the file.
Параметры
$file
string
обязательный
Файл, который пользователь пытается редактировать.
$allowed_files
string[]
необязательный
= array()
Массив файлов, разрешённых для редактирования.
$file должен точно совпадать с одной из записей.
Возвращаемое значение
string|void
Исходный код
wp-admin/includes/file.php:739
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, cannot call files with their real path.' ));
case 3:
wp_die( __( 'Sorry, that file cannot be edited.' ) );
}
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

