| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -17,17 +17,21 @@ | ||
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | if (!class_exists('Activation')) |
| 20 | 20 | { |
| 21 | - require_once FBOX_PLUGIN_DIR . '/Inc/Framework/Inc/Admin/Includes/Activation.php'; | |
| 21 | + require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Admin/Includes/Activation.php'; | |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | class PluginActivation extends \Activation |
| 25 | 25 | { |
| 26 | 26 | /** |
| 27 | - * Runs once we activate the plugin. | |
| 28 | - * Set plugin data | |
| 29 | - * | |
| 27 | + * Installs FireBox on the current site. | |
| 28 | + * | |
| 29 | + * Idempotent: it runs on activation, for every site of a network, when a | |
| 30 | + * site is added to a network, and as a self-heal on version drift. Callers | |
| 31 | + * go through SiteInstaller, which decides which sites to run it on and | |
| 32 | + * handles the migrations an existing site needs. | |
| 33 | + * | |
| 30 | 34 | * @return void |
| 31 | 35 | */ |
| 32 | 36 | public function start() |
| 33 | 37 | { |
| @@ -32,55 +36,69 @@ | ||
| 32 | 36 | public function start() |
| 33 | 37 | { |
| 34 | 38 | $this->pluginActivation(); |
| 35 | 39 | |
| 36 | - require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Helpers/Directory.php'; | |
| 37 | - require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Helpers/WPHelper.php'; | |
| 38 | 40 | \FireBox\Core\Helpers\Activation::createLibraryDirectories(); |
| 39 | - | |
| 40 | - // Set plugin version | |
| 41 | - update_option('firebox_version', FBOX_VERSION); | |
| 42 | 41 | |
| 43 | 42 | |
| 44 | 43 | |
| 45 | - // set default plugin settings | |
| 46 | - if (!get_option('firebox_settings')) | |
| 47 | - { | |
| 48 | - $settings = [ | |
| 49 | - 'showcopyright' => '1', | |
| 50 | - 'show_admin_bar_menu_item' => '1', | |
| 51 | - 'debug' => '0', | |
| 52 | - 'statsdays' => '730', | |
| 53 | - 'geo_license_key' => '', | |
| 54 | - 'keep_data_on_uninstall' => '1', | |
| 55 | - 'usage_tracking' => '0', | |
| 56 | - 'enable_phpscripts' => '0', | |
| 57 | - 'license_key' => '', | |
| 58 | - ]; | |
| 44 | + $this->installDefaultSettings(); | |
| 59 | 45 | |
| 60 | - foreach (\FireBox\Core\Helpers\Integrations::getSettingsKeys() as $integration_key) | |
| 61 | - { | |
| 62 | - $settings[$integration_key] = ''; | |
| 63 | - } | |
| 64 | - | |
| 65 | - update_option('firebox_settings', $settings); | |
| 66 | - } | |
| 67 | - | |
| 68 | 46 | // initialize capabilities |
| 69 | 47 | new Capabilities(); |
| 70 | 48 | |
| 71 | - // Redirect to dashboard on first activation for onboarding | |
| 72 | - $this->redirectToDashboard(); | |
| 49 | + // Each site runs its own log retention cleanup; cron is per site. | |
| 50 | + \FireBox\Core\FB\Log::maybeScheduleCleanup(); | |
| 73 | 51 | } |
| 74 | 52 | |
| 75 | 53 | /** |
| 76 | - * Redirect to FireBox dashboard on first plugin activation | |
| 77 | - * Initialize onboarding flow | |
| 78 | - * | |
| 54 | + * Whether this site already has the FireBox tables. | |
| 55 | + * | |
| 56 | + * @return bool | |
| 57 | + */ | |
| 58 | + public function tablesInstalled() | |
| 59 | + { | |
| 60 | + return (bool) $this->tablesInitialized(); | |
| 61 | + } | |
| 62 | + | |
| 63 | + /** | |
| 64 | + * Writes any missing default settings. | |
| 65 | + * | |
| 66 | + * Missing keys are filled in rather than the whole option being written | |
| 67 | + * only when absent: a site can end up with a partial firebox_settings from | |
| 68 | + * a migration long before it ever sees this method. | |
| 69 | + * | |
| 79 | 70 | * @return void |
| 80 | 71 | */ |
| 81 | - private function redirectToDashboard() | |
| 72 | + private function installDefaultSettings() | |
| 82 | 73 | { |
| 83 | - // Set option to mark that we should redirect after activation | |
| 84 | - update_option('firebox_activation_redirect', true); | |
| 74 | + $settings = get_option('firebox_settings'); | |
| 75 | + $settings = is_array($settings) ? $settings : []; | |
| 76 | + | |
| 77 | + $defaults = [ | |
| 78 | + 'showcopyright' => '1', | |
| 79 | + 'show_admin_bar_menu_item' => '1', | |
| 80 | + 'debug' => '0', | |
| 81 | + 'statsdays' => '730', | |
| 82 | + 'geo_license_key' => '', | |
| 83 | + 'keep_data_on_uninstall' => '1', | |
| 84 | + 'usage_tracking' => '0', | |
| 85 | + 'enable_phpscripts' => '0', | |
| 86 | + 'license_key' => '', | |
| 87 | + ]; | |
| 88 | + | |
| 89 | + foreach (\FireBox\Core\Helpers\Integrations::getSettingsKeys() as $integration_key) | |
| 90 | + { | |
| 91 | + $defaults[$integration_key] = ''; | |
| 92 | + } | |
| 93 | + | |
| 94 | + $missing = array_diff_key($defaults, $settings); | |
| 95 | + | |
| 96 | + if (!$missing) | |
| 97 | + { | |
| 98 | + return; | |
| 99 | + } | |
| 100 | + | |
| 101 | + update_option('firebox_settings', array_merge($settings, $missing)); | |
| 85 | 102 | } |
| 103 | + | |
| 86 | 104 | } |