删除文件

原型

wp_delete_file( string $file )

参数

$file (string) (Required) 要删除的文件的路径。

源文件

路径:wp-includes/functions.php

<?php
...
function wp_delete_file( $file ) {
	/**
	 * Filters the path of the file to delete.
	 *
	 * @since 2.1.0
	 *
	 * @param string $file Path to the file to delete.
	 */
	$delete = apply_filters( 'wp_delete_file', $file );
	if ( ! empty( $delete ) ) {
		@unlink( $delete );
	}
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_delete_file/