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 provides helper functions and documentation for configuring
* related posts functionality via WordPress options.
*
* @package Apus_Theme
* @package ROI_Theme
* @since 1.0.0
*/
@@ -19,85 +19,85 @@ if (!defined('ABSPATH')) {
*
* @return array Array of options with their values
*/
function apus_get_related_posts_options() {
function roi_get_related_posts_options() {
return array(
'enabled' => array(
'key' => 'apus_related_posts_enabled',
'value' => get_option('apus_related_posts_enabled', true),
'key' => 'roi_related_posts_enabled',
'value' => get_option('roi_related_posts_enabled', true),
'type' => 'boolean',
'default' => true,
'label' => __('Enable Related Posts', 'apus-theme'),
'description' => __('Show related posts section at the end of single posts', 'apus-theme'),
'label' => __('Enable Related Posts', 'roi-theme'),
'description' => __('Show related posts section at the end of single posts', 'roi-theme'),
),
'title' => array(
'key' => 'apus_related_posts_title',
'value' => get_option('apus_related_posts_title', __('Related Posts', 'apus-theme')),
'key' => 'roi_related_posts_title',
'value' => get_option('roi_related_posts_title', __('Related Posts', 'roi-theme')),
'type' => 'text',
'default' => __('Related Posts', 'apus-theme'),
'label' => __('Section Title', 'apus-theme'),
'description' => __('Title displayed above related posts', 'apus-theme'),
'default' => __('Related Posts', 'roi-theme'),
'label' => __('Section Title', 'roi-theme'),
'description' => __('Title displayed above related posts', 'roi-theme'),
),
'count' => array(
'key' => 'apus_related_posts_count',
'value' => get_option('apus_related_posts_count', 3),
'key' => 'roi_related_posts_count',
'value' => get_option('roi_related_posts_count', 3),
'type' => 'number',
'default' => 3,
'min' => 1,
'max' => 12,
'label' => __('Number of Posts', 'apus-theme'),
'description' => __('Maximum number of related posts to display', 'apus-theme'),
'label' => __('Number of Posts', 'roi-theme'),
'description' => __('Maximum number of related posts to display', 'roi-theme'),
),
'columns' => array(
'key' => 'apus_related_posts_columns',
'value' => get_option('apus_related_posts_columns', 3),
'key' => 'roi_related_posts_columns',
'value' => get_option('roi_related_posts_columns', 3),
'type' => 'select',
'default' => 3,
'options' => array(
1 => __('1 Column', 'apus-theme'),
2 => __('2 Columns', 'apus-theme'),
3 => __('3 Columns', 'apus-theme'),
4 => __('4 Columns', 'apus-theme'),
1 => __('1 Column', 'roi-theme'),
2 => __('2 Columns', 'roi-theme'),
3 => __('3 Columns', 'roi-theme'),
4 => __('4 Columns', 'roi-theme'),
),
'label' => __('Grid Columns', 'apus-theme'),
'description' => __('Number of columns in the grid layout (responsive)', 'apus-theme'),
'label' => __('Grid Columns', 'roi-theme'),
'description' => __('Number of columns in the grid layout (responsive)', 'roi-theme'),
),
'show_excerpt' => array(
'key' => 'apus_related_posts_show_excerpt',
'value' => get_option('apus_related_posts_show_excerpt', true),
'key' => 'roi_related_posts_show_excerpt',
'value' => get_option('roi_related_posts_show_excerpt', true),
'type' => 'boolean',
'default' => true,
'label' => __('Show Excerpt', 'apus-theme'),
'description' => __('Display post excerpt in related posts cards', 'apus-theme'),
'label' => __('Show Excerpt', 'roi-theme'),
'description' => __('Display post excerpt in related posts cards', 'roi-theme'),
),
'excerpt_length' => array(
'key' => 'apus_related_posts_excerpt_length',
'value' => get_option('apus_related_posts_excerpt_length', 20),
'key' => 'roi_related_posts_excerpt_length',
'value' => get_option('roi_related_posts_excerpt_length', 20),
'type' => 'number',
'default' => 20,
'min' => 5,
'max' => 100,
'label' => __('Excerpt Length', 'apus-theme'),
'description' => __('Number of words in the excerpt', 'apus-theme'),
'label' => __('Excerpt Length', 'roi-theme'),
'description' => __('Number of words in the excerpt', 'roi-theme'),
),
'show_date' => array(
'key' => 'apus_related_posts_show_date',
'value' => get_option('apus_related_posts_show_date', true),
'key' => 'roi_related_posts_show_date',
'value' => get_option('roi_related_posts_show_date', true),
'type' => 'boolean',
'default' => true,
'label' => __('Show Date', 'apus-theme'),
'description' => __('Display publication date in related posts', 'apus-theme'),
'label' => __('Show Date', 'roi-theme'),
'description' => __('Display publication date in related posts', 'roi-theme'),
),
'show_category' => array(
'key' => 'apus_related_posts_show_category',
'value' => get_option('apus_related_posts_show_category', true),
'key' => 'roi_related_posts_show_category',
'value' => get_option('roi_related_posts_show_category', true),
'type' => 'boolean',
'default' => true,
'label' => __('Show Category', 'apus-theme'),
'description' => __('Display category badge on related posts', 'apus-theme'),
'label' => __('Show Category', 'roi-theme'),
'description' => __('Display category badge on related posts', 'roi-theme'),
),
'bg_colors' => array(
'key' => 'apus_related_posts_bg_colors',
'value' => get_option('apus_related_posts_bg_colors', array(
'key' => 'roi_related_posts_bg_colors',
'value' => get_option('roi_related_posts_bg_colors', array(
'#1a73e8', '#e91e63', '#4caf50', '#ff9800', '#9c27b0', '#00bcd4',
)),
'type' => 'color_array',
@@ -109,8 +109,8 @@ function apus_get_related_posts_options() {
'#9c27b0', // Purple
'#00bcd4', // Cyan
),
'label' => __('Background Colors', 'apus-theme'),
'description' => __('Colors used for posts without featured images', 'apus-theme'),
'label' => __('Background Colors', 'roi-theme'),
'description' => __('Colors used for posts without featured images', 'roi-theme'),
),
);
}
@@ -118,12 +118,12 @@ function apus_get_related_posts_options() {
/**
* Update a related posts option
*
* @param string $option_key The option key (without 'apus_related_posts_' prefix)
* @param string $option_key The option key (without 'roi_related_posts_' prefix)
* @param mixed $value The new value
* @return bool True if updated successfully
*/
function apus_update_related_posts_option($option_key, $value) {
$full_key = 'apus_related_posts_' . $option_key;
function roi_update_related_posts_option($option_key, $value) {
$full_key = 'roi_related_posts_' . $option_key;
return update_option($full_key, $value);
}
@@ -132,8 +132,8 @@ function apus_update_related_posts_option($option_key, $value) {
*
* @return bool True if reset successfully
*/
function apus_reset_related_posts_options() {
$options = apus_get_related_posts_options();
function roi_reset_related_posts_options() {
$options = roi_get_related_posts_options();
$success = true;
foreach ($options as $option) {
@@ -153,31 +153,31 @@ function apus_reset_related_posts_options() {
*
* @return void
*/
function apus_example_configure_related_posts() {
function roi_example_configure_related_posts() {
// Example usage - uncomment to use:
// Enable related posts
// update_option('apus_related_posts_enabled', true);
// update_option('roi_related_posts_enabled', true);
// Set custom title
// update_option('apus_related_posts_title', __('You Might Also Like', 'apus-theme'));
// update_option('roi_related_posts_title', __('You Might Also Like', 'roi-theme'));
// Show 4 related posts
// update_option('apus_related_posts_count', 4);
// update_option('roi_related_posts_count', 4);
// Use 2 columns layout
// update_option('apus_related_posts_columns', 2);
// update_option('roi_related_posts_columns', 2);
// Show excerpt with 30 words
// update_option('apus_related_posts_show_excerpt', true);
// update_option('apus_related_posts_excerpt_length', 30);
// update_option('roi_related_posts_show_excerpt', true);
// update_option('roi_related_posts_excerpt_length', 30);
// Show date and category
// update_option('apus_related_posts_show_date', true);
// update_option('apus_related_posts_show_category', true);
// update_option('roi_related_posts_show_date', true);
// update_option('roi_related_posts_show_category', true);
// Custom background colors for posts without images
// update_option('apus_related_posts_bg_colors', array(
// update_option('roi_related_posts_bg_colors', array(
// '#FF6B6B', // Red
// '#4ECDC4', // Teal
// '#45B7D1', // Blue
@@ -193,7 +193,7 @@ function apus_example_configure_related_posts() {
* This example shows how to customize the related posts query.
* Add this to your functions.php or child theme.
*/
function apus_example_modify_related_posts_query($args, $post_id) {
function roi_example_modify_related_posts_query($args, $post_id) {
// Example: Order by date instead of random
// $args['orderby'] = 'date';
// $args['order'] = 'DESC';
@@ -210,61 +210,61 @@ function apus_example_modify_related_posts_query($args, $post_id) {
return $args;
}
// add_filter('apus_related_posts_args', 'apus_example_modify_related_posts_query', 10, 2);
// add_filter('roi_related_posts_args', 'roi_example_modify_related_posts_query', 10, 2);
/**
* Get documentation for related posts configuration
*
* @return array Documentation array
*/
function apus_get_related_posts_documentation() {
function roi_get_related_posts_documentation() {
return array(
'overview' => array(
'title' => __('Related Posts Overview', 'apus-theme'),
'title' => __('Related Posts Overview', 'roi-theme'),
'content' => __(
'The related posts feature automatically displays relevant posts at the end of each blog post. ' .
'Posts are related based on shared categories and displayed in a responsive Bootstrap grid.',
'apus-theme'
'roi-theme'
),
),
'features' => array(
'title' => __('Key Features', 'apus-theme'),
'title' => __('Key Features', 'roi-theme'),
'items' => array(
__('Automatic category-based matching', 'apus-theme'),
__('Responsive Bootstrap 5 grid layout', 'apus-theme'),
__('Configurable number of posts and columns', 'apus-theme'),
__('Support for posts with and without featured images', 'apus-theme'),
__('Beautiful color backgrounds for posts without images', 'apus-theme'),
__('Customizable excerpt length', 'apus-theme'),
__('Optional display of dates and categories', 'apus-theme'),
__('Smooth hover animations', 'apus-theme'),
__('Print-friendly styles', 'apus-theme'),
__('Dark mode support', 'apus-theme'),
__('Automatic category-based matching', 'roi-theme'),
__('Responsive Bootstrap 5 grid layout', 'roi-theme'),
__('Configurable number of posts and columns', 'roi-theme'),
__('Support for posts with and without featured images', 'roi-theme'),
__('Beautiful color backgrounds for posts without images', 'roi-theme'),
__('Customizable excerpt length', 'roi-theme'),
__('Optional display of dates and categories', 'roi-theme'),
__('Smooth hover animations', 'roi-theme'),
__('Print-friendly styles', 'roi-theme'),
__('Dark mode support', 'roi-theme'),
),
),
'configuration' => array(
'title' => __('How to Configure', 'apus-theme'),
'title' => __('How to Configure', 'roi-theme'),
'methods' => array(
'database' => array(
'title' => __('Via WordPress Options API', 'apus-theme'),
'code' => "update_option('apus_related_posts_enabled', true);\nupdate_option('apus_related_posts_count', 4);",
'title' => __('Via WordPress Options API', 'roi-theme'),
'code' => "update_option('roi_related_posts_enabled', true);\nupdate_option('roi_related_posts_count', 4);",
),
'filter' => array(
'title' => __('Via Filter Hook', 'apus-theme'),
'code' => "add_filter('apus_related_posts_args', function(\$args, \$post_id) {\n \$args['posts_per_page'] = 6;\n return \$args;\n}, 10, 2);",
'title' => __('Via Filter Hook', 'roi-theme'),
'code' => "add_filter('roi_related_posts_args', function(\$args, \$post_id) {\n \$args['posts_per_page'] = 6;\n return \$args;\n}, 10, 2);",
),
),
),
'customization' => array(
'title' => __('Customization Examples', 'apus-theme'),
'title' => __('Customization Examples', 'roi-theme'),
'examples' => array(
array(
'title' => __('Change title and layout', 'apus-theme'),
'code' => "update_option('apus_related_posts_title', 'También te puede interesar');\nupdate_option('apus_related_posts_columns', 4);",
'title' => __('Change title and layout', 'roi-theme'),
'code' => "update_option('roi_related_posts_title', 'También te puede interesar');\nupdate_option('roi_related_posts_columns', 4);",
),
array(
'title' => __('Customize colors', 'apus-theme'),
'code' => "update_option('apus_related_posts_bg_colors', array(\n '#FF6B6B',\n '#4ECDC4',\n '#45B7D1'\n));",
'title' => __('Customize colors', 'roi-theme'),
'code' => "update_option('roi_related_posts_bg_colors', array(\n '#FF6B6B',\n '#4ECDC4',\n '#45B7D1'\n));",
),
),
),