148 lines
4.8 KiB
PHP
148 lines
4.8 KiB
PHP
<?php
|
|
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
add_action('pausera_render_ui', function () {
|
|
$settings = get_option('pausera_settings', []);
|
|
$enabled = !empty($settings['enable_maintenance']);
|
|
$excluded_ips = isset($settings['excluded_ips']) ? implode(',', $settings['excluded_ips']) : '';
|
|
$redirect_url = $settings['redirect_url'] ?? '/maintenance';
|
|
$excluded_roles = $settings['excluded_roles'] ?? [];
|
|
$allowed_users = $settings['allowed_users'] ?? [];
|
|
$plugin_data = get_plugin_data(PAUSERA_PATH . 'pausera.php');
|
|
|
|
global $wp_roles;
|
|
$all_users = get_users(['fields' => ['user_login']]);
|
|
$usernames = array_map(function ($u) {
|
|
return $u->user_login;
|
|
}, $all_users);
|
|
?>
|
|
|
|
<div class="pausera-status-bar">
|
|
Aktueller Status: <?php echo $enabled ? 'Wartungsmodus AKTIV' : 'Deaktiviert'; ?>
|
|
</div>
|
|
|
|
<div class="pausera-header">
|
|
<div class="pausera-title">Pausera</div>
|
|
</div>
|
|
|
|
<?php if (isset($_GET['settings-updated']) && $_GET['settings-updated'] === 'true') : ?>
|
|
<div class="pausera-notice success">
|
|
<?php echo esc_html(__('Settings saved successfully.', 'pausera')); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="pausera-wrap">
|
|
<div class="formular">
|
|
<form method="post" action="options.php" id="pausera-form">
|
|
<?php settings_fields('pausera_group'); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="pausera-card toggle-box <?php echo $enabled ? 'active' : ''; ?>" id="maintenance-toggle">
|
|
<input type="checkbox" id="maintenance_toggle_input" name="pausera_settings[enable_maintenance]" value="1" <?php checked($enabled); ?> />
|
|
<label for="maintenance_toggle_input">
|
|
<strong class="pausera-toggle-label" data-label-on="Deaktivieren" data-label-off="Aktivieren">
|
|
<?php echo $enabled ? 'Deaktivieren' : 'Aktivieren'; ?>
|
|
</strong>
|
|
</label>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="pausera-card">
|
|
<h3>Weiterleitungsseite</h3>
|
|
<label>Seite auswählen</label>
|
|
<select name="pausera_settings[redirect_url]" class="acf-style-select">
|
|
<?php foreach (get_pages() as $page) :
|
|
$slug = '/' . basename(get_permalink($page->ID));
|
|
$selected = selected($redirect_url, $slug, false);
|
|
echo "<option value='{$slug}' {$selected}>{$page->post_title}</option>";
|
|
endforeach; ?>
|
|
</select>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="pausera-card">
|
|
<h3>Erlaubte Benutzer</h3>
|
|
<label>Mehrere Benutzernamen mit Komma trennen</label>
|
|
<select name="pausera_settings[allowed_users][]" multiple class="acf-style-select">
|
|
<?php foreach ($usernames as $username) :
|
|
$selected = in_array($username, $allowed_users) ? 'selected' : '';
|
|
echo "<option value='{$username}' {$selected}>{$username}</option>";
|
|
endforeach; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="pausera-card">
|
|
<h3>Benutzerrollen</h3>
|
|
<label>Mehrfachauswahl möglich</label>
|
|
<select name="pausera_settings[excluded_roles][]" multiple class="acf-style-select">
|
|
<?php foreach ($wp_roles->roles as $key => $role) :
|
|
$selected = in_array($key, $excluded_roles) ? 'selected' : '';
|
|
echo "<option value='{$key}' {$selected}>{$role['name']}</option>";
|
|
endforeach; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="pausera-card">
|
|
<h3>Ausgeschlossene IP-Adressen</h3>
|
|
<label>Mehrere IPs mit Komma trennen</label>
|
|
<input type="text" name="pausera_settings[excluded_ips]" value="<?php echo esc_attr($excluded_ips); ?>" placeholder="127.0.0.1, 88.99.99.99">
|
|
</div>
|
|
|
|
<div class="pausera-buttons">
|
|
<button type="submit" class="pausera-save">Speichern</button>
|
|
</div>
|
|
|
|
|
|
<div class="pausera-confirm-overlay" id="pausera-confirm-box">
|
|
<div class="pausera-confirm-dialog">
|
|
<h3>Einstellungen speichern?</h3>
|
|
<p>Bitte bestätigen Sie, dass Sie die Änderungen speichern möchten.</p>
|
|
<div class="pausera-buttons">
|
|
<button type="button" id="confirm-save" class="pausera-save">Ja, speichern</button>
|
|
<button type="button" id="cancel-save" class="pausera-reset">Abbrechen</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</form>
|
|
</div>
|
|
|
|
<div class="pausera-sidebar">
|
|
<h4>Plugin-Informationen</h4>
|
|
<ul>
|
|
<li><strong>Version:</strong> <?php echo esc_html($plugin_data['Version']); ?></li>
|
|
<li><strong>Autor:</strong> Ihr Name</li>
|
|
<li><strong>Website:</strong> <a href="https://example.com" target="_blank">example.com</a></li>
|
|
</ul>
|
|
|
|
<h4>Plugin-Links</h4>
|
|
<ul>
|
|
<li><a href="https://example.com/docs" target="_blank">📄 Dokumentation</a></li>
|
|
<li><a href="mailto:support@example.com">Kontaktieren Sie uns</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php });
|