| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.0.8 Free | |
| 4 | + * @version 2.1.39 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2025 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core\Controllers; |
| @@ -21,8 +21,10 @@ | ||
| 21 | 21 | use FPFramework\Base\Ui\Tabs; |
| 22 | 22 | |
| 23 | 23 | class BoxSettings extends BaseController |
| 24 | 24 | { |
| 25 | + protected $action = ''; | |
| 26 | + | |
| 25 | 27 | /** |
| 26 | 28 | * The form settings name |
| 27 | 29 | * |
| 28 | 30 | * @var string |
| @@ -28,8 +30,13 @@ | ||
| 28 | 30 | * @var string |
| 29 | 31 | */ |
| 30 | 32 | const settings_name = 'firebox_settings'; |
| 31 | 33 | |
| 34 | + public function __construct() | |
| 35 | + { | |
| 36 | + add_action('update_option_firebox_settings', [$this, 'after_update_settings'], 10, 3); | |
| 37 | + } | |
| 38 | + | |
| 32 | 39 | /** |
| 33 | 40 | * Render the page content |
| 34 | 41 | * |
| 35 | 42 | * @return void |
| @@ -42,8 +49,25 @@ | ||
| 42 | 49 | // render layout |
| 43 | 50 | firebox()->renderer->admin->render('pages/settings'); |
| 44 | 51 | } |
| 45 | 52 | |
| 53 | + /** | |
| 54 | + * Stop the usage tracking if the user disables the tracking behavior. | |
| 55 | + * | |
| 56 | + * @param array $old_value | |
| 57 | + * @param array $new_value | |
| 58 | + * | |
| 59 | + * @return void | |
| 60 | + */ | |
| 61 | + public function after_update_settings($old_value, $new_value) | |
| 62 | + { | |
| 63 | + if (isset($new_value['usage_tracking']) && !$new_value['usage_tracking']) | |
| 64 | + { | |
| 65 | + $tracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 66 | + $tracking->stop(); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 46 | 70 | /** |
| 47 | 71 | * Load required media files |
| 48 | 72 | * |
| 49 | 73 | * @return void |
| @@ -57,9 +81,9 @@ | ||
| 57 | 81 | [], |
| 58 | 82 | FPF_VERSION, |
| 59 | 83 | false |
| 60 | 84 | ); |
| 61 | - wp_enqueue_script( 'fpf-geoip' ); | |
| 85 | + wp_enqueue_script('fpf-geoip'); | |
| 62 | 86 | } |
| 63 | 87 | |
| 64 | 88 | /** |
| 65 | 89 | * Callback used to handle the processing of settings. |
| @@ -70,22 +94,32 @@ | ||
| 70 | 94 | * @return void |
| 71 | 95 | */ |
| 72 | 96 | public function processBoxSettings($input) |
| 73 | 97 | { |
| 74 | - // create a unique db option to use it on all plugins to fetch the geo license key | |
| 75 | - $geo_license_key = ''; | |
| 76 | - if (isset($input['geo_license_key']) && !empty($input['geo_license_key'])) | |
| 77 | - { | |
| 78 | - $geo_license_key = $input['geo_license_key']; | |
| 79 | - } | |
| 80 | - update_option('fpf_geo_license_key', $geo_license_key); | |
| 98 | + if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], ['firebox_download_key_notice_activate', 'firebox_enable_usage_tracking'])) | |
| 99 | + { | |
| 100 | + return $input; | |
| 101 | + } | |
| 102 | + | |
| 103 | + // run a quick security check | |
| 104 | + if (!check_admin_referer('fpf_form_nonce_firebox_settings', 'fpf_form_nonce_firebox_settings')) | |
| 105 | + { | |
| 106 | + return; // get out if we didn't click the Activate button | |
| 107 | + } | |
| 81 | 108 | |
| 109 | + // Disable usage tracking | |
| 110 | + if (!isset($input['usage_tracking'])) | |
| 111 | + { | |
| 112 | + $tracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 113 | + $tracking->stop(); | |
| 114 | + } | |
| 115 | + | |
| 82 | 116 | |
| 83 | 117 | |
| 84 | 118 | // Filters the fields value |
| 85 | 119 | \FPFramework\Helpers\FormHelper::filterFields($input, \FireBox\Core\Admin\Forms\Settings::getSettings()); |
| 86 | 120 | |
| 87 | - add_settings_error( self::settings_name, 'settings_updated', fpframework()->_('FPF_SETTINGS_SAVED'), 'success'); | |
| 121 | + \FPFramework\Libs\AdminNotice::displaySuccess(fpframework()->_('FPF_SETTINGS_SAVED')); | |
| 88 | 122 | |
| 89 | 123 | return $input; |
| 90 | 124 | } |
| 91 | 125 | |
| @@ -115,17 +149,13 @@ | ||
| 115 | 149 | } |
| 116 | 150 | |
| 117 | 151 | // render settings as tabs |
| 118 | 152 | $tabs = new Tabs($settings); |
| 119 | - ob_start(); | |
| 120 | - $tabs->render(); | |
| 121 | - $html = ob_get_contents(); | |
| 122 | - ob_end_clean(); | |
| 123 | 153 | |
| 124 | 154 | // render form |
| 125 | - $form = new Form($html, [ | |
| 126 | - 'section_name' => self::settings_name, | |
| 127 | - 'vertical' => true | |
| 155 | + $form = new Form($tabs->render(), [ | |
| 156 | + 'section_name' => self::settings_name | |
| 128 | 157 | ]); |
| 129 | - $form->render(); | |
| 158 | + | |
| 159 | + echo $form->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 130 | 160 | } |
| 131 | 161 | } |