buildHeader($componentId); $html .= '
'; // Columna izquierda - CSS $html .= '
'; $html .= $this->buildCssGroup($componentId); $html .= '
'; // Columna derecha - JavaScript $html .= '
'; $html .= $this->buildJsGroup($componentId); $html .= '
'; $html .= '
'; return $html; } private function buildHeader(string $componentId): string { $html = '
renderer->getFieldValue($componentId, 'custom_code', 'custom_css', ''); $html .= $this->buildTextareaCode( 'themeSettingsCustomCss', 'Estilos CSS', $customCss, 'Se inyecta en wp_head. No incluir etiquetas <style>', 10 ); $html .= '
'; $html .= ' '; $html .= ' El CSS se carga despues de los estilos del tema.'; $html .= '
'; $html .= '
'; $html .= ''; return $html; } private function buildJsGroup(string $componentId): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' JavaScript Personalizado'; $html .= '
'; $customJsHeader = $this->renderer->getFieldValue($componentId, 'custom_code', 'custom_js_header', ''); $html .= $this->buildTextareaCode( 'themeSettingsCustomJsHeader', 'JavaScript en Header', $customJsHeader, 'Se inyecta en wp_head. No incluir etiquetas <script>', 5 ); $customJsFooter = $this->renderer->getFieldValue($componentId, 'custom_code', 'custom_js_footer', ''); $html .= $this->buildTextareaCode( 'themeSettingsCustomJsFooter', 'JavaScript en Footer', $customJsFooter, 'Se inyecta en wp_footer. No incluir etiquetas <script>', 5 ); $html .= '
'; $html .= ' '; $html .= ' Advertencia: El codigo JS puede afectar el rendimiento y seguridad del sitio.'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildTextareaCode(string $id, string $label, mixed $value, string $helpText = '', int $rows = 4): string { $value = $this->normalizeStringValue($value); $html = '
'; $html .= ' '; $html .= ' '; if (!empty($helpText)) { $html .= '
' . $helpText . '
'; } $html .= '
'; return $html; } /** * Normaliza un valor a string para inputs de formulario */ private function normalizeStringValue(mixed $value): string { if ($value === false) { return '0'; } if ($value === true) { return '1'; } return (string) $value; } }