Filter hook 'wp_delete_file'

in WP Core File wp-includes/functions.php at line 7711

View Source

wp_delete_file

Filter Hook
Description
Filters the path of the file to delete.

Hook Information

File Location wp-includes/functions.php View on GitHub
Hook Type Filter
Line Number 7711

Hook Parameters

Type Name Description
string $file Path to the file to delete.

Usage Examples

Basic Usage
<?php
// Hook into wp_delete_file
add_filter('wp_delete_file', 'my_custom_filter', 10, 1);

function my_custom_filter($file) {
    // Your custom filtering logic here
    return $file;
}

Source Code Context

wp-includes/functions.php:7711 - How this hook is used in WordPress core
<?php
7706  	 *
7707  	 * @since 2.1.0
7708  	 *
7709  	 * @param string $file Path to the file to delete.
7710  	 */
7711  	$delete = apply_filters( 'wp_delete_file', $file );
7712  
7713  	if ( ! empty( $delete ) ) {
7714  		return @unlink( $delete );
7715  	}
7716  

PHP Documentation

<?php
/**
	 * Filters the path of the file to delete.
	 *
	 * @since 2.1.0
	 *
	 * @param string $file Path to the file to delete.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/functions.php
Related Hooks

Related hooks will be displayed here in future updates.