You are here

function facebook_tracking_pixel_save_file in Facebook Tracking Pixel 7

Same name and namespace in other branches
  1. 8 facebook_tracking_pixel.module \facebook_tracking_pixel_save_file()

Saves JavaScript in the file system (but only if not empty).

Parameters

$data:

$filename:

null $subdir:

Return value

bool|null|string

6 calls to facebook_tracking_pixel_save_file()
facebook_tracking_pixel_base_codes_add_form_submit in ./facebook_tracking_pixel.admin.inc
Submit handler for the new base code tracking id form.
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_commerce_form_submit in ./facebook_tracking_pixel.admin.commerce.inc
Submit handler for commerce tracking admin form.
facebook_tracking_pixel_path_add_form_submit in ./facebook_tracking_pixel.admin.path.inc
Submit handler to add a new path based event.
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 788
facebook_tracking_pixel.module Facebook Tracking Module.

Code

function facebook_tracking_pixel_save_file($data, $filename, $subdir = NULL) {
  if (!drupal_strlen(trim($data))) {
    return FALSE;
  }
  $path = variable_get('facebook_tracking_pixel_path', 'public://facebook_tracking_pixel');
  if (!empty($subdir)) {
    $path = $path . '/' . $subdir;
  }
  file_prepare_directory($path, FILE_CREATE_DIRECTORY);
  $file_saved = file_unmanaged_save_data($data, $path . '/' . $filename, FILE_EXISTS_REPLACE);
  facebook_tracking_pixel_clear_cache();
  return $file_saved;
}