On this page
wp_delete_file( string $file )
Deletes a file.
Parameters
$filestring Required-
The path to the file to delete.
Source
File: wp-includes/functions.php. View all references
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 );
}
}
Hooks
- apply_filters( 'wp_delete_file',
string $file ) -
Filters the path of the file to delete.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| wp_delete_file_from_directory() wp-includes/functions.php | Deletes a file if its path is within the given directory. |
| wp_privacy_generate_personal_data_export_file() wp-admin/includes/privacy-tools.php | Generate the personal data export file. |
| wp_ajax_crop_image() wp-admin/includes/ajax-actions.php | Ajax handler for cropping an image. |
| wp_restore_image() wp-admin/includes/image-edit.php | Restores the metadata for a given attachment. |
| wp_save_image() wp-admin/includes/image-edit.php | Saves image to post, along with enqueued changes in |
| Custom_Image_Header::step_3() wp-admin/includes/class-custom-image-header.php | Display third step of custom header image page. |
Changelog
| Version | Description |
|---|---|
| 4.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_delete_file