fix(adsense): Remove debug code after finding root cause
Root cause: mu-plugin allow-unfiltered-html.php was replacing all filtered content with raw DB content at PHP_INT_MAX priority. Solution: Modified mu-plugin on server to call roi_inject_content_ads() after getting raw content. NOTE: The mu-plugin change is only on the production server at: /wp-content/mu-plugins/allow-unfiltered-html.php The change adds roi_inject_content_ads() call after YouTube Facade filter. This allows ads to be injected into posts even with the raw content bypass. Cleaned up: - Removed debug logging from adsense-placement.php - Removed template-level debug from single.php - Removed debug markers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -184,19 +184,12 @@ function roi_inject_content_ads(string $content): string
|
||||
{
|
||||
global $container;
|
||||
|
||||
// DEBUG: Log para diagnosticar problema de ads no inyectados
|
||||
$post_id = get_the_ID();
|
||||
$post_url = get_permalink();
|
||||
error_log('ROI AdSense Debug: roi_inject_content_ads called for post_id=' . $post_id . ', url=' . $post_url);
|
||||
|
||||
// Solo en posts individuales
|
||||
if (!is_single() || !in_the_loop() || !is_main_query()) {
|
||||
error_log('ROI AdSense Debug: Skip - not single/loop/main_query. is_single=' . (is_single() ? '1' : '0') . ', in_the_loop=' . (in_the_loop() ? '1' : '0') . ', is_main_query=' . (is_main_query() ? '1' : '0'));
|
||||
return $content;
|
||||
}
|
||||
|
||||
if ($container === null) {
|
||||
error_log('ROI AdSense Debug: Skip - container is null');
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -204,16 +197,12 @@ function roi_inject_content_ads(string $content): string
|
||||
$repository = $container->getComponentSettingsRepository();
|
||||
$settings = $repository->getComponentSettings('adsense-placement');
|
||||
|
||||
error_log('ROI AdSense Debug: Settings loaded. is_enabled=' . ($settings['visibility']['is_enabled'] ?? 'NOT SET'));
|
||||
|
||||
if (empty($settings) || !($settings['visibility']['is_enabled'] ?? false)) {
|
||||
error_log('ROI AdSense Debug: Skip - settings empty or not enabled');
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Verificar exclusiones
|
||||
if (roi_is_ad_excluded($settings)) {
|
||||
error_log('ROI AdSense Debug: Skip - post excluded');
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -223,14 +212,12 @@ function roi_inject_content_ads(string $content): string
|
||||
$postTopHtml = '';
|
||||
if ($settings['behavior']['post_top_enabled'] ?? false) {
|
||||
$postTopHtml = $renderer->renderSlot($settings, 'post-top');
|
||||
error_log('ROI AdSense Debug: post-top rendered, length=' . strlen($postTopHtml));
|
||||
}
|
||||
|
||||
// Inyectar anuncio al final (post-bottom)
|
||||
$postBottomHtml = '';
|
||||
if ($settings['behavior']['post_bottom_enabled'] ?? false) {
|
||||
$postBottomHtml = $renderer->renderSlot($settings, 'post-bottom');
|
||||
error_log('ROI AdSense Debug: post-bottom rendered, length=' . strlen($postBottomHtml));
|
||||
}
|
||||
|
||||
// Inyectar anuncios dentro del contenido
|
||||
@@ -240,16 +227,12 @@ function roi_inject_content_ads(string $content): string
|
||||
);
|
||||
$content = $injector->inject($content);
|
||||
|
||||
// DEBUG: Agregar marcador visible para rastrear si el contenido se pierde después del filtro
|
||||
$debugMarker = '<!-- ROI-ADSENSE-DEBUG-MARKER -->';
|
||||
$finalContent = $debugMarker . $postTopHtml . $content . $postBottomHtml . $debugMarker;
|
||||
error_log('ROI AdSense Debug: Final injection done. postTop=' . strlen($postTopHtml) . ', postBottom=' . strlen($postBottomHtml) . ', finalLength=' . strlen($finalContent));
|
||||
error_log('ROI AdSense Debug: First 200 chars of postTopHtml: ' . substr($postTopHtml, 0, 200));
|
||||
|
||||
return $finalContent;
|
||||
return $postTopHtml . $content . $postBottomHtml;
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
error_log('ROI AdSense Content ERROR: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine());
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('ROI AdSense Content ERROR: ' . $e->getMessage());
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
10
single.php
10
single.php
@@ -39,18 +39,8 @@ if (function_exists('roi_render_component')) {
|
||||
|
||||
<!-- Post Content -->
|
||||
<article class="post-content">
|
||||
<!-- DEBUG: BEFORE the_content() -->
|
||||
<?php
|
||||
// DEBUG: Capturar output de the_content
|
||||
ob_start();
|
||||
the_content();
|
||||
$captured_content = ob_get_clean();
|
||||
// DEBUG: Log y output
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('ROI DEBUG single.php: the_content() returned ' . strlen($captured_content) . ' chars');
|
||||
error_log('ROI DEBUG single.php: First 300 chars: ' . substr($captured_content, 0, 300));
|
||||
}
|
||||
echo $captured_content;
|
||||
|
||||
wp_link_pages(array(
|
||||
'before' => '<div class="page-links">' . esc_html__('Pages:', 'roi-theme'),
|
||||
|
||||
Reference in New Issue
Block a user