|
2 | 2 | /* |
3 | 3 | Plugin Name: Frak |
4 | 4 | Description: Adds Frak configuration to your WordPress site |
5 | | -Version: 0.5 |
| 5 | +Version: 0.6 |
6 | 6 | Author: Frak-Labs |
7 | 7 | */ |
8 | 8 |
|
@@ -53,35 +53,14 @@ function frak_save_config_file($config_content) { |
53 | 53 | return false; |
54 | 54 | } |
55 | 55 |
|
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); |
82 | 61 | } |
83 | 62 | } |
84 | | -add_action('parse_request', 'frak_handle_config_request'); |
| 63 | +register_activation_hook(__FILE__, 'frak_plugin_activate'); |
85 | 64 |
|
86 | 65 | // Register settings |
87 | 66 | function frak_register_settings() { |
|
0 commit comments