| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 2.1.14 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2024 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 |
class AdminPageSettings |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Register Settings Data |
| 23 |
* |
| 24 |
* @var array |
| 25 |
*/ |
| 26 |
const registerSettingsData = [ |
| 27 |
// FireBox Global Settings Page |
| 28 |
[ |
| 29 |
'option_group' => 'firebox_settings', |
| 30 |
'option_name' => 'firebox_settings', |
| 31 |
'controller' => '\FireBox\Core\Controllers\BoxSettings', |
| 32 |
'process_data_method' => 'processBoxSettings' |
| 33 |
], |
| 34 |
// FireBox Import Page |
| 35 |
[ |
| 36 |
'option_group' => 'firebox_import', |
| 37 |
'option_name' => 'firebox_import', |
| 38 |
'controller' => '\FireBox\Core\Controllers\BoxImport', |
| 39 |
'process_data_method' => 'processBoxesImport' |
| 40 |
], |
| 41 |
// FireBox Submission Edit Page |
| 42 |
[ |
| 43 |
'option_group' => 'firebox_submission', |
| 44 |
'option_name' => 'firebox_submission', |
| 45 |
'controller' => '\FireBox\Core\Controllers\Submissions', |
| 46 |
'process_data_method' => 'processSubmissionEdit' |
| 47 |
], |
| 48 |
]; |
| 49 |
|
| 50 |
public function __construct() |
| 51 |
{ |
| 52 |
add_action('admin_init', [$this, 'registerSettings']); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Registers FireBox Settings and FireBox Import Settings sections |
| 57 |
* in order to be able to submit the forms. |
| 58 |
* |
| 59 |
* @return void |
| 60 |
*/ |
| 61 |
public function registerSettings() |
| 62 |
{ |
| 63 |
foreach (self::registerSettingsData as $key => $setting) |
| 64 |
{ |
| 65 |
if (!class_exists($setting['controller'])) |
| 66 |
{ |
| 67 |
continue; |
| 68 |
} |
| 69 |
|
| 70 |
$controller = new $setting['controller'](); |
| 71 |
|
| 72 |
register_setting($setting['option_group'], $setting['option_name'], [$controller, $setting['process_data_method']]); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
} |