You are here

function facebook_tracking_pixel_delete_file in Facebook Tracking Pixel 8

Same name and namespace in other branches
  1. 7 facebook_tracking_pixel.module \facebook_tracking_pixel_delete_file()

Deletes all CSS & JavaScript from the file system or a single file.

Parameters

null $filename:

null $subdir:

Return value

bool

6 calls to facebook_tracking_pixel_delete_file()
facebook_tracking_pixel_base_codes_edit_form_submit in ./facebook_tracking_pixel.admin.inc
Submit handler for the base code edit form.
facebook_tracking_pixel_base_code_delete in ./facebook_tracking_pixel.module
Remove a base code by the FBID number.
facebook_tracking_pixel_commerce_form_submit in ./facebook_tracking_pixel.admin.commerce.inc
Submit handler for commerce tracking admin form.
facebook_tracking_pixel_path_delete_form_submit in ./facebook_tracking_pixel.admin.path.inc
Delete submit handler for the delete form.
facebook_tracking_pixel_path_edit_form_submit in ./facebook_tracking_pixel.admin.path.inc
Submit handler for path edit form.

... See full list

File

./facebook_tracking_pixel.module, line 727
facebook_tracking_pixel.module Facebook Tracking Module.

Code

function facebook_tracking_pixel_delete_file($filename = NULL, $subdir = NULL) {
  $path = variable_get('facebook_tracking_pixel_path', 'public://facebook_tracking_pixel');

  // Calling the function without a file name will delete everything.
  if ($filename == NULL) {
    if (!($files = file_scan_directory($path, '/.*\\.js$/'))) {
      foreach ($files as $key => $value) {
        file_unmanaged_delete($path . '/' . $key);
      }
      return TRUE;
    }
  }
  else {
    if (!empty($subdir)) {
      $deletepath = $path . '/' . $subdir . '/' . $filename;
    }
    else {
      $deletepath = $path . '/' . $filename;
    }
    file_unmanaged_delete($deletepath);
    return TRUE;
  }
  return FALSE;
}