chore(php): remove temporary debug comments from content ad injector
This commit is contained in:
@@ -52,18 +52,11 @@ final class ContentAdInjector
|
||||
// Determinar modo de operacion
|
||||
$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') {
|
||||
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
|
||||
{
|
||||
$config = $this->settings['incontent_advanced'] ?? [];
|
||||
$debugSteps = []; // DEBUG
|
||||
|
||||
// Obtener configuracion
|
||||
$maxAds = (int)($config['incontent_max_total_ads'] ?? 8);
|
||||
@@ -128,31 +120,26 @@ final class ContentAdInjector
|
||||
$priorityMode = $config['incontent_priority_mode'] ?? 'position';
|
||||
$format = $config['incontent_format'] ?? 'in-article';
|
||||
|
||||
$debugSteps['config'] = "maxAds=$maxAds, minSpacing=$minSpacing, priority=$priorityMode"; // DEBUG
|
||||
|
||||
// PASO 1: Escanear contenido para encontrar todas las ubicaciones
|
||||
$locations = $this->scanContent($content);
|
||||
$debugSteps['step1_scan'] = count($locations); // DEBUG
|
||||
|
||||
if (empty($locations)) {
|
||||
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
// PASO 2: Filtrar por configuracion (enabled)
|
||||
$locations = $this->filterByEnabled($locations, $config);
|
||||
$debugSteps['step2_enabled'] = count($locations); // DEBUG
|
||||
|
||||
if (empty($locations)) {
|
||||
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
// PASO 3: Aplicar probabilidad deterministica
|
||||
$postId = get_the_ID() ?: 0;
|
||||
$locations = $this->applyProbability($locations, $config, $postId);
|
||||
$debugSteps['step3_probability'] = count($locations); // DEBUG
|
||||
|
||||
if (empty($locations)) {
|
||||
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
// PASO 4-5: Filtrar por espaciado y limite (segun priority_mode)
|
||||
@@ -161,18 +148,13 @@ final class ContentAdInjector
|
||||
} else {
|
||||
$locations = $this->filterByPositionFirst($locations, $minSpacing, $maxAds);
|
||||
}
|
||||
$debugSteps['step4_spacing'] = count($locations); // DEBUG
|
||||
|
||||
if (empty($locations)) {
|
||||
return '<!-- ROI_ADV_DEBUG: ' . json_encode($debugSteps) . ' -->' . $content;
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Ordenar por posicion para insercion correcta
|
||||
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
|
||||
return $this->insertAds($content, $locations, $format);
|
||||
|
||||
Reference in New Issue
Block a user