From 8bbbf484bdf0035062a58d2c9e82fe6bd01ff74a Mon Sep 17 00:00:00 2001 From: FrankZamora Date: Wed, 10 Dec 2025 12:30:27 -0600 Subject: [PATCH] chore(php): add temporary debug to content ad injector --- .../Services/ContentAdInjector.php | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Public/AdsensePlacement/Infrastructure/Services/ContentAdInjector.php b/Public/AdsensePlacement/Infrastructure/Services/ContentAdInjector.php index f08c37a4..eb1419c5 100644 --- a/Public/AdsensePlacement/Infrastructure/Services/ContentAdInjector.php +++ b/Public/AdsensePlacement/Infrastructure/Services/ContentAdInjector.php @@ -43,20 +43,24 @@ final class ContentAdInjector */ public function inject(string $content): string { + // DEBUG TEMPORAL + $debug = ''; + // PASO 0: Validar longitud minima (aplica a todos los modos) $minLength = (int)($this->settings['forms']['min_content_length'] ?? 500); if (strlen(strip_tags($content)) < $minLength) { - return $content; + return $debug . '' . $content; } // Determinar modo de operacion $mode = $this->settings['incontent_advanced']['incontent_mode'] ?? 'paragraphs_only'; + $debug .= ''; if ($mode === 'paragraphs_only') { - return $this->injectParagraphsOnly($content); + return $debug . $this->injectParagraphsOnly($content); } - return $this->injectAdvanced($content); + return $debug . $this->injectAdvanced($content); } /** @@ -113,33 +117,38 @@ final class ContentAdInjector private function injectAdvanced(string $content): string { $config = $this->settings['incontent_advanced'] ?? []; + $debug = ''; // Obtener configuracion $maxAds = (int)($config['incontent_max_total_ads'] ?? 8); $minSpacing = (int)($config['incontent_min_spacing'] ?? 3); $priorityMode = $config['incontent_priority_mode'] ?? 'position'; $format = $config['incontent_format'] ?? 'in-article'; + $debug .= ''; // PASO 1: Escanear contenido para encontrar todas las ubicaciones $locations = $this->scanContent($content); + $debug .= ''; if (empty($locations)) { - return $content; + return $debug . '' . $content; } // PASO 2: Filtrar por configuracion (enabled) $locations = $this->filterByEnabled($locations, $config); + $debug .= ''; if (empty($locations)) { - return $content; + return $debug . '' . $content; } // PASO 3: Aplicar probabilidad deterministica $postId = get_the_ID() ?: 0; $locations = $this->applyProbability($locations, $config, $postId); + $debug .= ''; if (empty($locations)) { - return $content; + return $debug . '' . $content; } // PASO 4-5: Filtrar por espaciado y limite (segun priority_mode) @@ -148,16 +157,19 @@ final class ContentAdInjector } else { $locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds); } + $debug .= ''; if (empty($locations)) { - return $content; + return $debug . '' . $content; } // Ordenar por posicion para insercion correcta usort($locations, fn($a, $b) => $a['position'] <=> $b['position']); + $debug .= ''; + // PASO 6: Insertar anuncios - return $this->insertAds($content, $locations, $format); + return $debug . $this->insertAds($content, $locations, $format); } /**