Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit d87060d

Browse files
committed
fix: regen config file on deactivation/activation
1 parent af18528 commit d87060d

1 file changed

Lines changed: 7 additions & 28 deletions

File tree

frak-integration.php

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
Plugin Name: Frak
44
Description: Adds Frak configuration to your WordPress site
5-
Version: 0.5
5+
Version: 0.6
66
Author: Frak-Labs
77
*/
88

@@ -53,35 +53,14 @@ function frak_save_config_file($config_content) {
5353
return false;
5454
}
5555

56-
// Handle the config file request
57-
function frak_handle_config_request($wp) {
58-
if (isset($wp->query_vars['frak_config'])) {
59-
$file_path = frak_get_config_file_path();
60-
61-
if (file_exists($file_path)) {
62-
$last_modified = get_option('frak_config_last_modified', 0);
63-
64-
// Set proper headers for caching
65-
header('Content-Type: application/javascript');
66-
header('Cache-Control: public, max-age=31536000'); // 1 year
67-
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $last_modified) . ' GMT');
68-
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
69-
70-
// Check if the browser has a cached version
71-
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
72-
$if_modified_since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
73-
if ($if_modified_since >= $last_modified) {
74-
header('HTTP/1.1 304 Not Modified');
75-
exit;
76-
}
77-
}
78-
79-
readfile($file_path);
80-
exit;
81-
}
56+
// Register an activation hook to regenerate the config file
57+
function frak_plugin_activate() {
58+
$custom_config = get_option('frak_custom_config', '');
59+
if (!empty($custom_config)) {
60+
frak_save_config_file($custom_config);
8261
}
8362
}
84-
add_action('parse_request', 'frak_handle_config_request');
63+
register_activation_hook(__FILE__, 'frak_plugin_activate');
8564

8665
// Register settings
8766
function frak_register_settings() {

0 commit comments

Comments
 (0)