Minecraft-Modern-Theme/inc/customizer.php aktualisiert

This commit is contained in:
2026-01-06 23:18:59 +00:00
parent ae4ec1dc30
commit 57e758353a

View File

@@ -68,7 +68,7 @@ function minecraft_modern_customize_register( $wp_customize ) {
'label' => 'Schriftfarbe', 'section' => 'header_slider', 'settings' => 'slider_font_color',
) ) );
// === VERGESSENE EINSTELLUNG WIEDER HINZUGEFÜGT ===
// Header-Höhe
$wp_customize->add_setting( 'header_height', array( 'default' => 'mittel', 'sanitize_callback' => 'sanitize_text_field' ) );
$wp_customize->add_control( 'header_height', array(
'label' => 'Header-Höhe', 'section' => 'header_slider', 'settings' => 'header_height', 'type' => 'select',
@@ -84,10 +84,6 @@ function minecraft_modern_customize_register( $wp_customize ) {
'label' => 'Paginierung (Punkte) ausblenden', 'section' => 'header_slider', 'settings' => 'slider_hide_pagination', 'type' => 'checkbox',
) );
// =========================================================================
// === ENTFERNT: Slider-Effekt-Einstellungen ==============================
// =========================================================================
// --- Sektion: Startseiten-Hero (Fallback) ---
$wp_customize->add_section( 'hero_section', array(
'title' => 'Startseiten-Hero (wenn Slider deaktiviert)',
@@ -113,7 +109,7 @@ function minecraft_modern_customize_register( $wp_customize ) {
// --- Checkbox: Seitentitel auf Startseite verstecken ---
$wp_customize->add_setting( 'show_home_title', array(
'default' => false, // Standard: Aus (Titel wird versteckt)
'default' => false,
'sanitize_callback' => 'wp_validate_boolean',
) );
$wp_customize->add_control( 'show_home_title', array(
@@ -276,6 +272,121 @@ function minecraft_modern_customize_register( $wp_customize ) {
'type' => 'number',
'input_attrs' => array( 'min' => 2, 'max' => 10, 'step' => 1 ),
) );
// =========================================================================
// === 7. EXPORT / IMPORT SECTION =========================================
// =========================================================================
$wp_customize->add_section( 'theme_mods_import_export', array(
'title' => __( 'Einstellungen sichern', 'minecraft-modern-theme' ),
'priority' => 999,
'description' => '',
) );
// Füge ein Custom Control mit HTML hinzu
$wp_customize->add_setting( 'import_export_placeholder', array(
'sanitize_callback' => 'sanitize_text_field',
) );
// Custom Control Class für Export/Import
class Import_Export_Control extends WP_Customize_Control {
public $type = 'import_export';
public function render_content() {
$export_url = admin_url('admin-post.php?action=export_theme_settings');
$nonce = wp_create_nonce('theme-import-nonce');
?>
<div class="import-export-wrapper" style="margin-top: 15px;">
<p class="description" style="margin-bottom: 20px;">
<strong>Hinweis:</strong> Hier kannst du alle deine Theme-Einstellungen sichern und wiederherstellen.
</p>
<a href="<?php echo esc_url($export_url); ?>" class="button button-primary button-hero" id="export-settings-btn" style="display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px;">
<span class="dashicons dashicons-download" style="margin-top:3px;"></span> Einstellungen Exportieren
</a>
<div style="border-top: 2px solid #ddd; padding-top: 20px; margin-top: 20px;">
<label style="display:block; margin-bottom:10px; font-weight:bold;">
Backup wiederherstellen:
</label>
<input type="file" id="import-settings-file" accept=".json" style="width:100%; margin-bottom:10px;">
<button type="button" class="button button-secondary" id="import-settings-btn" disabled style="display: inline-flex; align-items: center; gap: 8px;">
<span class="dashicons dashicons-upload" style="margin-top:3px;"></span> Einstellungen Importieren
</button>
</div>
<p class="description" style="margin-top:15px; padding: 10px; background: #fff3cd; border-left: 4px solid #ffc107;">
<strong>⚠️ Warnung:</strong> Beim Import werden alle aktuellen Einstellungen überschrieben!
</p>
</div>
<script type="text/javascript">
(function($) {
var ajaxUrl = '<?php echo admin_url('admin-ajax.php'); ?>';
var nonce = '<?php echo $nonce; ?>';
$('#import-settings-file').on('change', function() {
$('#import-settings-btn').prop('disabled', $(this).val() === '');
});
$('#import-settings-btn').on('click', function() {
var fileInput = $('#import-settings-file')[0];
if (fileInput.files.length === 0) {
alert('Bitte wähle eine JSON-Datei aus.');
return;
}
if (!confirm('WARNUNG: Alle aktuellen Einstellungen werden überschrieben. Bist du sicher?')) {
return;
}
var formData = new FormData();
formData.append('import_file', fileInput.files[0]);
formData.append('action', 'import_theme_settings');
formData.append('nonce', nonce);
var $btn = $(this);
var originalText = $btn.html();
$btn.prop('disabled', true).html('<span class="dashicons dashicons-update" style="margin-top:3px; animation: rotation 1s infinite linear;"></span> Importiere...');
$.ajax({
url: ajaxUrl,
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(response) {
if (response.success) {
alert('✅ ' + response.data);
location.reload();
} else {
alert('❌ Fehler: ' + response.data);
$btn.prop('disabled', false).html(originalText);
}
},
error: function() {
alert('❌ Ein technischer Fehler ist aufgetreten.');
$btn.prop('disabled', false).html(originalText);
}
});
});
})(jQuery);
</script>
<style>
@keyframes rotation {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
</style>
<?php
}
}
$wp_customize->add_control( new Import_Export_Control( $wp_customize, 'import_export_placeholder', array(
'section' => 'theme_mods_import_export',
) ) );
}
add_action( 'customize_register', 'minecraft_modern_customize_register' );
@@ -289,7 +400,7 @@ function minecraft_modern_dynamic_css_output() {
$slider_font = get_theme_mod( 'slider_font_family', 'Raleway' );
$slider_color = get_theme_mod( 'slider_font_color', '#ffffff' );
$slider_size_setting = get_theme_mod( 'slider_font_size', 'mittel' );
$header_height_setting = get_theme_mod( 'header_height', 'mittel' ); // Diese Einstellung wird hier verwendet!
$header_height_setting = get_theme_mod( 'header_height', 'mittel' );
// Header-Höhe umwandeln
$header_height_value = '300px';
@@ -329,10 +440,6 @@ function minecraft_modern_dynamic_css_output() {
font-size: <?php echo esc_attr($chosen_sizes['subtitle']); ?>;
}
/* =================================================================== */
/* === NEU: Trennlinien mit der Akzentfarbe ========================= */
/* =================================================================== */
/* Trennlinie unter dem Header */
.site-header {
border-bottom: 4px solid var(--primary-accent);
@@ -347,7 +454,6 @@ function minecraft_modern_dynamic_css_output() {
.site-footer {
border-top: 4px solid var(--primary-accent);
}
</style>
<?php
}