Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_delete_file_from_directory ›

Da4.9.7
Deprecaton/a
wp_delete_file_from_directory ( $file, $directory )
Parametri: (2)
  • (string) $file Absolute path to the file to delete.
    Richiesto:
  • (string) $directory Absolute path to a directory.
    Richiesto:
Ritorna:
  • (bool) True on success, false on failure.
Definito a:
Codex:

Deletes a file if its path is within the given directory.



Sorgenti

function wp_delete_file_from_directory( $file, $directory ) {
	$real_file      = realpath( wp_normalize_path( $file ) );
	$real_directory = realpath( wp_normalize_path( $directory ) );

	if ( false === $real_file || false === $real_directory || strpos( wp_normalize_path( $real_file ), trailingslashit( wp_normalize_path( $real_directory ) ) ) !== 0 ) {
		return false;
	}

	wp_delete_file( $file );

	return true;
}