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>
258 lines
9.7 KiB
PHP
258 lines
9.7 KiB
PHP
<?php
|
|
/**
|
|
* CTA A/B Testing Customizer Settings
|
|
*
|
|
* Opciones del panel de personalización para configurar
|
|
* las dos variantes del CTA (A y B).
|
|
*
|
|
* @package ROI_Theme
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Registrar configuraciones del CTA en el Customizer
|
|
*/
|
|
function roi_customize_cta($wp_customize) {
|
|
// Agregar sección para CTA A/B Testing
|
|
$wp_customize->add_section('roi_cta', array(
|
|
'title' => __('CTA A/B Testing', 'roi-theme'),
|
|
'description' => __('Configura las dos variantes del Call-to-Action que se mostrarán aleatoriamente. El sistema asignará automáticamente una variante a cada usuario (50/50).', 'roi-theme'),
|
|
'priority' => 132,
|
|
));
|
|
|
|
// =====================================================
|
|
// CONFIGURACIÓN GENERAL
|
|
// =====================================================
|
|
|
|
// Habilitar/Deshabilitar CTA
|
|
$wp_customize->add_setting('roi_enable_cta', array(
|
|
'default' => true,
|
|
'sanitize_callback' => 'roi_sanitize_checkbox',
|
|
'transport' => 'refresh',
|
|
));
|
|
$wp_customize->add_control('roi_enable_cta', array(
|
|
'label' => __('Habilitar CTA con A/B Testing', 'roi-theme'),
|
|
'description' => __('Muestra un Call-to-Action en los posts individuales con dos variantes aleatorias.', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// Auto-insertar CTA (opcional, por defecto usar template tag)
|
|
$wp_customize->add_setting('roi_cta_auto_insert', array(
|
|
'default' => false,
|
|
'sanitize_callback' => 'roi_sanitize_checkbox',
|
|
'transport' => 'refresh',
|
|
));
|
|
$wp_customize->add_control('roi_cta_auto_insert', array(
|
|
'label' => __('Auto-insertar CTA después del contenido', 'roi-theme'),
|
|
'description' => __('Si está desactivado, usa el template tag roi_display_cta() manualmente.', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'checkbox',
|
|
));
|
|
|
|
// =====================================================
|
|
// VARIANTE A - ENFOQUE EN CATÁLOGO
|
|
// =====================================================
|
|
|
|
// Separador visual
|
|
$wp_customize->add_setting('roi_cta_a_separator', array(
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
));
|
|
$wp_customize->add_control(new WP_Customize_Control(
|
|
$wp_customize,
|
|
'roi_cta_a_separator',
|
|
array(
|
|
'label' => __('━━━ Variante A: Catálogo ━━━', 'roi-theme'),
|
|
'description' => __('Enfoque en acceso al catálogo de 200,000+ APUs', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'hidden',
|
|
)
|
|
));
|
|
|
|
// Título Variante A
|
|
$wp_customize->add_setting('roi_cta_a_title', array(
|
|
'default' => __('Accede a 200,000+ Análisis de Precios Unitarios', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_a_title', array(
|
|
'label' => __('Título', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// Texto Variante A
|
|
$wp_customize->add_setting('roi_cta_a_text', array(
|
|
'default' => __('Consulta estructuras completas, insumos y dosificaciones de los APUs más utilizados en construcción en México.', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_a_text', array(
|
|
'label' => __('Texto descriptivo', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'textarea',
|
|
));
|
|
|
|
// Botón Variante A
|
|
$wp_customize->add_setting('roi_cta_a_button', array(
|
|
'default' => __('Ver Catálogo Completo', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_a_button', array(
|
|
'label' => __('Texto del botón', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// URL Variante A
|
|
$wp_customize->add_setting('roi_cta_a_url', array(
|
|
'default' => '#',
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_a_url', array(
|
|
'label' => __('URL del botón', 'roi-theme'),
|
|
'description' => __('Ejemplo: /catalogo-completo/ o una URL completa', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'url',
|
|
));
|
|
|
|
// =====================================================
|
|
// VARIANTE B - ENFOQUE EN MEMBRESÍA
|
|
// =====================================================
|
|
|
|
// Separador visual
|
|
$wp_customize->add_setting('roi_cta_b_separator', array(
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
));
|
|
$wp_customize->add_control(new WP_Customize_Control(
|
|
$wp_customize,
|
|
'roi_cta_b_separator',
|
|
array(
|
|
'label' => __('━━━ Variante B: Membresía ━━━', 'roi-theme'),
|
|
'description' => __('Enfoque en planes de membresía y acceso premium', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'hidden',
|
|
)
|
|
));
|
|
|
|
// Título Variante B
|
|
$wp_customize->add_setting('roi_cta_b_title', array(
|
|
'default' => __('¿Necesitas Consultar Más APUs?', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_b_title', array(
|
|
'label' => __('Título', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// Texto Variante B
|
|
$wp_customize->add_setting('roi_cta_b_text', array(
|
|
'default' => __('Accede a nuestra biblioteca de 200,000 análisis de precios unitarios con estructuras detalladas y listados de insumos.', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_b_text', array(
|
|
'label' => __('Texto descriptivo', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'textarea',
|
|
));
|
|
|
|
// Botón Variante B
|
|
$wp_customize->add_setting('roi_cta_b_button', array(
|
|
'default' => __('Conocer Planes de Membresía', 'roi-theme'),
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_b_button', array(
|
|
'label' => __('Texto del botón', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'text',
|
|
));
|
|
|
|
// URL Variante B
|
|
$wp_customize->add_setting('roi_cta_b_url', array(
|
|
'default' => '#',
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
'transport' => 'postMessage',
|
|
));
|
|
$wp_customize->add_control('roi_cta_b_url', array(
|
|
'label' => __('URL del botón', 'roi-theme'),
|
|
'description' => __('Ejemplo: /planes-de-membresia/ o una URL completa', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'url',
|
|
));
|
|
|
|
// =====================================================
|
|
// GOOGLE ANALYTICS TRACKING
|
|
// =====================================================
|
|
|
|
// Separador visual
|
|
$wp_customize->add_setting('roi_cta_ga_separator', array(
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
));
|
|
$wp_customize->add_control(new WP_Customize_Control(
|
|
$wp_customize,
|
|
'roi_cta_ga_separator',
|
|
array(
|
|
'label' => __('━━━ Google Analytics ━━━', 'roi-theme'),
|
|
'description' => __('Configuración para tracking de conversiones', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'hidden',
|
|
)
|
|
));
|
|
|
|
// Google Analytics Tracking ID
|
|
$wp_customize->add_setting('roi_ga_tracking_id', array(
|
|
'default' => '',
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
'transport' => 'refresh',
|
|
));
|
|
$wp_customize->add_control('roi_ga_tracking_id', array(
|
|
'label' => __('Google Analytics Tracking ID', 'roi-theme'),
|
|
'description' => __('Formato: G-XXXXXXXXXX (GA4) o UA-XXXXXXXXX-X (Universal Analytics). Déjalo vacío si ya tienes GA instalado mediante plugin.', 'roi-theme'),
|
|
'section' => 'roi_cta',
|
|
'type' => 'text',
|
|
));
|
|
}
|
|
add_action('customize_register', 'roi_customize_cta');
|
|
|
|
/**
|
|
* Agregar script de Google Analytics en el header si está configurado
|
|
*/
|
|
function roi_output_google_analytics() {
|
|
$tracking_id = get_theme_mod('roi_ga_tracking_id', '');
|
|
|
|
// No mostrar si está vacío o si estamos en el admin
|
|
if (empty($tracking_id) || is_admin()) {
|
|
return;
|
|
}
|
|
|
|
// No mostrar si es un usuario admin logueado
|
|
if (current_user_can('manage_options')) {
|
|
return;
|
|
}
|
|
?>
|
|
<!-- Google Analytics (CTA A/B Testing) -->
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_attr($tracking_id); ?>"></script>
|
|
<script>
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
gtag('config', '<?php echo esc_js($tracking_id); ?>', {
|
|
'anonymize_ip': true,
|
|
'cookie_flags': 'SameSite=None;Secure'
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
add_action('wp_head', 'roi_output_google_analytics', 1);
|