diff --git a/Admin/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarFormBuilder.php b/Admin/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarFormBuilder.php index 5cb18c47..781973a8 100644 --- a/Admin/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarFormBuilder.php +++ b/Admin/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarFormBuilder.php @@ -138,6 +138,20 @@ final class CtaBoxSidebarFormBuilder $exclusionPartial = new ExclusionFormPartial($this->renderer); $html .= $exclusionPartial->render($componentId, 'cta'); + // Switch: Ocultar para usuarios logueados (Plan 99.16) + $hideForLoggedIn = $this->renderer->getFieldValue($componentId, 'visibility', 'hide_for_logged_in', false); + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= ' '; + $html .= '
'; + $html .= '
'; + $html .= ' '; $html .= ''; diff --git a/Admin/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkFormBuilder.php b/Admin/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkFormBuilder.php index b56ed5d0..c8cc9054 100644 --- a/Admin/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkFormBuilder.php +++ b/Admin/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkFormBuilder.php @@ -162,6 +162,34 @@ final class CtaLetsTalkFormBuilder $exclusionPartial = new ExclusionFormPartial($this->renderer); $html .= $exclusionPartial->render($componentId, 'letsTalk'); + // Switch: CSS Crítico + $isCritical = $this->renderer->getFieldValue($componentId, 'visibility', 'is_critical', true); + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= ' '; + $html .= '
'; + $html .= '
'; + + // Switch: Ocultar para usuarios logueados (Plan 99.16) + $hideForLoggedIn = $this->renderer->getFieldValue($componentId, 'visibility', 'hide_for_logged_in', false); + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= ' '; + $html .= '
'; + $html .= '
'; + $html .= ' '; $html .= ''; diff --git a/Admin/CtaPost/Infrastructure/Ui/CtaPostFormBuilder.php b/Admin/CtaPost/Infrastructure/Ui/CtaPostFormBuilder.php index 91584103..d722a7f0 100644 --- a/Admin/CtaPost/Infrastructure/Ui/CtaPostFormBuilder.php +++ b/Admin/CtaPost/Infrastructure/Ui/CtaPostFormBuilder.php @@ -127,6 +127,20 @@ final class CtaPostFormBuilder $exclusionPartial = new ExclusionFormPartial($this->renderer); $html .= $exclusionPartial->render($componentId, 'ctaPost'); + // Switch: Ocultar para usuarios logueados (Plan 99.16) + $hideForLoggedIn = $this->renderer->getFieldValue($componentId, 'visibility', 'hide_for_logged_in', false); + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= ' '; + $html .= '
'; + $html .= '
'; + $html .= ' '; $html .= ''; diff --git a/Admin/TopNotificationBar/Infrastructure/Ui/TopNotificationBarFormBuilder.php b/Admin/TopNotificationBar/Infrastructure/Ui/TopNotificationBarFormBuilder.php index 4a3f3d21..8780f1d5 100644 --- a/Admin/TopNotificationBar/Infrastructure/Ui/TopNotificationBarFormBuilder.php +++ b/Admin/TopNotificationBar/Infrastructure/Ui/TopNotificationBarFormBuilder.php @@ -149,7 +149,7 @@ final class TopNotificationBarFormBuilder // Switch: CSS Crítico $isCritical = $this->renderer->getFieldValue($componentId, 'visibility', 'is_critical', true); - $html .= '
'; + $html .= '
'; $html .= '
'; $html .= ' '; @@ -161,6 +161,20 @@ final class TopNotificationBarFormBuilder $html .= '
'; $html .= '
'; + // Switch: Ocultar para usuarios logueados (Plan 99.16) + $hideForLoggedIn = $this->renderer->getFieldValue($componentId, 'visibility', 'hide_for_logged_in', false); + $html .= '
'; + $html .= '
'; + $html .= ' '; + $html .= ' '; + $html .= '
'; + $html .= '
'; + $html .= '
'; $html .= ''; diff --git a/Inc/adsense-placement.php b/Inc/adsense-placement.php index e55d45be..c39b83e3 100644 --- a/Inc/adsense-placement.php +++ b/Inc/adsense-placement.php @@ -26,6 +26,7 @@ if (!defined('ABSPATH')) { } use ROITheme\Shared\Infrastructure\Services\PageVisibilityHelper; +use ROITheme\Shared\Infrastructure\Services\UserVisibilityHelper; /** * Renderiza un slot de anuncio en una ubicacion @@ -49,8 +50,8 @@ function roi_render_ad_slot(string $location): string return ''; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return ''; } @@ -79,17 +80,17 @@ function roi_render_ad_slot(string $location): string /** * Verifica si se deben ocultar anuncios para usuarios logueados + * + * @deprecated Plan 99.16: Usar UserVisibilityHelper::shouldShowForUser() en su lugar. + * Esta función se mantiene para compatibilidad hacia atrás. + * + * @param array $settings Configuración del componente + * @return bool true si se debe ocultar, false si se debe mostrar */ function roi_should_hide_for_logged_in(array $settings): bool { - // Si la opcion esta activada Y el usuario esta logueado, ocultar ads - $hideForLoggedIn = $settings['visibility']['hide_for_logged_in'] ?? false; - - if ($hideForLoggedIn && is_user_logged_in()) { - return true; - } - - return false; + // Delegar a UserVisibilityHelper (Plan 99.16) + return !UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? []); } /** @@ -145,8 +146,8 @@ function roi_render_rail_ads(): string return ''; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return ''; } @@ -200,8 +201,8 @@ function roi_enqueue_adsense_script(): void return; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return; } @@ -258,8 +259,8 @@ function roi_inject_content_ads(string $content): string return $content; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return $content; } @@ -463,8 +464,8 @@ function roi_render_anchor_ads(): string return ''; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return ''; } @@ -512,8 +513,8 @@ function roi_render_vignette_ad(): string return ''; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return ''; } @@ -583,8 +584,8 @@ function roi_enqueue_anchor_vignette_scripts(): void return; } - // Verificar si ocultar para usuarios logueados - if (roi_should_hide_for_logged_in($settings)) { + // Verificar visibilidad por usuario logueado (Plan 99.16) + if (!UserVisibilityHelper::shouldShowForUser($settings['visibility'] ?? [])) { return; } diff --git a/Public/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarRenderer.php b/Public/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarRenderer.php index 42b847a5..a8eca9b7 100644 --- a/Public/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarRenderer.php +++ b/Public/CtaBoxSidebar/Infrastructure/Ui/CtaBoxSidebarRenderer.php @@ -7,6 +7,7 @@ use ROITheme\Shared\Domain\Contracts\RendererInterface; use ROITheme\Shared\Domain\Contracts\CSSGeneratorInterface; use ROITheme\Shared\Domain\Entities\Component; use ROITheme\Shared\Infrastructure\Services\PageVisibilityHelper; +use ROITheme\Shared\Infrastructure\Services\UserVisibilityHelper; /** * CtaBoxSidebarRenderer - Renderiza caja CTA en sidebar @@ -51,6 +52,11 @@ final class CtaBoxSidebarRenderer implements RendererInterface return ''; } + // Validar visibilidad por usuario logueado + if (!UserVisibilityHelper::shouldShowForUser($data['visibility'] ?? [])) { + return ''; + } + $css = $this->generateCSS($data); $html = $this->buildHTML($data); $script = $this->buildScript(); diff --git a/Public/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkRenderer.php b/Public/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkRenderer.php index d4b238fd..38f8dbbb 100644 --- a/Public/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkRenderer.php +++ b/Public/CtaLetsTalk/Infrastructure/Ui/CtaLetsTalkRenderer.php @@ -7,6 +7,7 @@ use ROITheme\Shared\Domain\Contracts\RendererInterface; use ROITheme\Shared\Domain\Contracts\CSSGeneratorInterface; use ROITheme\Shared\Domain\Entities\Component; use ROITheme\Shared\Infrastructure\Services\PageVisibilityHelper; +use ROITheme\Shared\Infrastructure\Services\UserVisibilityHelper; /** * Class CtaLetsTalkRenderer @@ -61,6 +62,11 @@ final class CtaLetsTalkRenderer implements RendererInterface return ''; } + // Validar visibilidad por usuario logueado + if (!UserVisibilityHelper::shouldShowForUser($data['visibility'] ?? [])) { + return ''; + } + // Generar CSS usando CSSGeneratorService $css = $this->generateCSS($data); diff --git a/Public/CtaPost/Infrastructure/Ui/CtaPostRenderer.php b/Public/CtaPost/Infrastructure/Ui/CtaPostRenderer.php index 9982b72a..b967b550 100644 --- a/Public/CtaPost/Infrastructure/Ui/CtaPostRenderer.php +++ b/Public/CtaPost/Infrastructure/Ui/CtaPostRenderer.php @@ -7,6 +7,7 @@ use ROITheme\Shared\Domain\Contracts\RendererInterface; use ROITheme\Shared\Domain\Contracts\CSSGeneratorInterface; use ROITheme\Shared\Domain\Entities\Component; use ROITheme\Shared\Infrastructure\Services\PageVisibilityHelper; +use ROITheme\Shared\Infrastructure\Services\UserVisibilityHelper; /** * CtaPostRenderer - Renderiza CTA promocional debajo del contenido @@ -41,6 +42,11 @@ final class CtaPostRenderer implements RendererInterface return ''; } + // Validar visibilidad por usuario logueado + if (!UserVisibilityHelper::shouldShowForUser($data['visibility'] ?? [])) { + return ''; + } + $css = $this->generateCSS($data); $html = $this->buildHTML($data); diff --git a/Public/TopNotificationBar/Infrastructure/Ui/TopNotificationBarRenderer.php b/Public/TopNotificationBar/Infrastructure/Ui/TopNotificationBarRenderer.php index fa25e9cc..89e5749a 100644 --- a/Public/TopNotificationBar/Infrastructure/Ui/TopNotificationBarRenderer.php +++ b/Public/TopNotificationBar/Infrastructure/Ui/TopNotificationBarRenderer.php @@ -7,6 +7,7 @@ use ROITheme\Shared\Domain\Contracts\RendererInterface; use ROITheme\Shared\Domain\Contracts\CSSGeneratorInterface; use ROITheme\Shared\Domain\Entities\Component; use ROITheme\Shared\Infrastructure\Services\PageVisibilityHelper; +use ROITheme\Shared\Infrastructure\Services\UserVisibilityHelper; /** * Class TopNotificationBarRenderer @@ -61,6 +62,11 @@ final class TopNotificationBarRenderer implements RendererInterface return ''; } + // Validar visibilidad por usuario logueado + if (!UserVisibilityHelper::shouldShowForUser($data['visibility'] ?? [])) { + return ''; + } + // Generar HTML $html = $this->buildHTML($data); diff --git a/Schemas/cta-box-sidebar.json b/Schemas/cta-box-sidebar.json index 957c5e2a..d4d19d29 100644 --- a/Schemas/cta-box-sidebar.json +++ b/Schemas/cta-box-sidebar.json @@ -27,6 +27,13 @@ "default": false, "editable": true, "description": "Muestra el componente en pantallas < 992px" + }, + "hide_for_logged_in": { + "type": "boolean", + "label": "Ocultar para usuarios logueados", + "default": false, + "editable": true, + "description": "No mostrar el CTA a usuarios con sesión iniciada en WordPress" } } }, diff --git a/Schemas/cta-lets-talk.json b/Schemas/cta-lets-talk.json index 7f7aef0a..4d741135 100644 --- a/Schemas/cta-lets-talk.json +++ b/Schemas/cta-lets-talk.json @@ -35,6 +35,13 @@ "default": true, "editable": true, "description": "Inyectar CSS inline en para optimizar LCP (componente above-the-fold)" + }, + "hide_for_logged_in": { + "type": "boolean", + "label": "Ocultar para usuarios logueados", + "default": false, + "editable": true, + "description": "No mostrar el botón a usuarios con sesión iniciada en WordPress" } } }, diff --git a/Schemas/cta-post.json b/Schemas/cta-post.json index 4d6d0034..01439538 100644 --- a/Schemas/cta-post.json +++ b/Schemas/cta-post.json @@ -27,6 +27,13 @@ "default": true, "editable": true, "description": "Muestra el componente en pantallas < 992px" + }, + "hide_for_logged_in": { + "type": "boolean", + "label": "Ocultar para usuarios logueados", + "default": false, + "editable": true, + "description": "No mostrar el CTA a usuarios con sesión iniciada en WordPress" } } }, diff --git a/Schemas/top-notification-bar.json b/Schemas/top-notification-bar.json index 049075e8..b22d2de3 100644 --- a/Schemas/top-notification-bar.json +++ b/Schemas/top-notification-bar.json @@ -37,6 +37,13 @@ "default": true, "editable": true, "description": "Inyectar CSS inline en para optimizar LCP (componente above-the-fold)" + }, + "hide_for_logged_in": { + "type": "boolean", + "label": "Ocultar para usuarios logueados", + "default": false, + "editable": true, + "description": "No mostrar la barra a usuarios con sesión iniciada en WordPress" } } }, diff --git a/Shared/Infrastructure/Services/UserVisibilityHelper.php b/Shared/Infrastructure/Services/UserVisibilityHelper.php new file mode 100644 index 00000000..a2c246bd --- /dev/null +++ b/Shared/Infrastructure/Services/UserVisibilityHelper.php @@ -0,0 +1,35 @@ +