kompass/modules/KompassSettings/Controllers/SettingsPage.php

74 lines
2.6 KiB
PHP
Raw Normal View History

2024-03-16 14:21:57 +01:00
<?php
namespace Bdp\Modules\KompassSettings\Controllers;
class SettingsPage
{
public function __construct()
{
add_options_page(BDP_LV_PLUGIN_SLUG . '-kompass',
__('kompass', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
'manage_options',
BDP_LV_PLUGIN_SLUG . '-Kompass-settings',
[$this, 'option_page'],2048);
}
public function option_page() {
bdp_kompass_load_plugin_textdomain();
$showMessage = null;
$tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : 'tab1';
if (isset($_REQUEST['update_options']) && $_REQUEST['update_options'] == true) {
switch ($tab) {
case 'tab1':
break;
case 'tab2':
update_option('kompass_seo_google_verification', $_POST['kompass_seo_google_verification']);
update_option('kompass_seo_bing_verification', $_POST['kompass_seo_bing_verification']);
$showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG);
break;
}
if (null !== $showMessage) {
echo '<div class="notice notice-success" style="padding: 5px 10px;">';
echo $showMessage;
echo '</div>';
}
}
bdp_kompass_load_plugin_textdomain();
?>
<div class="wrap">
<h1 class="wp-heading-inline">
<?= __('kompass', BDP_LV_PLUGIN_SLUG); ?> - <?= __('Settings', BDP_LV_PLUGIN_SLUG); ?></h1>
<hr class="wp-header-end">
<?= kompass_settings_print_tab_header($tab); ?>
<div class="tab-content">
<?php
switch ($tab) {
case 'tab1':
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings&tab=tab1" method="post">';
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-seo-settings');
submit_button();
echo '<input type="hidden" name="tab" value="tab4" />';
echo '</form>';
break;
case 'tab2':
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings" method="post">';
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-seo-settings');
submit_button();
echo '<input type="hidden" name="tab" value="tab2" />';
echo '</form>';
break;
}
?>
</div>
</div>
<?php
}
}