Files
roi-theme/sidebar.php
FrankZamora de5fff4f5c 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>
2025-11-17 13:48:24 -06:00

57 lines
1.3 KiB
PHP

<?php
/**
* The sidebar template file
*
* This template displays the primary sidebar widget area.
* If no widgets are active, the sidebar will not be displayed.
*
* @package ROI_Theme
* @since 1.0.0
*/
// Exit if the sidebar is not active
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
}
?>
<div class="sidebar-sticky position-sticky" style="top: 5rem;">
<?php
/**
* Display Table of Contents (TOC) on single posts
* Issue #86 - TOC should be displayed in sidebar
*/
if (is_single() && function_exists('roi_extract_headings') && function_exists('roi_generate_toc')) {
global $post;
if (!empty($post->post_content)) {
$headings = roi_extract_headings($post->post_content);
$toc_html = roi_generate_toc($headings);
if (!empty($toc_html)) {
echo $toc_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
}
?>
<?php
/**
* Display sidebar widgets
*
* Widgets can be added through Appearance > Widgets in the WordPress admin.
* The sidebar must be registered in functions.php for widgets to appear here.
*/
if (is_active_sidebar('sidebar-1')) {
dynamic_sidebar('sidebar-1');
}
?>
<?php
/**
* CTA Box Sidebar (Issue #36)
*
* Display CTA box below TOC on single posts
*/
get_template_part( 'template-parts/cta-box', 'sidebar' );
?>
</div><!-- .sidebar-sticky -->