fix(adsense): Disable Auto Ads when disable_auto_ads is enabled
- Add enable_page_level_ads: false to prevent Google from automatically inserting ads in unwanted locations - This prevents ads from appearing inside table cells and other inappropriate places 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -157,6 +157,9 @@ function roi_should_disable_auto_ads(): bool
|
||||
|
||||
/**
|
||||
* Carga el script principal de AdSense
|
||||
*
|
||||
* IMPORTANTE: Si disable_auto_ads está activo, se añade código para
|
||||
* deshabilitar Auto Ads (page-level ads) de Google.
|
||||
*/
|
||||
function roi_enqueue_adsense_script(): void
|
||||
{
|
||||
@@ -180,13 +183,25 @@ function roi_enqueue_adsense_script(): void
|
||||
}
|
||||
|
||||
$delayEnabled = ($settings['forms']['delay_enabled'] ?? true) === true;
|
||||
$disableAutoAds = ($settings['visibility']['disable_auto_ads'] ?? true) === true;
|
||||
|
||||
// Script principal de AdSense
|
||||
if ($delayEnabled) {
|
||||
echo '<script type="text/plain" data-adsense-script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=' . esc_attr($publisherId) . '" crossorigin="anonymous"></script>' . "\n";
|
||||
} else {
|
||||
echo '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=' . esc_attr($publisherId) . '" crossorigin="anonymous"></script>' . "\n";
|
||||
}
|
||||
|
||||
// Deshabilitar Auto Ads (page-level ads) si está configurado
|
||||
if ($disableAutoAds) {
|
||||
echo '<script>
|
||||
(adsbygoogle = window.adsbygoogle || []).push({
|
||||
google_ad_client: "' . esc_js($publisherId) . '",
|
||||
enable_page_level_ads: false
|
||||
});
|
||||
</script>' . "\n";
|
||||
}
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('ROI AdSense: ' . $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user