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:
FrankZamora
2025-11-17 13:48:24 -06:00
parent b782ebceee
commit de5fff4f5c
149 changed files with 3187 additions and 9554 deletions

View File

@@ -5,7 +5,7 @@
* This file contains examples of how to use theme options throughout the theme.
* DO NOT include this file in functions.php - it's for reference only.
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -18,7 +18,7 @@ if (!defined('ABSPATH')) {
* EXAMPLE 1: Using options in header.php
*/
function example_display_logo() {
$logo_url = apus_get_logo_url();
$logo_url = roi_get_logo_url();
if ($logo_url) {
?>
@@ -39,8 +39,8 @@ function example_display_logo() {
* EXAMPLE 2: Displaying breadcrumbs
*/
function example_show_breadcrumbs() {
if (apus_show_breadcrumbs() && !is_front_page()) {
$separator = apus_get_breadcrumb_separator();
if (roi_show_breadcrumbs() && !is_front_page()) {
$separator = roi_get_breadcrumb_separator();
echo '<nav class="breadcrumbs">';
echo '<a href="' . esc_url(home_url('/')) . '">Home</a>';
@@ -62,12 +62,12 @@ function example_show_breadcrumbs() {
* EXAMPLE 3: Customizing excerpt
*/
function example_custom_excerpt_length($length) {
return apus_get_excerpt_length();
return roi_get_excerpt_length();
}
add_filter('excerpt_length', 'example_custom_excerpt_length');
function example_custom_excerpt_more($more) {
return apus_get_excerpt_more();
return roi_get_excerpt_more();
}
add_filter('excerpt_more', 'example_custom_excerpt_more');
@@ -75,10 +75,10 @@ add_filter('excerpt_more', 'example_custom_excerpt_more');
* EXAMPLE 4: Displaying related posts in single.php
*/
function example_display_related_posts() {
if (apus_show_related_posts() && is_single()) {
$count = apus_get_related_posts_count();
$taxonomy = apus_get_related_posts_taxonomy();
$title = apus_get_related_posts_title();
if (roi_show_related_posts() && is_single()) {
$count = roi_get_related_posts_count();
$taxonomy = roi_get_related_posts_taxonomy();
$title = roi_get_related_posts_title();
// Get related posts
$post_id = get_the_ID();
@@ -113,7 +113,7 @@ function example_display_related_posts() {
<article class="related-post-item">
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('apus-thumbnail'); ?>
<?php the_post_thumbnail('roi-thumbnail'); ?>
</a>
<?php endif; ?>
<h4>
@@ -121,7 +121,7 @@ function example_display_related_posts() {
</h4>
<div class="post-meta">
<time datetime="<?php echo get_the_date('c'); ?>">
<?php echo get_the_date(apus_get_date_format()); ?>
<?php echo get_the_date(roi_get_date_format()); ?>
</time>
</div>
</article>
@@ -140,9 +140,9 @@ function example_display_related_posts() {
* EXAMPLE 5: Conditional comments display
*/
function example_maybe_show_comments() {
if (is_single() && apus_comments_enabled_for_posts()) {
if (is_single() && roi_comments_enabled_for_posts()) {
comments_template();
} elseif (is_page() && apus_comments_enabled_for_pages()) {
} elseif (is_page() && roi_comments_enabled_for_pages()) {
comments_template();
}
}
@@ -151,10 +151,10 @@ function example_maybe_show_comments() {
* EXAMPLE 6: Featured image on single posts
*/
function example_display_featured_image() {
if (is_single() && apus_show_featured_image_single() && has_post_thumbnail()) {
if (is_single() && roi_show_featured_image_single() && has_post_thumbnail()) {
?>
<div class="post-thumbnail">
<?php the_post_thumbnail('apus-featured-large'); ?>
<?php the_post_thumbnail('roi-featured-large'); ?>
</div>
<?php
}
@@ -164,7 +164,7 @@ function example_display_featured_image() {
* EXAMPLE 7: Author box on single posts
*/
function example_display_author_box() {
if (is_single() && apus_show_author_box()) {
if (is_single() && roi_show_author_box()) {
$author_id = get_the_author_meta('ID');
?>
<div class="author-box">
@@ -175,7 +175,7 @@ function example_display_author_box() {
<h4 class="author-name"><?php the_author(); ?></h4>
<p class="author-bio"><?php the_author_meta('description'); ?></p>
<a href="<?php echo get_author_posts_url($author_id); ?>" class="author-link">
<?php _e('View all posts', 'apus-theme'); ?>
<?php _e('View all posts', 'roi-theme'); ?>
</a>
</div>
</div>
@@ -187,7 +187,7 @@ function example_display_author_box() {
* EXAMPLE 8: Social media links in footer
*/
function example_display_social_links() {
$social_links = apus_get_social_links();
$social_links = roi_get_social_links();
// Filter out empty links
$social_links = array_filter($social_links);
@@ -213,7 +213,7 @@ function example_display_social_links() {
* EXAMPLE 9: Copyright text in footer
*/
function example_display_copyright() {
$copyright = apus_get_copyright_text();
$copyright = roi_get_copyright_text();
if ($copyright) {
echo '<div class="copyright">' . wp_kses_post($copyright) . '</div>';
@@ -224,7 +224,7 @@ function example_display_copyright() {
* EXAMPLE 10: Custom CSS in header
*/
function example_add_custom_css() {
$custom_css = apus_get_custom_css();
$custom_css = roi_get_custom_css();
if ($custom_css) {
echo '<style type="text/css">' . "\n";
@@ -238,7 +238,7 @@ add_action('wp_head', 'example_add_custom_css', 100);
* EXAMPLE 11: Custom JS in header
*/
function example_add_custom_js_header() {
$custom_js = apus_get_custom_js_header();
$custom_js = roi_get_custom_js_header();
if ($custom_js) {
echo '<script type="text/javascript">' . "\n";
@@ -252,7 +252,7 @@ add_action('wp_head', 'example_add_custom_js_header', 100);
* EXAMPLE 12: Custom JS in footer
*/
function example_add_custom_js_footer() {
$custom_js = apus_get_custom_js_footer();
$custom_js = roi_get_custom_js_footer();
if ($custom_js) {
echo '<script type="text/javascript">' . "\n";
@@ -267,7 +267,7 @@ add_action('wp_footer', 'example_add_custom_js_footer', 100);
*/
function example_set_archive_posts_per_page($query) {
if ($query->is_archive() && !is_admin() && $query->is_main_query()) {
$posts_per_page = apus_get_archive_posts_per_page();
$posts_per_page = roi_get_archive_posts_per_page();
$query->set('posts_per_page', $posts_per_page);
}
}
@@ -278,18 +278,18 @@ add_action('pre_get_posts', 'example_set_archive_posts_per_page');
*/
function example_apply_performance_settings() {
// Remove emoji scripts
if (apus_is_performance_enabled('remove_emoji')) {
if (roi_is_performance_enabled('remove_emoji')) {
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
}
// Remove embeds
if (apus_is_performance_enabled('remove_embeds')) {
if (roi_is_performance_enabled('remove_embeds')) {
wp_deregister_script('wp-embed');
}
// Remove Dashicons for non-logged users
if (apus_is_performance_enabled('remove_dashicons') && !is_user_logged_in()) {
if (roi_is_performance_enabled('remove_dashicons') && !is_user_logged_in()) {
wp_deregister_style('dashicons');
}
}
@@ -299,7 +299,7 @@ add_action('wp_enqueue_scripts', 'example_apply_performance_settings', 100);
* EXAMPLE 15: Lazy loading images
*/
function example_add_lazy_loading($attr, $attachment, $size) {
if (apus_is_lazy_loading_enabled()) {
if (roi_is_lazy_loading_enabled()) {
$attr['loading'] = 'lazy';
}
return $attr;
@@ -313,9 +313,9 @@ function example_get_layout_class() {
$layout = 'right-sidebar'; // default
if (is_single()) {
$layout = apus_get_default_post_layout();
$layout = roi_get_default_post_layout();
} elseif (is_page()) {
$layout = apus_get_default_page_layout();
$layout = roi_get_default_page_layout();
}
return 'layout-' . $layout;
@@ -325,7 +325,7 @@ function example_get_layout_class() {
* EXAMPLE 17: Display post meta conditionally
*/
function example_display_post_meta() {
if (!apus_get_option('show_post_meta', true)) {
if (!roi_get_option('show_post_meta', true)) {
return;
}
@@ -333,13 +333,13 @@ function example_display_post_meta() {
<div class="post-meta">
<span class="post-date">
<time datetime="<?php echo get_the_date('c'); ?>">
<?php echo get_the_date(apus_get_date_format()); ?>
<?php echo get_the_date(roi_get_date_format()); ?>
</time>
</span>
<span class="post-author">
<?php the_author(); ?>
</span>
<?php if (apus_get_option('show_post_categories', true)) : ?>
<?php if (roi_get_option('show_post_categories', true)) : ?>
<span class="post-categories">
<?php the_category(', '); ?>
</span>
@@ -352,7 +352,7 @@ function example_display_post_meta() {
* EXAMPLE 18: Display post tags conditionally
*/
function example_display_post_tags() {
if (is_single() && apus_get_option('show_post_tags', true)) {
if (is_single() && roi_get_option('show_post_tags', true)) {
the_tags('<div class="post-tags">', ', ', '</div>');
}
}
@@ -362,7 +362,7 @@ function example_display_post_tags() {
*/
function example_debug_all_options() {
if (current_user_can('manage_options') && isset($_GET['debug_options'])) {
$all_options = apus_get_all_options();
$all_options = roi_get_all_options();
echo '<pre>';
print_r($all_options);
echo '</pre>';
@@ -377,17 +377,17 @@ function example_check_feature() {
// Multiple ways to check boolean options
// Method 1: Using helper function
if (apus_is_option_enabled('enable_breadcrumbs')) {
if (roi_is_option_enabled('enable_breadcrumbs')) {
// Breadcrumbs are enabled
}
// Method 2: Using get_option with default
if (apus_get_option('enable_related_posts', true)) {
if (roi_get_option('enable_related_posts', true)) {
// Related posts are enabled
}
// Method 3: Direct check
$options = apus_get_all_options();
$options = roi_get_all_options();
if (isset($options['enable_lazy_loading']) && $options['enable_lazy_loading']) {
// Lazy loading is enabled
}