| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.12 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Admin; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
if (!class_exists('Activation')) |
| 20 |
{ |
| 21 |
require_once FBOX_PLUGIN_DIR . 'Inc/Framework/Inc/Admin/Includes/Activation.php'; |
| 22 |
} |
| 23 |
|
| 24 |
class PluginActivation extends \Activation |
| 25 |
{ |
| 26 |
/** |
| 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 |
* |
| 34 |
* @return void |
| 35 |
*/ |
| 36 |
public function start() |
| 37 |
{ |
| 38 |
$this->pluginActivation(); |
| 39 |
|
| 40 |
\FireBox\Core\Helpers\Activation::createLibraryDirectories(); |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
$this->installDefaultSettings(); |
| 45 |
|
| 46 |
// initialize capabilities |
| 47 |
new Capabilities(); |
| 48 |
|
| 49 |
// Each site runs its own log retention cleanup; cron is per site. |
| 50 |
\FireBox\Core\FB\Log::maybeScheduleCleanup(); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 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 |
* |
| 70 |
* @return void |
| 71 |
*/ |
| 72 |
private function installDefaultSettings() |
| 73 |
{ |
| 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)); |
| 102 |
} |
| 103 |
|
| 104 |
} |
| 105 |
|