public static function getLockFile() { if (empty(self::$_LOCKFILE)) { $lockfile = '.cfaojslock'; self::$_LOCKFILE = apply_filters('cfao_script_lockfile', $lockfile); } return self::$_LOCKFILE; }
public static function saveSettings() { if (empty($_POST['cfao_save_settings'])) { // Not our time to save. return; } else { $tab = 'general'; if (!check_admin_referer('cfao-save-settings', 'cfao-save-settings')) { wp_die(__('I\'m sorry, Dave. I can\'t do that.')); } if ($_POST['cfao_save_settings'] == 'save_general_settings') { if (!empty($_POST['cfao_using_cache'])) { update_option('cfao_using_cache', true); } else { update_option('cfao_using_cache', false); } update_option('cfao_security_key', md5($_SERVER['SERVER_ADDR'] . time())); update_option('cfao_minify_js_level', $_POST['js-minify']); do_action('cfao_save_general_settings', $_POST); } else { if ($_POST['cfao_save_settings'] == 'save_scripts') { // Save the scripts data update_option('cfao_scripts', $_POST['scripts']); $tab = 'scripts'; } else { if ($_POST['cfao_save_settings'] == 'save_styles') { update_option('cfao_styles', $_POST['styles']); $tab = 'styles'; } else { if ($_POST['cfao_save_settings'] == 'clear_scripts_cache') { $dir = CFAssetOptimizerScripts::getCacheDir(); if (is_dir($dir)) { $files = opendir($dir); if ($files) { while ($file = readdir($files)) { if (is_file($dir . '/' . $file) && (preg_match('/\\.js$/', $file) || $file == CFAssetOptimizerScripts::getLockFile())) { unlink($dir . '/' . $file); } } } } $tab = 'scripts'; } else { if ($_POST['cfao_save_settings'] == 'clear_styles_cache') { $dir = CFAssetOptimizerStyles::getCacheDir(); if (is_dir($dir)) { $files = opendir($dir); if ($files) { while ($file = readdir($files)) { if (is_file($dir . '/' . $file) && (preg_match('/\\.css$/', $file) || $file == CFAssetOptimizerStyles::getLockFile())) { unlink($dir . '/' . $file); } } } } $tab = 'styles'; } } } } } wp_redirect(add_query_arg('tab', $tab, $_SERVER['REQUEST_URI'])); exit; } }