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:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Estilos base para el panel de administración
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
Container
|
||||
======================================== */
|
||||
|
||||
.apus-admin-panel {
|
||||
.roi-admin-panel {
|
||||
max-width: 1400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
@@ -20,11 +20,11 @@
|
||||
Header
|
||||
======================================== */
|
||||
|
||||
.apus-admin-panel h1 {
|
||||
.roi-admin-panel h1 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.apus-admin-panel .description {
|
||||
.roi-admin-panel .description {
|
||||
color: #666;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@@ -151,7 +151,7 @@
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 782px) {
|
||||
.apus-admin-panel {
|
||||
.roi-admin-panel {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
* Theme Options Admin Styles
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
/* Main Container */
|
||||
.apus-theme-options {
|
||||
.roi-theme-options {
|
||||
margin: 20px 20px 0 0;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.apus-options-header {
|
||||
.roi-options-header {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
padding: 20px;
|
||||
@@ -22,14 +22,14 @@
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.apus-options-logo h2 {
|
||||
.roi-options-logo h2 {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
color: #1d2327;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.apus-options-logo .version {
|
||||
.roi-options-logo .version {
|
||||
background: #2271b1;
|
||||
color: #fff;
|
||||
padding: 3px 8px;
|
||||
@@ -38,53 +38,53 @@
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.apus-options-actions {
|
||||
.roi-options-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.apus-options-actions .button .dashicons {
|
||||
.roi-options-actions .button .dashicons {
|
||||
margin-top: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* Form */
|
||||
.apus-options-form {
|
||||
.roi-options-form {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
/* Tabs Container */
|
||||
.apus-options-container {
|
||||
.roi-options-container {
|
||||
display: flex;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
/* Tabs Navigation */
|
||||
.apus-tabs-nav {
|
||||
.roi-tabs-nav {
|
||||
width: 200px;
|
||||
background: #f6f7f7;
|
||||
border-right: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav ul {
|
||||
.roi-tabs-nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li {
|
||||
.roi-tabs-nav li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li:first-child {
|
||||
.roi-tabs-nav li:first-child {
|
||||
border-top: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a {
|
||||
.roi-tabs-nav a {
|
||||
display: block;
|
||||
padding: 15px 20px;
|
||||
color: #50575e;
|
||||
@@ -93,21 +93,21 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a .dashicons {
|
||||
.roi-tabs-nav a .dashicons {
|
||||
margin-right: 8px;
|
||||
color: #787c82;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a:hover {
|
||||
.roi-tabs-nav a:hover {
|
||||
background: #fff;
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a:hover .dashicons {
|
||||
.roi-tabs-nav a:hover .dashicons {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a {
|
||||
.roi-tabs-nav li.active a {
|
||||
background: #fff;
|
||||
color: #2271b1;
|
||||
font-weight: 600;
|
||||
@@ -115,37 +115,37 @@
|
||||
padding-left: 17px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a .dashicons {
|
||||
.roi-tabs-nav li.active a .dashicons {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
/* Tabs Content */
|
||||
.apus-tabs-content {
|
||||
.roi-tabs-content {
|
||||
flex: 1;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.apus-tab-pane {
|
||||
.roi-tab-pane {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apus-tab-pane.active {
|
||||
.roi-tab-pane.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-tab-pane h2 {
|
||||
.roi-tab-pane h2 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 23px;
|
||||
font-weight: 400;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.apus-tab-pane > p.description {
|
||||
.roi-tab-pane > p.description {
|
||||
margin: 0 0 20px 0;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.apus-tab-pane h3 {
|
||||
.roi-tab-pane h3 {
|
||||
margin: 30px 0 0 0;
|
||||
padding: 15px 0 10px 0;
|
||||
border-top: 1px solid #dcdcde;
|
||||
@@ -153,34 +153,34 @@
|
||||
}
|
||||
|
||||
/* Form Table */
|
||||
.apus-tab-pane .form-table {
|
||||
.roi-tab-pane .form-table {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table th {
|
||||
.roi-tab-pane .form-table th {
|
||||
padding: 20px 10px 20px 0;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table td {
|
||||
.roi-tab-pane .form-table td {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
|
||||
/* Toggle Switch */
|
||||
.apus-switch {
|
||||
.roi-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.apus-switch input {
|
||||
.roi-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.apus-slider {
|
||||
.roi-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
@@ -192,7 +192,7 @@
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.apus-slider:before {
|
||||
.roi-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 18px;
|
||||
@@ -204,24 +204,24 @@
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .apus-slider {
|
||||
input:checked + .roi-slider {
|
||||
background-color: #2271b1;
|
||||
}
|
||||
|
||||
input:focus + .apus-slider {
|
||||
input:focus + .roi-slider {
|
||||
box-shadow: 0 0 1px #2271b1;
|
||||
}
|
||||
|
||||
input:checked + .apus-slider:before {
|
||||
input:checked + .roi-slider:before {
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
/* Image Upload */
|
||||
.apus-image-upload {
|
||||
.roi-image-upload {
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.apus-image-preview {
|
||||
.roi-image-preview {
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #c3c4c7;
|
||||
background: #f6f7f7;
|
||||
@@ -232,23 +232,23 @@ input:checked + .apus-slider:before {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.apus-image-preview:empty {
|
||||
.roi-image-preview:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apus-preview-image {
|
||||
.roi-preview-image {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-upload-image,
|
||||
.apus-remove-image {
|
||||
.roi-upload-image,
|
||||
.roi-remove-image {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* Submit Button */
|
||||
.apus-options-form .submit {
|
||||
.roi-options-form .submit {
|
||||
margin: 0;
|
||||
padding: 20px 30px;
|
||||
border-top: 1px solid #c3c4c7;
|
||||
@@ -256,7 +256,7 @@ input:checked + .apus-slider:before {
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.apus-modal {
|
||||
.roi-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 100000;
|
||||
@@ -268,7 +268,7 @@ input:checked + .apus-slider:before {
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.apus-modal-content {
|
||||
.roi-modal-content {
|
||||
background-color: #fff;
|
||||
margin: 10% auto;
|
||||
padding: 30px;
|
||||
@@ -279,7 +279,7 @@ input:checked + .apus-slider:before {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.apus-modal-close {
|
||||
.roi-modal-close {
|
||||
color: #646970;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
@@ -288,22 +288,22 @@ input:checked + .apus-slider:before {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.apus-modal-close:hover,
|
||||
.apus-modal-close:focus {
|
||||
.roi-modal-close:hover,
|
||||
.roi-modal-close:focus {
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.apus-modal-content h2 {
|
||||
.roi-modal-content h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.apus-modal-content textarea {
|
||||
.roi-modal-content textarea {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Notices */
|
||||
.apus-notice {
|
||||
.roi-notice {
|
||||
padding: 12px;
|
||||
margin: 20px 0;
|
||||
border-left: 4px solid;
|
||||
@@ -311,19 +311,19 @@ input:checked + .apus-slider:before {
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.apus-notice.success {
|
||||
.roi-notice.success {
|
||||
border-left-color: #00a32a;
|
||||
}
|
||||
|
||||
.apus-notice.error {
|
||||
.roi-notice.error {
|
||||
border-left-color: #d63638;
|
||||
}
|
||||
|
||||
.apus-notice.warning {
|
||||
.roi-notice.warning {
|
||||
border-left-color: #dba617;
|
||||
}
|
||||
|
||||
.apus-notice.info {
|
||||
.roi-notice.info {
|
||||
border-left-color: #2271b1;
|
||||
}
|
||||
|
||||
@@ -336,109 +336,109 @@ textarea.code {
|
||||
|
||||
/* Responsive */
|
||||
@media screen and (max-width: 782px) {
|
||||
.apus-options-container {
|
||||
.roi-options-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.apus-tabs-nav {
|
||||
.roi-tabs-nav {
|
||||
width: 100%;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav ul {
|
||||
.roi-tabs-nav ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li {
|
||||
.roi-tabs-nav li {
|
||||
flex: 1;
|
||||
min-width: 50%;
|
||||
border-right: 1px solid #c3c4c7;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li:first-child {
|
||||
.roi-tabs-nav li:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a {
|
||||
.roi-tabs-nav a {
|
||||
text-align: center;
|
||||
padding: 12px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a .dashicons {
|
||||
.roi-tabs-nav a .dashicons {
|
||||
display: block;
|
||||
margin: 0 auto 5px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a {
|
||||
.roi-tabs-nav li.active a {
|
||||
border-left: none;
|
||||
border-bottom: 3px solid #2271b1;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.apus-tabs-content {
|
||||
.roi-tabs-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.apus-options-header {
|
||||
.roi-options-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.apus-options-actions {
|
||||
.roi-options-actions {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.apus-options-actions .button {
|
||||
.roi-options-actions .button {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table th {
|
||||
.roi-tab-pane .form-table th {
|
||||
width: auto;
|
||||
padding: 15px 10px 5px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table td {
|
||||
.roi-tab-pane .form-table td {
|
||||
display: block;
|
||||
padding: 5px 10px 15px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loading Spinner */
|
||||
.apus-spinner {
|
||||
.roi-spinner {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(0,0,0,.1);
|
||||
border-radius: 50%;
|
||||
border-top-color: #2271b1;
|
||||
animation: apus-spin 1s ease-in-out infinite;
|
||||
animation: roispin 1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes apus-spin {
|
||||
@keyframes roispin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Helper Classes */
|
||||
.apus-hidden {
|
||||
.roi-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.apus-text-center {
|
||||
.roi-text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.apus-mt-20 {
|
||||
.roi-mt-20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.apus-mb-20 {
|
||||
.roi-mb-20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@@ -448,13 +448,13 @@ textarea.code {
|
||||
}
|
||||
|
||||
/* Field Dependencies */
|
||||
.apus-field-dependency {
|
||||
.roi-field-dependency {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Success Animation */
|
||||
@keyframes apus-saved {
|
||||
@keyframes roisaved {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
@@ -466,6 +466,6 @@ textarea.code {
|
||||
}
|
||||
}
|
||||
|
||||
.apus-saved {
|
||||
animation: apus-saved 0.3s ease-in-out;
|
||||
.roi-saved {
|
||||
animation: roisaved 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Gestión de configuraciones de componentes del tema
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @package ROI_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
@@ -92,10 +92,10 @@ const AdminPanel = {
|
||||
try {
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: apusAdminData.ajaxUrl,
|
||||
url: roiAdminData.ajaxUrl,
|
||||
data: new URLSearchParams({
|
||||
action: 'apus_get_settings',
|
||||
nonce: apusAdminData.nonce
|
||||
action: 'roi_get_settings',
|
||||
nonce: roiAdminData.nonce
|
||||
})
|
||||
});
|
||||
|
||||
@@ -130,15 +130,15 @@ const AdminPanel = {
|
||||
|
||||
// Crear FormData para WordPress AJAX
|
||||
const postData = new URLSearchParams();
|
||||
postData.append('action', 'apus_save_settings');
|
||||
postData.append('nonce', apusAdminData.nonce);
|
||||
postData.append('action', 'roi_save_settings');
|
||||
postData.append('nonce', roiAdminData.nonce);
|
||||
|
||||
// Agregar components como JSON string
|
||||
postData.append('components', JSON.stringify(formData.components));
|
||||
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: apusAdminData.ajaxUrl,
|
||||
url: roiAdminData.ajaxUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
@@ -201,7 +201,7 @@ const AdminPanel = {
|
||||
noticeDiv.className = `notice notice-${type} is-dismissible`;
|
||||
noticeDiv.innerHTML = `<p>${message}</p>`;
|
||||
|
||||
const container = document.querySelector('.apus-admin-panel');
|
||||
const container = document.querySelector('.roi-admin-panel');
|
||||
if (container) {
|
||||
container.insertBefore(noticeDiv, container.firstChild);
|
||||
|
||||
|
||||
@@ -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