WordPress开发者和主题制作者的搜索引擎



validate_file_to_edit ›

Since1.5.0
已弃用n/a
validate_file_to_edit ( $file, $allowed_files = array() )
参数: (2)
  • (string) $file File the user is attempting to edit.
    Required: Yes
  • (string[]) $allowed_files Optional. Array of allowed files to edit. `$file` must match an entry exactly.
    Required: No
    默认: array()
返回:
  • (string|void) Returns the file name on success, dies on failure.
定义在:
文档:

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

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



源码

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.' ) );
	}
}