Fase 1: Estructura Base y DI Container - Clean Architecture
COMPLETADO: Fase 1 de la migración a Clean Architecture + POO ## Estructura de Carpetas - ✓ Estructura completa de 4 capas (Domain, Application, Infrastructure, Presentation) - ✓ Carpetas de Use Cases (SaveComponent, GetComponent, DeleteComponent, SyncSchema) - ✓ Estructura de tests (Unit, Integration, E2E) - ✓ Carpetas de schemas y templates ## Composer y Autoloading - ✓ PSR-4 autoloading configurado para ROITheme namespace - ✓ Autoloader optimizado regenerado ## DI Container - ✓ DIContainer implementado con patrón Singleton - ✓ Métodos set(), get(), has() para gestión de servicios - ✓ Getters específicos para ComponentRepository, ValidationService, CacheService - ✓ Placeholders que serán implementados en Fase 5 - ✓ Prevención de clonación y deserialización ## Interfaces - ✓ ComponentRepositoryInterface (Domain) - ✓ ValidationServiceInterface (Application) - ✓ CacheServiceInterface (Application) - ✓ Component entity placeholder (Domain) ## Bootstrap - ✓ functions.php actualizado con carga de Composer autoloader - ✓ Inicialización del DIContainer - ✓ Helper function roi_container() disponible globalmente ## Tests - ✓ 10 tests unitarios para DIContainer (100% cobertura) - ✓ Total: 13 tests unitarios, 28 assertions - ✓ Suite de tests pasando correctamente ## Validación - ✓ Script de validación automatizado (48/48 checks pasados) - ✓ 100% de validaciones exitosas La arquitectura base está lista para la Fase 2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
* Template Part: Table of Contents (TOC)
|
||||
*
|
||||
* Genera automáticamente TOC desde los H2 del post
|
||||
* Usa JavaScript custom para ScrollSpy
|
||||
* HTML exacto del template original
|
||||
*
|
||||
* @package APUs_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
@@ -14,52 +14,29 @@ if (!is_single()) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Función: Generar TOC desde el contenido del post
|
||||
*
|
||||
* Busca todos los H2 que tengan ID
|
||||
* Retorna HTML de la tabla de contenidos
|
||||
*/
|
||||
function apu_generate_toc($content) {
|
||||
// Buscar todos los H2 con ID en el contenido
|
||||
// Regex: <h2[^>]*id=["']([^"']*) ["'][^>]*>(.*?)</h2>
|
||||
preg_match_all('/<h2[^>]*id=["\']([^"\']*)["\'][^>]*>(.*?)<\/h2>/i', $content, $matches);
|
||||
|
||||
// Si no hay H2 con ID, no mostrar TOC
|
||||
if (empty($matches[1])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Iniciar construcción del TOC
|
||||
$toc = '<div class="toc-container">';
|
||||
$toc .= '<h4 class="toc-title">Tabla de Contenido</h4>';
|
||||
$toc .= '<ol class="list-unstyled toc-list">';
|
||||
|
||||
// Iterar sobre cada H2 encontrado
|
||||
foreach ($matches[1] as $index => $id) {
|
||||
// Limpiar el título (eliminar tags HTML internos)
|
||||
$title = strip_tags($matches[2][$index]);
|
||||
|
||||
// Crear el elemento de la lista
|
||||
$toc .= sprintf(
|
||||
'<li><a href="#%s" class="toc-link">%s</a></li>',
|
||||
esc_attr($id),
|
||||
esc_html($title)
|
||||
);
|
||||
}
|
||||
|
||||
$toc .= '</ol>';
|
||||
$toc .= '</div>';
|
||||
|
||||
return $toc;
|
||||
}
|
||||
|
||||
// Obtener el contenido del post actual
|
||||
global $post;
|
||||
$post_content = $post->post_content;
|
||||
|
||||
// Aplicar filtros de WordPress al contenido (shortcodes, etc.)
|
||||
// Aplicar filtros de WordPress al contenido
|
||||
$post_content = apply_filters('the_content', $post_content);
|
||||
|
||||
// Generar y mostrar el TOC
|
||||
echo apu_generate_toc($post_content);
|
||||
// Buscar todos los H2 con ID en el contenido
|
||||
preg_match_all('/<h2[^>]*id=["\']([^"\']*)["\'][^>]*>(.*?)<\/h2>/i', $post_content, $matches);
|
||||
|
||||
// Si no hay H2 con ID, no mostrar TOC
|
||||
if (empty($matches[1])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Generar el TOC con el HTML del template
|
||||
?>
|
||||
<div class="toc-container">
|
||||
<h4>Tabla de Contenido</h4>
|
||||
<ol class="list-unstyled toc-list">
|
||||
<?php foreach ($matches[1] as $index => $id) : ?>
|
||||
<?php $title = strip_tags($matches[2][$index]); ?>
|
||||
<li><a href="#<?php echo esc_attr($id); ?>"><?php echo esc_html($title); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user