Update from Git Manager GUI
This commit is contained in:
234
admin/forum-settings.php
Normal file
234
admin/forum-settings.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
/**
|
||||
* forum-settings.php
|
||||
* Admin-Einstellungsseite für WP Business Forum.
|
||||
* Wird von wp-business-forum.php per require_once eingebunden.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
// ── Hilfsfunktion ─────────────────────────────────────────────────────────────
|
||||
// Gibt alle Forum-Einstellungen zurück (mit Fallback auf Standardwerte).
|
||||
// Verwendung überall im Plugin: wbf_get_settings()['hero_title']
|
||||
|
||||
if ( ! function_exists('wbf_get_settings') ) {
|
||||
function wbf_get_settings() {
|
||||
$defaults = [
|
||||
// Hero-Bereich
|
||||
'hero_title' => 'Community Forum',
|
||||
'hero_subtitle' => 'Diskutiere, teile Ideen und bleib immer informiert.',
|
||||
// Topbar
|
||||
'topbar_brand' => 'Community',
|
||||
// Statistik-Labels
|
||||
'stat_threads' => 'Threads',
|
||||
'stat_posts' => 'Beiträge',
|
||||
'stat_members' => 'Mitglieder',
|
||||
// Abschnitt-Überschriften
|
||||
'section_cats' => 'Kategorien',
|
||||
'section_recent' => 'Neue Threads',
|
||||
// Buttons
|
||||
'btn_new_thread' => 'Neuer Thread',
|
||||
'btn_login' => 'Einloggen',
|
||||
'btn_register' => 'Registrieren',
|
||||
'btn_logout' => 'Logout',
|
||||
// Sidebar
|
||||
'sidebar_profile' => 'Mein Profil',
|
||||
'sidebar_login' => 'Login / Registrieren',
|
||||
// Sicherheit
|
||||
'auto_logout_minutes' => '30',
|
||||
];
|
||||
|
||||
$saved = get_option( 'wbf_settings', [] );
|
||||
|
||||
// Fehlende Keys mit Defaults auffüllen, leere Strings ignorieren
|
||||
return array_merge( $defaults, array_filter( (array) $saved, 'strlen' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// ── Admin-Seite ───────────────────────────────────────────────────────────────
|
||||
|
||||
if ( ! function_exists('wbf_admin_settings') ) {
|
||||
function wbf_admin_settings() {
|
||||
|
||||
// Speichern
|
||||
if ( isset( $_POST['wbf_save_settings'] ) && check_admin_referer( 'wbf_settings_nonce' ) ) {
|
||||
|
||||
$fields = [
|
||||
'hero_title', 'hero_subtitle',
|
||||
'topbar_brand',
|
||||
'stat_threads', 'stat_posts', 'stat_members',
|
||||
'section_cats', 'section_recent',
|
||||
'btn_new_thread', 'btn_login', 'btn_register', 'btn_logout',
|
||||
'sidebar_profile', 'sidebar_login',
|
||||
'auto_logout_minutes',
|
||||
];
|
||||
|
||||
$settings = [];
|
||||
foreach ( $fields as $key ) {
|
||||
$settings[ $key ] = sanitize_text_field( $_POST[ $key ] ?? '' );
|
||||
}
|
||||
|
||||
update_option( 'wbf_settings', $settings );
|
||||
echo '<div class="notice notice-success is-dismissible"><p>✅ Einstellungen gespeichert!</p></div>';
|
||||
}
|
||||
|
||||
$s = wbf_get_settings();
|
||||
|
||||
// Inline-Hilfsfunktion für eine Tabellenzeile
|
||||
$row = function( $label, $name, $placeholder, $desc = '' ) use ( $s ) {
|
||||
$val = esc_attr( $s[ $name ] ?? '' );
|
||||
echo "
|
||||
<tr>
|
||||
<th scope='row'><label for='wbf_{$name}'>{$label}</label></th>
|
||||
<td>
|
||||
<input type='text'
|
||||
id='wbf_{$name}'
|
||||
name='{$name}'
|
||||
value='{$val}'
|
||||
placeholder='" . esc_attr( $placeholder ) . "'
|
||||
class='regular-text'>
|
||||
" . ( $desc ? "<p class='description'>{$desc}</p>" : '' ) . "
|
||||
</td>
|
||||
</tr>";
|
||||
};
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>⚙️ Forum-Einstellungen</h1>
|
||||
<p style="color:#666;margin-bottom:1.5rem">
|
||||
Alle sichtbaren Texte des Forums — kein Code nötig.
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<?php wp_nonce_field( 'wbf_settings_nonce' ); ?>
|
||||
|
||||
<!-- ── Hero-Bereich ───────────────────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
🏠 Hero-Bereich (Startseite)
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<?php $row(
|
||||
'Titel', 'hero_title', 'Community Forum',
|
||||
'Der große Titel im Banner oben auf der Startseite.'
|
||||
); ?>
|
||||
<?php $row(
|
||||
'Untertitel', 'hero_subtitle',
|
||||
'Diskutiere, teile Ideen und bleib immer informiert.',
|
||||
'Der kleine Text direkt unter dem Titel.'
|
||||
); ?>
|
||||
</table>
|
||||
|
||||
<!-- ── Topbar ─────────────────────────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
🔝 Topbar (Navigationsleiste)
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<?php $row(
|
||||
'Forum-Name / Brand', 'topbar_brand', 'Community',
|
||||
'Angezeigt als Markenname links in der Navigationsleiste.'
|
||||
); ?>
|
||||
<?php $row( 'Button „Einloggen"', 'btn_login', 'Einloggen' ); ?>
|
||||
<?php $row( 'Button „Registrieren"', 'btn_register', 'Registrieren' ); ?>
|
||||
<?php $row( 'Button „Logout"', 'btn_logout', 'Logout' ); ?>
|
||||
</table>
|
||||
|
||||
<!-- ── Statistik-Labels ───────────────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
📊 Statistik-Labels
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<?php $row( 'Label „Threads"', 'stat_threads', 'Threads' ); ?>
|
||||
<?php $row( 'Label „Beiträge"', 'stat_posts', 'Beiträge' ); ?>
|
||||
<?php $row( 'Label „Mitglieder"', 'stat_members', 'Mitglieder' ); ?>
|
||||
</table>
|
||||
|
||||
<!-- ── Abschnitt-Überschriften ───────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
📂 Abschnitt-Überschriften
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<?php $row( 'Kategorien-Überschrift', 'section_cats', 'Kategorien' ); ?>
|
||||
<?php $row( 'Neue Threads (Sidebar)', 'section_recent', 'Neue Threads' ); ?>
|
||||
<?php $row( 'Button „Neuer Thread"', 'btn_new_thread', 'Neuer Thread' ); ?>
|
||||
</table>
|
||||
|
||||
<!-- ── Sidebar ────────────────────────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
👤 Sidebar
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<?php $row(
|
||||
'Sidebar-Titel (eingeloggt)', 'sidebar_profile', 'Mein Profil'
|
||||
); ?>
|
||||
<?php $row(
|
||||
'Sidebar-Titel (ausgeloggt)', 'sidebar_login', 'Login / Registrieren'
|
||||
); ?>
|
||||
</table>
|
||||
|
||||
<!-- ── Sicherheit ─────────────────────────────────── -->
|
||||
<h2 style="border-bottom:1px solid #ddd;padding-bottom:.4rem;margin-top:1.5rem">
|
||||
🔒 Sicherheit
|
||||
</h2>
|
||||
<table class="form-table" role="presentation">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="wbf_auto_logout_minutes">Auto-Logout nach Inaktivität</label>
|
||||
</th>
|
||||
<td>
|
||||
<select id="wbf_auto_logout_minutes" name="auto_logout_minutes">
|
||||
<?php
|
||||
$current_val = $s['auto_logout_minutes'] ?? '30';
|
||||
$options = [
|
||||
'0' => 'Deaktiviert',
|
||||
'5' => '5 Minuten',
|
||||
'10' => '10 Minuten',
|
||||
'15' => '15 Minuten',
|
||||
'30' => '30 Minuten',
|
||||
'60' => '1 Stunde',
|
||||
'120' => '2 Stunden',
|
||||
'480' => '8 Stunden',
|
||||
];
|
||||
foreach ( $options as $val => $label ):
|
||||
?>
|
||||
<option value="<?php echo esc_attr($val); ?>"<?php selected($current_val, (string)$val); ?>>
|
||||
<?php echo esc_html($label); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p class="description">
|
||||
Nach dieser Zeit ohne Aktivität wird der Nutzer automatisch ausgeloggt und erhält eine Warnung
|
||||
(30 Sek. vor dem Logout). Gilt nur für Forum-Benutzer, nicht für WordPress-Admins.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php submit_button(
|
||||
'💾 Einstellungen speichern',
|
||||
'primary',
|
||||
'wbf_save_settings',
|
||||
true,
|
||||
[ 'style' => 'margin-top:1rem' ]
|
||||
); ?>
|
||||
</form>
|
||||
|
||||
<!-- ── Vorschau-Tabelle ──────────────────────────────── -->
|
||||
<hr style="margin-top:2.5rem">
|
||||
<h3>📋 Aktuelle Werte</h3>
|
||||
<table class="widefat striped" style="max-width:700px">
|
||||
<thead>
|
||||
<tr><th>Schlüssel</th><th>Aktueller Wert</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $s as $key => $val ): ?>
|
||||
<tr>
|
||||
<td><code><?php echo esc_html( $key ); ?></code></td>
|
||||
<td><?php echo esc_html( $val ); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} // end function_exists wbf_admin_settings
|
||||
Reference in New Issue
Block a user