chore(php): remove temporary debug comments from content ad injector

This commit is contained in:
FrankZamora
2025-12-10 11:39:36 -06:00
parent 2cb7363cbb
commit 4f1e85fe88

View File

@@ -52,18 +52,11 @@ final class ContentAdInjector
// Determinar modo de operacion // Determinar modo de operacion
$mode = $this->settings['incontent_advanced']['incontent_mode'] ?? 'paragraphs_only'; $mode = $this->settings['incontent_advanced']['incontent_mode'] ?? 'paragraphs_only';
// DEBUG TEMPORAL: Insertar comentario HTML para diagnosticar
$debugComment = sprintf(
'<!-- ROI_AD_DEBUG: mode=%s, hasIncontentAdvanced=%s -->',
$mode,
isset($this->settings['incontent_advanced']) ? 'YES' : 'NO'
);
if ($mode === 'paragraphs_only') { if ($mode === 'paragraphs_only') {
return $debugComment . $this->injectParagraphsOnly($content); return $this->injectParagraphsOnly($content);
} }
return $debugComment . $this->injectAdvanced($content); return $this->injectAdvanced($content);
} }
/** /**
@@ -120,7 +113,6 @@ final class ContentAdInjector
private function injectAdvanced(string $content): string private function injectAdvanced(string $content): string
{ {
$config = $this->settings['incontent_advanced'] ?? []; $config = $this->settings['incontent_advanced'] ?? [];
$debugSteps = []; // DEBUG
// Obtener configuracion // Obtener configuracion
$maxAds = (int)($config['incontent_max_total_ads'] ?? 8); $maxAds = (int)($config['incontent_max_total_ads'] ?? 8);
@@ -128,31 +120,26 @@ final class ContentAdInjector
$priorityMode = $config['incontent_priority_mode'] ?? 'position'; $priorityMode = $config['incontent_priority_mode'] ?? 'position';
$format = $config['incontent_format'] ?? 'in-article'; $format = $config['incontent_format'] ?? 'in-article';
$debugSteps['config'] = "maxAds=$maxAds, minSpacing=$minSpacing, priority=$priorityMode"; // DEBUG
// PASO 1: Escanear contenido para encontrar todas las ubicaciones // PASO 1: Escanear contenido para encontrar todas las ubicaciones
$locations = $this->scanContent($content); $locations = $this->scanContent($content);
$debugSteps['step1_scan'] = count($locations); // DEBUG
if (empty($locations)) { if (empty($locations)) {
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content; return $content;
} }
// PASO 2: Filtrar por configuracion (enabled) // PASO 2: Filtrar por configuracion (enabled)
$locations = $this->filterByEnabled($locations, $config); $locations = $this->filterByEnabled($locations, $config);
$debugSteps['step2_enabled'] = count($locations); // DEBUG
if (empty($locations)) { if (empty($locations)) {
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content; return $content;
} }
// PASO 3: Aplicar probabilidad deterministica // PASO 3: Aplicar probabilidad deterministica
$postId = get_the_ID() ?: 0; $postId = get_the_ID() ?: 0;
$locations = $this->applyProbability($locations, $config, $postId); $locations = $this->applyProbability($locations, $config, $postId);
$debugSteps['step3_probability'] = count($locations); // DEBUG
if (empty($locations)) { if (empty($locations)) {
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content; return $content;
} }
// PASO 4-5: Filtrar por espaciado y limite (segun priority_mode) // PASO 4-5: Filtrar por espaciado y limite (segun priority_mode)
@@ -161,18 +148,13 @@ final class ContentAdInjector
} else { } else {
$locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds); $locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds);
} }
$debugSteps['step4_spacing'] = count($locations); // DEBUG
if (empty($locations)) { if (empty($locations)) {
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content; return $content;
} }
// Ordenar por posicion para insercion correcta // Ordenar por posicion para insercion correcta
usort($locations, fn($a, $b) => $a['position'] <=> $b['position']); usort($locations, fn($a, $b) => $a['position'] <=> $b['position']);
$debugSteps['final_ads'] = count($locations); // DEBUG
// Insertar debug comment
$content = '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
// PASO 6: Insertar anuncios // PASO 6: Insertar anuncios
return $this->insertAds($content, $locations, $format); return $this->insertAds($content, $locations, $format);