ACF_Local_JSON::delete_file
Deletes an ACF JSON file.
Method of the class: ACF_Local_JSON{}
No Hooks.
Returns
true|false.
Usage
$ACF_Local_JSON = new ACF_Local_JSON(); $ACF_Local_JSON->delete_file( $key, $post );
- $key(string) (required)
- The ACF post key.
- $post(array)
- The main ACF post array.
Default:array()
Changelog
| Since 5.9.0 | Introduced. |
ACF_Local_JSON::delete_file() ACF Local JSON::delete file code ACF 6.8.8
public function delete_file( $key, $post = array() ) {
$paths = $this->get_save_paths( $key, $post );
$filename = $this->get_filename( $key, $post );
if ( ! $filename ) {
return false;
}
foreach ( $paths as $path_to_check ) {
$file = untrailingslashit( $path_to_check ) . '/' . $filename;
if ( is_writable( $file ) ) { //phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_is_writable -- non-compatible function for this purpose.
wp_delete_file( $file );
}
}
return true;
}