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:
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Funciones helper para leer configuraciones del tema desde la tabla personalizada
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
@@ -20,14 +20,14 @@ if (!defined('ABSPATH')) {
|
||||
* @param mixed $default Default value if setting doesn't exist
|
||||
* @return mixed The setting value
|
||||
*/
|
||||
function apus_get_setting($setting_name, $default = '') {
|
||||
function roi_get_setting($setting_name, $default = '') {
|
||||
// Cache estático para optimizar performance
|
||||
static $db_manager = null;
|
||||
static $settings_cache = null;
|
||||
|
||||
// Inicializar DB Manager una sola vez
|
||||
if ($db_manager === null) {
|
||||
$db_manager = new APUS_DB_Manager();
|
||||
$db_manager = new ROI_DB_Manager();
|
||||
}
|
||||
|
||||
// Cargar todas las configuraciones una sola vez por request
|
||||
@@ -37,7 +37,7 @@ function apus_get_setting($setting_name, $default = '') {
|
||||
// Si no hay configuraciones en la tabla, intentar desde wp_options
|
||||
// (backward compatibility durante migración)
|
||||
if (empty($settings_cache)) {
|
||||
$settings_cache = get_option('apus_theme_options', array());
|
||||
$settings_cache = get_option('roi_theme_options', array());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ function apus_get_setting($setting_name, $default = '') {
|
||||
/**
|
||||
* Get theme option value (ALIAS for backward compatibility)
|
||||
*
|
||||
* @deprecated 2.0.0 Use apus_get_setting() instead
|
||||
* @deprecated 2.0.0 Use roi_get_setting() instead
|
||||
* @param string $option_name The option name
|
||||
* @param mixed $default Default value if option doesn't exist
|
||||
* @return mixed The option value
|
||||
*/
|
||||
function apus_get_option($option_name, $default = '') {
|
||||
return apus_get_setting($option_name, $default);
|
||||
function roi_get_option($option_name, $default = '') {
|
||||
return roi_get_setting($option_name, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,19 +67,19 @@ function apus_get_option($option_name, $default = '') {
|
||||
* @param string $setting_name The setting name
|
||||
* @return bool True if enabled, false otherwise
|
||||
*/
|
||||
function apus_is_setting_enabled($setting_name) {
|
||||
return (bool) apus_get_setting($setting_name, false);
|
||||
function roi_is_setting_enabled($setting_name) {
|
||||
return (bool) roi_get_setting($setting_name, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if option is enabled (ALIAS for backward compatibility)
|
||||
*
|
||||
* @deprecated 2.0.0 Use apus_is_setting_enabled() instead
|
||||
* @deprecated 2.0.0 Use roi_is_setting_enabled() instead
|
||||
* @param string $option_name The option name
|
||||
* @return bool True if enabled, false otherwise
|
||||
*/
|
||||
function apus_is_option_enabled($option_name) {
|
||||
return apus_is_setting_enabled($option_name);
|
||||
function roi_is_option_enabled($option_name) {
|
||||
return roi_is_setting_enabled($option_name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +87,8 @@ function apus_is_option_enabled($option_name) {
|
||||
*
|
||||
* @return string The separator
|
||||
*/
|
||||
function apus_get_breadcrumb_separator() {
|
||||
return apus_get_setting('breadcrumb_separator', '>');
|
||||
function roi_get_breadcrumb_separator() {
|
||||
return roi_get_setting('breadcrumb_separator', '>');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,8 +96,8 @@ function apus_get_breadcrumb_separator() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_show_breadcrumbs() {
|
||||
return apus_is_setting_enabled('enable_breadcrumbs');
|
||||
function roi_show_breadcrumbs() {
|
||||
return roi_is_setting_enabled('enable_breadcrumbs');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,8 +105,8 @@ function apus_show_breadcrumbs() {
|
||||
*
|
||||
* @return int The excerpt length
|
||||
*/
|
||||
function apus_get_excerpt_length() {
|
||||
return (int) apus_get_setting('excerpt_length', 55);
|
||||
function roi_get_excerpt_length() {
|
||||
return (int) roi_get_setting('excerpt_length', 55);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +114,8 @@ function apus_get_excerpt_length() {
|
||||
*
|
||||
* @return string The excerpt more text
|
||||
*/
|
||||
function apus_get_excerpt_more() {
|
||||
return apus_get_setting('excerpt_more', '...');
|
||||
function roi_get_excerpt_more() {
|
||||
return roi_get_setting('excerpt_more', '...');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,8 @@ function apus_get_excerpt_more() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_show_related_posts() {
|
||||
return apus_is_setting_enabled('enable_related_posts');
|
||||
function roi_show_related_posts() {
|
||||
return roi_is_setting_enabled('enable_related_posts');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,8 +132,8 @@ function apus_show_related_posts() {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function apus_get_related_posts_count() {
|
||||
return (int) apus_get_setting('related_posts_count', 3);
|
||||
function roi_get_related_posts_count() {
|
||||
return (int) roi_get_setting('related_posts_count', 3);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,8 +141,8 @@ function apus_get_related_posts_count() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_related_posts_taxonomy() {
|
||||
return apus_get_setting('related_posts_taxonomy', 'category');
|
||||
function roi_get_related_posts_taxonomy() {
|
||||
return roi_get_setting('related_posts_taxonomy', 'category');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,8 +150,8 @@ function apus_get_related_posts_taxonomy() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_related_posts_title() {
|
||||
return apus_get_setting('related_posts_title', __('Related Posts', 'apus-theme'));
|
||||
function roi_get_related_posts_title() {
|
||||
return roi_get_setting('related_posts_title', __('Related Posts', 'roi-theme'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,8 +160,8 @@ function apus_get_related_posts_title() {
|
||||
* @param string $optimization The optimization name
|
||||
* @return bool
|
||||
*/
|
||||
function apus_is_performance_enabled($optimization) {
|
||||
return apus_is_setting_enabled('performance_' . $optimization);
|
||||
function roi_is_performance_enabled($optimization) {
|
||||
return roi_is_setting_enabled('performance_' . $optimization);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,13 +169,13 @@ function apus_is_performance_enabled($optimization) {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_copyright_text() {
|
||||
function roi_get_copyright_text() {
|
||||
$default = sprintf(
|
||||
__('© %s %s. All rights reserved.', 'apus-theme'),
|
||||
__('© %s %s. All rights reserved.', 'roi-theme'),
|
||||
date('Y'),
|
||||
get_bloginfo('name')
|
||||
);
|
||||
return apus_get_setting('copyright_text', $default);
|
||||
return roi_get_setting('copyright_text', $default);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,13 +183,13 @@ function apus_get_copyright_text() {
|
||||
*
|
||||
* @return array Array of social media links
|
||||
*/
|
||||
function apus_get_social_links() {
|
||||
function roi_get_social_links() {
|
||||
return array(
|
||||
'facebook' => apus_get_setting('social_facebook', ''),
|
||||
'twitter' => apus_get_setting('social_twitter', ''),
|
||||
'instagram' => apus_get_setting('social_instagram', ''),
|
||||
'linkedin' => apus_get_setting('social_linkedin', ''),
|
||||
'youtube' => apus_get_setting('social_youtube', ''),
|
||||
'facebook' => roi_get_setting('social_facebook', ''),
|
||||
'twitter' => roi_get_setting('social_twitter', ''),
|
||||
'instagram' => roi_get_setting('social_instagram', ''),
|
||||
'linkedin' => roi_get_setting('social_linkedin', ''),
|
||||
'youtube' => roi_get_setting('social_youtube', ''),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ function apus_get_social_links() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_comments_enabled_for_posts() {
|
||||
return apus_is_setting_enabled('enable_comments_posts');
|
||||
function roi_comments_enabled_for_posts() {
|
||||
return roi_is_setting_enabled('enable_comments_posts');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,8 +207,8 @@ function apus_comments_enabled_for_posts() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_comments_enabled_for_pages() {
|
||||
return apus_is_setting_enabled('enable_comments_pages');
|
||||
function roi_comments_enabled_for_pages() {
|
||||
return roi_is_setting_enabled('enable_comments_pages');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,8 +216,8 @@ function apus_comments_enabled_for_pages() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_default_post_layout() {
|
||||
return apus_get_setting('default_post_layout', 'right-sidebar');
|
||||
function roi_get_default_post_layout() {
|
||||
return roi_get_setting('default_post_layout', 'right-sidebar');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,8 +225,8 @@ function apus_get_default_post_layout() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_default_page_layout() {
|
||||
return apus_get_setting('default_page_layout', 'right-sidebar');
|
||||
function roi_get_default_page_layout() {
|
||||
return roi_get_setting('default_page_layout', 'right-sidebar');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,8 +234,8 @@ function apus_get_default_page_layout() {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function apus_get_archive_posts_per_page() {
|
||||
$custom = (int) apus_get_setting('archive_posts_per_page', 0);
|
||||
function roi_get_archive_posts_per_page() {
|
||||
$custom = (int) roi_get_setting('archive_posts_per_page', 0);
|
||||
return $custom > 0 ? $custom : get_option('posts_per_page', 10);
|
||||
}
|
||||
|
||||
@@ -244,8 +244,8 @@ function apus_get_archive_posts_per_page() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_show_featured_image_single() {
|
||||
return apus_is_setting_enabled('show_featured_image_single');
|
||||
function roi_show_featured_image_single() {
|
||||
return roi_is_setting_enabled('show_featured_image_single');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,8 +253,8 @@ function apus_show_featured_image_single() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_show_author_box() {
|
||||
return apus_is_setting_enabled('show_author_box');
|
||||
function roi_show_author_box() {
|
||||
return roi_is_setting_enabled('show_author_box');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,8 +262,8 @@ function apus_show_author_box() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_date_format() {
|
||||
return apus_get_setting('date_format', 'd/m/Y');
|
||||
function roi_get_date_format() {
|
||||
return roi_get_setting('date_format', 'd/m/Y');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,8 +271,8 @@ function apus_get_date_format() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_time_format() {
|
||||
return apus_get_setting('time_format', 'H:i');
|
||||
function roi_get_time_format() {
|
||||
return roi_get_setting('time_format', 'H:i');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,8 +280,8 @@ function apus_get_time_format() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_logo_url() {
|
||||
$logo_id = apus_get_setting('site_logo', 0);
|
||||
function roi_get_logo_url() {
|
||||
$logo_id = roi_get_setting('site_logo', 0);
|
||||
if ($logo_id) {
|
||||
$logo = wp_get_attachment_image_url($logo_id, 'full');
|
||||
if ($logo) {
|
||||
@@ -296,8 +296,8 @@ function apus_get_logo_url() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_favicon_url() {
|
||||
$favicon_id = apus_get_setting('site_favicon', 0);
|
||||
function roi_get_favicon_url() {
|
||||
$favicon_id = roi_get_setting('site_favicon', 0);
|
||||
if ($favicon_id) {
|
||||
$favicon = wp_get_attachment_image_url($favicon_id, 'full');
|
||||
if ($favicon) {
|
||||
@@ -312,8 +312,8 @@ function apus_get_favicon_url() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_custom_css() {
|
||||
return apus_get_setting('custom_css', '');
|
||||
function roi_get_custom_css() {
|
||||
return roi_get_setting('custom_css', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,8 +321,8 @@ function apus_get_custom_css() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_custom_js_header() {
|
||||
return apus_get_setting('custom_js_header', '');
|
||||
function roi_get_custom_js_header() {
|
||||
return roi_get_setting('custom_js_header', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,8 +330,8 @@ function apus_get_custom_js_header() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_custom_js_footer() {
|
||||
return apus_get_setting('custom_js_footer', '');
|
||||
function roi_get_custom_js_footer() {
|
||||
return roi_get_setting('custom_js_footer', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,8 +339,8 @@ function apus_get_custom_js_footer() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_is_lazy_loading_enabled() {
|
||||
return apus_is_setting_enabled('enable_lazy_loading');
|
||||
function roi_is_lazy_loading_enabled() {
|
||||
return roi_is_setting_enabled('enable_lazy_loading');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,13 +348,13 @@ function apus_is_lazy_loading_enabled() {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function apus_get_all_settings() {
|
||||
$db_manager = new APUS_DB_Manager();
|
||||
function roi_get_all_settings() {
|
||||
$db_manager = new ROI_DB_Manager();
|
||||
$settings = $db_manager->get_config('theme');
|
||||
|
||||
// Backward compatibility: si no hay settings en tabla, leer de wp_options
|
||||
if (empty($settings)) {
|
||||
$settings = get_option('apus_theme_options', array());
|
||||
$settings = get_option('roi_theme_options', array());
|
||||
}
|
||||
|
||||
return $settings;
|
||||
@@ -363,11 +363,11 @@ function apus_get_all_settings() {
|
||||
/**
|
||||
* Get all theme options (ALIAS for backward compatibility)
|
||||
*
|
||||
* @deprecated 2.0.0 Use apus_get_all_settings() instead
|
||||
* @deprecated 2.0.0 Use roi_get_all_settings() instead
|
||||
* @return array
|
||||
*/
|
||||
function apus_get_all_options() {
|
||||
return apus_get_all_settings();
|
||||
function roi_get_all_options() {
|
||||
return roi_get_all_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,19 +375,19 @@ function apus_get_all_options() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_reset_settings() {
|
||||
$db_manager = new APUS_DB_Manager();
|
||||
function roi_reset_settings() {
|
||||
$db_manager = new ROI_DB_Manager();
|
||||
return $db_manager->delete_config('theme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset theme options to defaults (ALIAS for backward compatibility)
|
||||
*
|
||||
* @deprecated 2.0.0 Use apus_reset_settings() instead
|
||||
* @deprecated 2.0.0 Use roi_reset_settings() instead
|
||||
* @return bool
|
||||
*/
|
||||
function apus_reset_options() {
|
||||
return apus_reset_settings();
|
||||
function roi_reset_options() {
|
||||
return roi_reset_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,8 +395,8 @@ function apus_reset_options() {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function apus_is_toc_enabled() {
|
||||
return apus_get_setting('enable_toc', true);
|
||||
function roi_is_toc_enabled() {
|
||||
return roi_get_setting('enable_toc', true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,8 +404,8 @@ function apus_is_toc_enabled() {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function apus_get_toc_min_headings() {
|
||||
return (int) apus_get_setting('toc_min_headings', 2);
|
||||
function roi_get_toc_min_headings() {
|
||||
return (int) roi_get_setting('toc_min_headings', 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,6 +413,6 @@ function apus_get_toc_min_headings() {
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function apus_get_toc_title() {
|
||||
return apus_get_setting('toc_title', __('Table of Contents', 'apus-theme'));
|
||||
function roi_get_toc_title() {
|
||||
return roi_get_setting('toc_title', __('Table of Contents', 'roi-theme'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user