kompass/modules/KompassSettings/Controllers/SettingsPage.php

160 lines
5.3 KiB
PHP
Raw Normal View History

2024-03-16 14:21:57 +01:00
<?php
namespace Bdp\Modules\KompassSettings\Controllers;
class SettingsPage
{
2024-07-31 17:53:07 +02:00
public static function add_menu() {
2024-08-12 15:11:25 +02:00
if (
null !== get_option('bdp_calendar_source_url', null ) ||
!file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php')
)
{
add_menu_page(
'Kalender Installation',
'Kalender Installation',
'manage_options',
'kompass-calendar',
['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_calendar'],
'dashicons-calendar-alt',
2
);
if ( file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../kronos/kronos.php') ) {
add_action( 'admin_notices', array( 'Bdp\Modules\PluginInstaller\Controllers\OutdatedModule', 'calender' ) );
}
}
if (
!file_exists(dirname(BDP_LV_STARTUP_FILE ) . '/../solea/solea.php')
)
{
add_menu_page(
'Installiere solea (Veranstaltungen)',
'Installiere solea (Veranstaltungen)',
'manage_options',
'kompass-events',
['Bdp\Modules\PluginInstaller\Controllers\InstallSingleplugin', 'install_events'],
'dashicons-tickets-alt',
2
);
}
2024-07-31 17:53:07 +02:00
add_submenu_page('options-general.php',
'kompass Einstellungen',
'kompass Einstellungen',
'manage_options',
'kompass-settings',
['Bdp\Modules\KompassSettings\Controllers\SettingsPage', 'kompass_settings_page_new']
);
2024-07-31 21:20:57 +02:00
add_submenu_page('options-general.php',
'Mail',
'Mail',
'manage_options',
'kompass-mail-settings',
['Bdp\Modules\Mail\Controllers\MailSettingsController', 'settings_form']
);
2024-07-31 17:53:07 +02:00
}
2024-03-16 14:21:57 +01:00
public function __construct()
{
2024-03-16 16:58:00 +01:00
add_options_page(
__('kompass', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
2024-03-16 14:21:57 +01:00
__('kompass', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
'manage_options',
BDP_LV_PLUGIN_SLUG . '-Kompass-settings',
[$this, 'option_page'],2048);
2024-07-31 17:53:07 +02:00
}
public static function kompass_settings_page_new() {
if (isset($_POST['save'])) {
update_option('paged_used_for_state', false);
update_option('user_can_register', false);
update_option('use_mareike_theme', false);
if (isset($_POST['used_for_state'])) { update_option('paged_used_for_state', true); }
if (isset($_POST['self_register'])) { update_option('user_can_register', true); }
if (isset($_POST['use_mareike_theme'])) { update_option('use_mareike_theme', true); }
kompass_print_message_box('Die Einstellungen wurden gespeichert.');
}
require BDP_LV_PLUGIN_DIR . '/settings/views/settings.php';
return;
2024-03-16 14:21:57 +01:00
}
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) {
2024-07-31 17:53:07 +02:00
case 'tab2':
2024-08-12 15:11:25 +02:00
kompass_print_message_box('Diese Funktion wird nicht mdehr unterstützt.', 'error');
break;
2024-03-16 14:21:57 +01:00
2024-07-31 17:53:07 +02:00
case 'tab3':
2024-03-16 14:21:57 +01:00
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) {
2024-07-31 17:53:07 +02:00
case 'tab2':
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings&tab=tab2" method="post">';
2024-03-16 16:58:00 +01:00
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-calendar-settings');
require_once BDP_LV_PLUGIN_DIR . '/modules/calendar/Views/categories-partial.php';
2024-07-31 17:53:07 +02:00
echo '<input type="hidden" name="tab" value="tab2" />';
2024-03-16 16:58:00 +01:00
submit_button();
2024-03-16 14:21:57 +01:00
echo '</form>';
break;
2024-07-31 17:53:07 +02:00
case 'tab3':
2024-03-16 14:21:57 +01:00
echo '<form action="admin.php?page=bdp-kompass-Kompass-settings" method="post">';
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-seo-settings');
submit_button();
2024-07-31 17:53:07 +02:00
echo '<input type="hidden" name="tab" value="tab3" />';
2024-03-16 14:21:57 +01:00
echo '</form>';
break;
}
?>
</div>
</div>
<?php
}
}