| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 1.0.13 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2022 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Admin\Includes\Metaboxes; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
use FireBox\Core\Admin\Forms\FireBox as FireBoxForm; |
| 20 |
use FPFramework\Base\Ui\Tabs; |
| 21 |
use FPFramework\Base\FieldsParser; |
| 22 |
|
| 23 |
class FireBox |
| 24 |
{ |
| 25 |
/** |
| 26 |
* The slug |
| 27 |
* |
| 28 |
* @var String |
| 29 |
*/ |
| 30 |
public $slug = 'firebox_settings'; |
| 31 |
|
| 32 |
/** |
| 33 |
* The title |
| 34 |
* |
| 35 |
* @var String |
| 36 |
*/ |
| 37 |
public $title; |
| 38 |
|
| 39 |
/** |
| 40 |
* The callback |
| 41 |
* |
| 42 |
* @var String |
| 43 |
*/ |
| 44 |
public $callback = 'render_settings_meta_box'; |
| 45 |
|
| 46 |
/** |
| 47 |
* The screen |
| 48 |
* |
| 49 |
* @var String |
| 50 |
*/ |
| 51 |
public $screen = 'firebox'; |
| 52 |
|
| 53 |
/** |
| 54 |
* The context |
| 55 |
* |
| 56 |
* @var String |
| 57 |
*/ |
| 58 |
public $context = 'advanced'; |
| 59 |
|
| 60 |
/** |
| 61 |
* The priority |
| 62 |
* |
| 63 |
* @var String |
| 64 |
*/ |
| 65 |
public $priority = 'high'; |
| 66 |
|
| 67 |
public function __construct() |
| 68 |
{ |
| 69 |
$this->title = firebox()->_('FB_SETTINGS_PAGE_TITLE'); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* FireBox Metabox Settings. |
| 74 |
* Used by MetaboxManager to retrieve the settings and validate during form saving process. |
| 75 |
* |
| 76 |
* @return array |
| 77 |
*/ |
| 78 |
public function getSettings() |
| 79 |
{ |
| 80 |
return FireBoxForm::getSettings(); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Render the meta box |
| 85 |
* |
| 86 |
* @return void |
| 87 |
*/ |
| 88 |
public function render_settings_meta_box() |
| 89 |
{ |
| 90 |
$fieldsParser = new FieldsParser([ |
| 91 |
'bind_data' => FireBoxForm::getBindData(), |
| 92 |
'fields_path' => apply_filters('firebox/metabox/firebox/fields_path_modify', ['\\FireBox\\Core\\Fields\\']), |
| 93 |
'fields_name_prefix' => \FPFramework\Admin\Includes\MetaboxManager::$fields_prefix |
| 94 |
]); |
| 95 |
|
| 96 |
$settings = $this->getSettings(); |
| 97 |
foreach ($settings['data'] as $key => $value) |
| 98 |
{ |
| 99 |
ob_start(); |
| 100 |
$fieldsParser->renderContentFields($value); |
| 101 |
$html = ob_get_contents(); |
| 102 |
ob_end_clean(); |
| 103 |
|
| 104 |
$settings['data'][$key]['title'] = $value['title']; |
| 105 |
$settings['data'][$key]['content'] = $html; |
| 106 |
} |
| 107 |
|
| 108 |
// render settings as tabs |
| 109 |
$tabs = new Tabs($settings); |
| 110 |
|
| 111 |
ob_start(); |
| 112 |
$tabs->render(); |
| 113 |
$metaboxes_html = ob_get_contents(); |
| 114 |
ob_end_clean(); |
| 115 |
|
| 116 |
fpframework()->renderer->admin->render('metaboxes', ['content' => $metaboxes_html]); |
| 117 |
} |
| 118 |
} |