diff --git a/Inc/adsense-placement.php b/Inc/adsense-placement.php index f9e29bac..6ef46e9c 100644 --- a/Inc/adsense-placement.php +++ b/Inc/adsense-placement.php @@ -97,6 +97,9 @@ function roi_render_rail_ads(): string global $container; if ($container === null) { + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: container is NULL'); + } return ''; } @@ -105,22 +108,34 @@ function roi_render_rail_ads(): string $settings = $repository->getComponentSettings('adsense-placement'); if (empty($settings)) { + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: settings are EMPTY'); + } return ''; } // Verificar exclusiones if (roi_is_ad_excluded($settings)) { + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: EXCLUDED by roi_is_ad_excluded'); + } return ''; } // Obtener renderer desde DIContainer (DIP compliant) $renderer = $container->getAdsensePlacementRenderer(); - return $renderer->renderRailAds($settings); + $html = $renderer->renderRailAds($settings); + + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: renderRailAds returned ' . strlen($html) . ' chars'); + } + + return $html; } catch (\Throwable $e) { if (defined('WP_DEBUG') && WP_DEBUG) { - error_log('ROI AdSense Rail Ads: ' . $e->getMessage()); + error_log('ROI AdSense Rail Ads ERROR: ' . $e->getMessage()); } return ''; } @@ -130,8 +145,19 @@ function roi_render_rail_ads(): string * Hook para inyectar Rail Ads en el footer */ add_action('wp_footer', function() { + // DEBUG: Verificar que el hook se ejecuta + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: wp_footer hook fired'); + } + + $output = roi_render_rail_ads(); + + if (defined('WP_DEBUG') && WP_DEBUG) { + error_log('ROI Rail Ads: output length = ' . strlen($output)); + } + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - echo roi_render_rail_ads(); + echo $output; }, 50); /**