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:
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Theme Options Admin JavaScript
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var ApusThemeOptions = {
|
||||
var ROIThemeOptions = {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
@@ -28,17 +28,17 @@
|
||||
*/
|
||||
tabs: function() {
|
||||
// Tab click handler
|
||||
$('.apus-tabs-nav a').on('click', function(e) {
|
||||
$('.roi-tabs-nav a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var tabId = $(this).attr('href');
|
||||
|
||||
// Update active states
|
||||
$('.apus-tabs-nav li').removeClass('active');
|
||||
$('.roi-tabs-nav li').removeClass('active');
|
||||
$(this).parent().addClass('active');
|
||||
|
||||
// Show/hide tab content
|
||||
$('.apus-tab-pane').removeClass('active');
|
||||
$('.roi-tab-pane').removeClass('active');
|
||||
$(tabId).addClass('active');
|
||||
|
||||
// Update URL hash without scrolling
|
||||
@@ -53,14 +53,14 @@
|
||||
if (window.location.hash) {
|
||||
var hash = window.location.hash;
|
||||
if ($(hash).length) {
|
||||
$('.apus-tabs-nav a[href="' + hash + '"]').trigger('click');
|
||||
$('.roi-tabs-nav a[href="' + hash + '"]').trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
// Handle browser back/forward buttons
|
||||
$(window).on('hashchange', function() {
|
||||
if (window.location.hash) {
|
||||
$('.apus-tabs-nav a[href="' + window.location.hash + '"]').trigger('click');
|
||||
$('.roi-tabs-nav a[href="' + window.location.hash + '"]').trigger('click');
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -73,14 +73,14 @@
|
||||
var mediaUploader;
|
||||
|
||||
// Upload button click
|
||||
$(document).on('click', '.apus-upload-image', function(e) {
|
||||
$(document).on('click', '.roi-upload-image', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var container = button.closest('.apus-image-upload');
|
||||
var preview = container.find('.apus-image-preview');
|
||||
var input = container.find('.apus-image-id');
|
||||
var removeBtn = container.find('.apus-remove-image');
|
||||
var container = button.closest('.roi-image-upload');
|
||||
var preview = container.find('.roi-image-preview');
|
||||
var input = container.find('.roi-image-id');
|
||||
var removeBtn = container.find('.roi-remove-image');
|
||||
|
||||
// If the media uploader already exists, reopen it
|
||||
if (mediaUploader) {
|
||||
@@ -90,9 +90,9 @@
|
||||
|
||||
// Create new media uploader
|
||||
mediaUploader = wp.media({
|
||||
title: apusAdminOptions.strings.selectImage,
|
||||
title: roiAdminOptions.strings.selectImage,
|
||||
button: {
|
||||
text: apusAdminOptions.strings.useImage
|
||||
text: roiAdminOptions.strings.useImage
|
||||
},
|
||||
multiple: false
|
||||
});
|
||||
@@ -107,7 +107,7 @@
|
||||
// Show preview
|
||||
var imgUrl = attachment.sizes && attachment.sizes.medium ?
|
||||
attachment.sizes.medium.url : attachment.url;
|
||||
preview.html('<img src="' + imgUrl + '" class="apus-preview-image" />');
|
||||
preview.html('<img src="' + imgUrl + '" class="roi-preview-image" />');
|
||||
|
||||
// Show remove button
|
||||
removeBtn.show();
|
||||
@@ -118,13 +118,13 @@
|
||||
});
|
||||
|
||||
// Remove button click
|
||||
$(document).on('click', '.apus-remove-image', function(e) {
|
||||
$(document).on('click', '.roi-remove-image', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var container = button.closest('.apus-image-upload');
|
||||
var preview = container.find('.apus-image-preview');
|
||||
var input = container.find('.apus-image-id');
|
||||
var container = button.closest('.roi-image-upload');
|
||||
var preview = container.find('.roi-image-preview');
|
||||
var input = container.find('.roi-image-id');
|
||||
|
||||
// Clear values
|
||||
input.val('');
|
||||
@@ -137,10 +137,10 @@
|
||||
* Reset Options
|
||||
*/
|
||||
resetOptions: function() {
|
||||
$('#apus-reset-options').on('click', function(e) {
|
||||
$('#roi-reset-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!confirm(apusAdminOptions.strings.confirmReset)) {
|
||||
if (!confirm(roiAdminOptions.strings.confirmReset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,28 +148,28 @@
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
url: roiAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_reset_options',
|
||||
nonce: apusAdminOptions.nonce
|
||||
action: 'roi_reset_options',
|
||||
nonce: roiAdminOptions.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Show success message
|
||||
ApusThemeOptions.showNotice('success', response.data.message);
|
||||
ROIThemeOptions.showNotice('success', response.data.message);
|
||||
|
||||
// Reload page after 1 second
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
ROIThemeOptions.showNotice('error', response.data.message);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
ROIThemeOptions.showNotice('error', roiAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
@@ -180,18 +180,18 @@
|
||||
* Export Options
|
||||
*/
|
||||
exportOptions: function() {
|
||||
$('#apus-export-options').on('click', function(e) {
|
||||
$('#roi-export-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
url: roiAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_export_options',
|
||||
nonce: apusAdminOptions.nonce
|
||||
action: 'roi_export_options',
|
||||
nonce: roiAdminOptions.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
@@ -206,14 +206,14 @@
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
|
||||
ApusThemeOptions.showNotice('success', 'Options exported successfully!');
|
||||
ROIThemeOptions.showNotice('success', 'Options exported successfully!');
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
ROIThemeOptions.showNotice('error', response.data.message);
|
||||
}
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
ROIThemeOptions.showNotice('error', roiAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
@@ -224,17 +224,17 @@
|
||||
* Import Options
|
||||
*/
|
||||
importOptions: function() {
|
||||
var modal = $('#apus-import-modal');
|
||||
var importData = $('#apus-import-data');
|
||||
var modal = $('#roi-import-modal');
|
||||
var importData = $('#roi-import-data');
|
||||
|
||||
// Show modal
|
||||
$('#apus-import-options').on('click', function(e) {
|
||||
$('#roi-import-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
modal.show();
|
||||
});
|
||||
|
||||
// Close modal
|
||||
$('.apus-modal-close, #apus-import-cancel').on('click', function() {
|
||||
$('.roi-modal-close, #roi-import-cancel').on('click', function() {
|
||||
modal.hide();
|
||||
importData.val('');
|
||||
});
|
||||
@@ -248,7 +248,7 @@
|
||||
});
|
||||
|
||||
// Submit import
|
||||
$('#apus-import-submit').on('click', function(e) {
|
||||
$('#roi-import-submit').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var data = importData.val().trim();
|
||||
@@ -262,16 +262,16 @@
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
url: roiAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_import_options',
|
||||
nonce: apusAdminOptions.nonce,
|
||||
action: 'roi_import_options',
|
||||
nonce: roiAdminOptions.nonce,
|
||||
import_data: data
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
ApusThemeOptions.showNotice('success', response.data.message);
|
||||
ROIThemeOptions.showNotice('success', response.data.message);
|
||||
modal.hide();
|
||||
importData.val('');
|
||||
|
||||
@@ -280,12 +280,12 @@
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
ROIThemeOptions.showNotice('error', response.data.message);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
ROIThemeOptions.showNotice('error', roiAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
@@ -296,7 +296,7 @@
|
||||
* Form Validation
|
||||
*/
|
||||
formValidation: function() {
|
||||
$('.apus-options-form').on('submit', function(e) {
|
||||
$('.roi-options-form').on('submit', function(e) {
|
||||
var valid = true;
|
||||
var firstError = null;
|
||||
|
||||
@@ -340,7 +340,7 @@
|
||||
// Validate URL fields
|
||||
$(this).find('input[type="url"]').each(function() {
|
||||
var val = $(this).val();
|
||||
if (val && !ApusThemeOptions.isValidUrl(val)) {
|
||||
if (val && !ROIThemeOptions.isValidUrl(val)) {
|
||||
valid = false;
|
||||
$(this).addClass('error');
|
||||
if (!firstError) {
|
||||
@@ -360,7 +360,7 @@
|
||||
firstError.focus();
|
||||
}
|
||||
|
||||
ApusThemeOptions.showNotice('error', 'Please fix the errors in the form.');
|
||||
ROIThemeOptions.showNotice('error', 'Please fix the errors in the form.');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@
|
||||
});
|
||||
|
||||
// Remove error class on input
|
||||
$('.apus-options-form input, .apus-options-form select, .apus-options-form textarea').on('change input', function() {
|
||||
$('.roi-options-form input, .roi-options-form select, .roi-options-form textarea').on('change input', function() {
|
||||
$(this).removeClass('error');
|
||||
});
|
||||
},
|
||||
@@ -383,7 +383,7 @@
|
||||
var checked = $(this).is(':checked');
|
||||
var fields = $('#related_posts_count, #related_posts_taxonomy, #related_posts_title, #related_posts_columns');
|
||||
|
||||
fields.closest('tr').toggleClass('apus-field-dependency', !checked);
|
||||
fields.closest('tr').toggleClass('roi-field-dependency', !checked);
|
||||
fields.prop('disabled', !checked);
|
||||
}).trigger('change');
|
||||
|
||||
@@ -392,7 +392,7 @@
|
||||
var checked = $(this).is(':checked');
|
||||
var field = $('#breadcrumb_separator');
|
||||
|
||||
field.closest('tr').toggleClass('apus-field-dependency', !checked);
|
||||
field.closest('tr').toggleClass('roi-field-dependency', !checked);
|
||||
field.prop('disabled', !checked);
|
||||
}).trigger('change');
|
||||
},
|
||||
@@ -403,7 +403,7 @@
|
||||
showNotice: function(type, message) {
|
||||
var notice = $('<div class="notice notice-' + type + ' is-dismissible"><p>' + message + '</p></div>');
|
||||
|
||||
$('.apus-theme-options h1').after(notice);
|
||||
$('.roi-theme-options h1').after(notice);
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
setTimeout(function() {
|
||||
@@ -431,10 +431,10 @@
|
||||
|
||||
// Initialize on document ready
|
||||
$(document).ready(function() {
|
||||
ApusThemeOptions.init();
|
||||
ROIThemeOptions.init();
|
||||
});
|
||||
|
||||
// Make it globally accessible
|
||||
window.ApusThemeOptions = ApusThemeOptions;
|
||||
window.ROIThemeOptions = ROIThemeOptions;
|
||||
|
||||
})(jQuery);
|
||||
|
||||
Reference in New Issue
Block a user