fix: Container width setting now applies correctly + Rail Ads improvements

- Fix container width not applying: css-global-responsive.css now uses
  CSS variable --roi-container-width instead of hardcoded values
- Add 8 Rail format options: slim-small (160x300), slim-medium (160x400),
  slim-large (160x500), skyscraper (160x600), slim-xlarge (160x700),
  wide-skyscraper (160x800), half-page (300x600), large-skyscraper (300x1050)
- Change rail_top_offset from text input to select with preset values
- Fix Rail Ads JavaScript positioning (moved after HTML, added retries)
- ThemeSettingsRenderer now always outputs CSS variables for layout

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-11-27 21:30:06 -06:00
parent 122bcd4750
commit 72ef7580fc
5 changed files with 195 additions and 134 deletions

View File

@@ -86,30 +86,37 @@ final class ThemeSettingsRenderer implements RendererInterface
* Genera CSS para el layout configurable
*
* @param array $data Datos del componente
* @return string Bloque style o vacio si usa defaults
* @return string Bloque style con variables CSS y overrides
*/
private function renderLayoutCSS(array $data): string
{
$containerWidth = $data['layout']['container_max_width'] ?? '1320';
// Si es el valor default, no generar CSS extra
if ($containerWidth === '1320') {
return '';
}
// Validar que el valor sea seguro
$allowedWidths = ['1140', '1200', '1320', '1400', '100%'];
if (!in_array($containerWidth, $allowedWidths, true)) {
return '';
$containerWidth = '1320'; // Fallback al default
}
// Generar el CSS
$widthValue = ($containerWidth === '100%') ? '100%' : $containerWidth . 'px';
$widthNumeric = ($containerWidth === '100%') ? '100vw' : $containerWidth . 'px';
return sprintf(
// Siempre generar CSS variable para que otros componentes puedan usarla
$css = sprintf(
'<!-- Layout CSS (ROI Theme) -->
<style id="roi-theme-layout-css">
/* Container width override */
:root {
--roi-container-width: %s;
--roi-container-width-numeric: %s;
}',
esc_attr($widthValue),
esc_attr($widthNumeric)
);
// Solo añadir override de container si NO es el default
if ($containerWidth !== '1320') {
$css .= sprintf('
@media (min-width: 1200px) {
.container,
.container-lg,
@@ -117,10 +124,15 @@ final class ThemeSettingsRenderer implements RendererInterface
.container-xxl {
max-width: %s;
}
}
</style>',
esc_attr($widthValue)
);
}',
esc_attr($widthValue)
);
}
$css .= '
</style>';
return $css;
}
/**