wp_delete_file

Delete a file.

Description

wp_delete_file( (string) $file ); 

Parameters (1)

0. $file (string)
The path to the file to delete.

Usage

  1. if ( !function_exists( 'wp_delete_file' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // The path to the file to delete. 
  5. $file = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_delete_file($file); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_delete_file( $file ) { 
  2. /** 
  3. * Filters the path of the file to delete. 
  4. * @since 2.1.0 
  5. * @param string $medium Path to the file to delete. 
  6. */ 
  7. $delete = apply_filters( 'wp_delete_file', $file ); 
  8. if ( ! empty( $delete ) ) { 
  9. @unlink( $delete );