feat(custom-css-manager): implementar TIPO 3 - CSS Crítico Personalizado
Nuevo sistema de gestión de CSS personalizado con panel admin: - Admin/CustomCSSManager: CRUD de snippets CSS (crítico/diferido) - Public/CustomCSSManager: Inyección dinámica en frontend - Schema JSON para configuración del componente Migración de CSS estático a BD: - Tablas APU (~14KB) → snippet diferido en BD - Tablas Genéricas (~10KB) → snippet diferido en BD - Comentadas funciones legacy en enqueue-scripts.php Limpieza de archivos obsoletos: - Eliminado build-bootstrap-subset.js - Eliminado migrate-legacy-options.php - Eliminado minify-css.php - Eliminado purgecss.config.js Beneficios: - CSS editable desde admin sin tocar código - Soporte crítico (head) y diferido (footer) - Filtrado por scope (all/home/single/archive) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -351,15 +351,20 @@ function roi_enqueue_generic_tables() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generic Tables CSS
|
||||
// DIFERIDO: Fase 4.2 PageSpeed - below the fold
|
||||
wp_enqueue_style(
|
||||
'roi-generic-tables',
|
||||
get_template_directory_uri() . '/Assets/Css/css-global-generic-tables.css',
|
||||
array('roi-bootstrap'),
|
||||
ROI_VERSION,
|
||||
'print' // Diferido para no bloquear renderizado
|
||||
);
|
||||
// ELIMINADO: Generic Tables CSS
|
||||
// Motivo: Migrado a CustomCSSManager (TIPO 3: CSS Crítico Personalizado)
|
||||
// Los estilos ahora se inyectan dinámicamente desde la BD via CustomCSSInjector
|
||||
// Fecha: 2025-12-01
|
||||
// @see Admin/CustomCSSManager/ - Sistema de gestión de CSS personalizado
|
||||
// @see Public/CustomCSSManager/Infrastructure/Services/CustomCSSInjector.php
|
||||
|
||||
// wp_enqueue_style(
|
||||
// 'roi-generic-tables',
|
||||
// get_template_directory_uri() . '/Assets/Css/css-global-generic-tables.css',
|
||||
// array('roi-bootstrap'),
|
||||
// ROI_VERSION,
|
||||
// 'print'
|
||||
// );
|
||||
}
|
||||
|
||||
add_action('wp_enqueue_scripts', 'roi_enqueue_generic_tables', 11);
|
||||
@@ -570,43 +575,38 @@ add_action('wp_enqueue_scripts', 'roi_enqueue_theme_styles', 13);
|
||||
* @see Assets/Css/critical-bootstrap.css - CSS crítico inline
|
||||
* @see Shared/Infrastructure/Services/CriticalBootstrapService.php
|
||||
*/
|
||||
function roi_enqueue_apu_tables_styles() {
|
||||
wp_enqueue_style(
|
||||
'roi-tables-apu',
|
||||
get_template_directory_uri() . '/Assets/Css/css-tablas-apu.css',
|
||||
array('roi-bootstrap'),
|
||||
ROI_VERSION,
|
||||
'print' // media="print" para carga async - se cambia a 'all' via JS
|
||||
);
|
||||
}
|
||||
// ELIMINADO: roi_enqueue_apu_tables_styles y roi_async_apu_tables_css_tag
|
||||
// Motivo: Migrado a CustomCSSManager (TIPO 3: CSS Crítico Personalizado)
|
||||
// Los estilos de tablas APU ahora se inyectan dinámicamente desde la BD
|
||||
// via CustomCSSInjector en wp_footer con id="roi-custom-deferred-css"
|
||||
// Fecha: 2025-12-01
|
||||
// @see Admin/CustomCSSManager/ - Sistema de gestión de CSS personalizado
|
||||
// @see Public/CustomCSSManager/Infrastructure/Services/CustomCSSInjector.php
|
||||
|
||||
add_action('wp_enqueue_scripts', 'roi_enqueue_apu_tables_styles', 5);
|
||||
// function roi_enqueue_apu_tables_styles() {
|
||||
// wp_enqueue_style(
|
||||
// 'roi-tables-apu',
|
||||
// get_template_directory_uri() . '/Assets/Css/css-tablas-apu.css',
|
||||
// array('roi-bootstrap'),
|
||||
// ROI_VERSION,
|
||||
// 'print'
|
||||
// );
|
||||
// }
|
||||
// add_action('wp_enqueue_scripts', 'roi_enqueue_apu_tables_styles', 5);
|
||||
|
||||
/**
|
||||
* Modificar tag de css-tablas-apu.css para carga async
|
||||
*
|
||||
* Agrega onload="this.media='all'" para aplicar estilos después de cargar
|
||||
* sin bloquear el renderizado inicial.
|
||||
*
|
||||
* @param string $tag Tag HTML del link
|
||||
* @param string $handle Nombre del estilo
|
||||
* @return string Tag modificado
|
||||
*/
|
||||
function roi_async_apu_tables_css_tag($tag, $handle) {
|
||||
if ($handle === 'roi-tables-apu') {
|
||||
// Agregar onload para cambiar media a 'all' cuando cargue
|
||||
$tag = str_replace(
|
||||
"media='print'",
|
||||
"media='print' onload=\"this.media='all'\"",
|
||||
$tag
|
||||
);
|
||||
// Agregar noscript fallback
|
||||
$noscript_url = get_template_directory_uri() . '/Assets/Css/css-tablas-apu.css?ver=' . ROI_VERSION;
|
||||
$tag .= '<noscript><link rel="stylesheet" href="' . esc_url($noscript_url) . '"></noscript>';
|
||||
}
|
||||
return $tag;
|
||||
}
|
||||
add_filter('style_loader_tag', 'roi_async_apu_tables_css_tag', 10, 2);
|
||||
// function roi_async_apu_tables_css_tag($tag, $handle) {
|
||||
// if ($handle === 'roi-tables-apu') {
|
||||
// $tag = str_replace(
|
||||
// "media='print'",
|
||||
// "media='print' onload=\"this.media='all'\"",
|
||||
// $tag
|
||||
// );
|
||||
// $noscript_url = get_template_directory_uri() . '/Assets/Css/css-tablas-apu.css?ver=' . ROI_VERSION;
|
||||
// $tag .= '<noscript><link rel="stylesheet" href="' . esc_url($noscript_url) . '"></noscript>';
|
||||
// }
|
||||
// return $tag;
|
||||
// }
|
||||
// add_filter('style_loader_tag', 'roi_async_apu_tables_css_tag', 10, 2);
|
||||
|
||||
/**
|
||||
* Enqueue APU Tables auto-class JavaScript
|
||||
|
||||
Reference in New Issue
Block a user