settings['behavior']['post_content_enabled'] ?? false)) { return $content; } // Verificar longitud minima $minLength = (int)($this->settings['forms']['min_content_length'] ?? 500); if (strlen(strip_tags($content)) < $minLength) { return $content; } $afterParagraphs = (int)($this->settings['behavior']['post_content_after_paragraphs'] ?? 3); $maxAds = (int)($this->settings['behavior']['post_content_max_ads'] ?? 2); // Dividir contenido en parrafos $paragraphs = explode('

', $content); $totalParagraphs = count($paragraphs); if ($totalParagraphs < $afterParagraphs + 1) { return $content; } $adsInserted = 0; $newContent = ''; foreach ($paragraphs as $index => $paragraph) { $newContent .= $paragraph; if ($index < $totalParagraphs - 1) { $newContent .= '

'; } $paragraphNumber = $index + 1; // Primer anuncio despues del parrafo indicado if ($paragraphNumber === $afterParagraphs && $adsInserted < $maxAds) { $newContent .= $this->renderer->renderSlot($this->settings, 'post-content-' . ($adsInserted + 1)); $adsInserted++; } // Segundo anuncio a mitad del contenido restante $midPoint = $afterParagraphs + (int)(($totalParagraphs - $afterParagraphs) / 2); if ($paragraphNumber === $midPoint && $adsInserted < $maxAds && $maxAds > 1) { $newContent .= $this->renderer->renderSlot($this->settings, 'post-content-' . ($adsInserted + 1)); $adsInserted++; } } return $newContent; } }