Professional WP Theme Builder
Browser View: http://localhost/wordpress-preview/
`;const blob = new Blob([combinedCode], {type: 'text/html'});
previewFrame.src = URL.createObjectURL(blob);
}// Listener for real-time updates
Object.values(editors).forEach(editor => {
editor.addEventListener('input', () => {
clearTimeout(window.updateTimer);
window.updateTimer = setTimeout(updatePreview, 500);
});
});// Theme Export Functionality
async function downloadWPTheme() {
const zip = new JSZip();
const themeName = "my-custom-theme";
const folder = zip.folder(themeName);// 1. Mandatory style.css with WP Header
const fullCSS = `/*\nTheme Name: Studio Custom Theme\nAuthor: WP Studio\nVersion: 1.0\nDescription: Generated via Code Runner\n*/\n\n${editors.css.value}`;
folder.file("style.css", fullCSS);// 2. index.php
folder.file("index.php", editors.html.value);// 3. functions.php
folder.file("functions.php", editors.php.value);// 4. script.js
folder.file("script.js", editors.js.value);// Generate and trigger download
const blob = await zip.generateAsync({type: "blob"});
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = `${themeName}.zip`;
link.click();
}// Run preview on load
updatePreview();