fix(rail-ads): revertir a anuncio 160px fijo centrado en container responsive
This commit is contained in:
@@ -97,9 +97,6 @@ function roi_render_rail_ads(): string
|
|||||||
global $container;
|
global $container;
|
||||||
|
|
||||||
if ($container === null) {
|
if ($container === null) {
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: container is NULL');
|
|
||||||
}
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,34 +105,22 @@ function roi_render_rail_ads(): string
|
|||||||
$settings = $repository->getComponentSettings('adsense-placement');
|
$settings = $repository->getComponentSettings('adsense-placement');
|
||||||
|
|
||||||
if (empty($settings)) {
|
if (empty($settings)) {
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: settings are EMPTY');
|
|
||||||
}
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar exclusiones
|
// Verificar exclusiones
|
||||||
if (roi_is_ad_excluded($settings)) {
|
if (roi_is_ad_excluded($settings)) {
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: EXCLUDED by roi_is_ad_excluded');
|
|
||||||
}
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obtener renderer desde DIContainer (DIP compliant)
|
// Obtener renderer desde DIContainer (DIP compliant)
|
||||||
$renderer = $container->getAdsensePlacementRenderer();
|
$renderer = $container->getAdsensePlacementRenderer();
|
||||||
|
|
||||||
$html = $renderer->renderRailAds($settings);
|
return $renderer->renderRailAds($settings);
|
||||||
|
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: renderRailAds returned ' . strlen($html) . ' chars');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||||
error_log('ROI AdSense Rail Ads ERROR: ' . $e->getMessage());
|
error_log('ROI AdSense Rail Ads: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -145,19 +130,8 @@ function roi_render_rail_ads(): string
|
|||||||
* Hook para inyectar Rail Ads en el footer
|
* Hook para inyectar Rail Ads en el footer
|
||||||
*/
|
*/
|
||||||
add_action('wp_footer', function() {
|
add_action('wp_footer', function() {
|
||||||
// DEBUG: Verificar que el hook se ejecuta
|
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: wp_footer hook fired');
|
|
||||||
}
|
|
||||||
|
|
||||||
$output = roi_render_rail_ads();
|
|
||||||
|
|
||||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
|
||||||
error_log('ROI Rail Ads: output length = ' . strlen($output));
|
|
||||||
}
|
|
||||||
|
|
||||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||||
echo $output;
|
echo roi_render_rail_ads();
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -362,9 +362,7 @@ final class AdsensePlacementRenderer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* EXCEPCION DOCUMENTADA: CSS inline requerido por Google AdSense
|
* EXCEPCION DOCUMENTADA: CSS inline requerido por Google AdSense
|
||||||
* Usamos display:block con data-full-width-responsive="true" para que
|
* El anuncio usa tamaño fijo (160xHeight) centrado en el container responsive.
|
||||||
* el anuncio se adapte automaticamente al ancho del contenedor responsive.
|
|
||||||
* La altura se controla via el selector de formato.
|
|
||||||
* Ref: https://support.google.com/adsense/answer/9274516
|
* Ref: https://support.google.com/adsense/answer/9274516
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -372,9 +370,8 @@ final class AdsensePlacementRenderer
|
|||||||
if ($leftEnabled) {
|
if ($leftEnabled) {
|
||||||
$html .= sprintf(
|
$html .= sprintf(
|
||||||
'<div class="roi-rail-ad roi-rail-ad-left">
|
'<div class="roi-rail-ad roi-rail-ad-left">
|
||||||
<ins class="adsbygoogle" style="display:block;height:%dpx"
|
<ins class="adsbygoogle" style="display:inline-block;width:160px;height:%dpx"
|
||||||
data-ad-client="%s" data-ad-slot="%s"
|
data-ad-client="%s" data-ad-slot="%s"></ins>
|
||||||
data-full-width-responsive="true"></ins>
|
|
||||||
<script type="%s"%s>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
<script type="%s"%s>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
||||||
</div>',
|
</div>',
|
||||||
$height, esc_attr($publisherId), esc_attr($slotId), $scriptType, $dataAttr
|
$height, esc_attr($publisherId), esc_attr($slotId), $scriptType, $dataAttr
|
||||||
@@ -385,9 +382,8 @@ final class AdsensePlacementRenderer
|
|||||||
if ($rightEnabled) {
|
if ($rightEnabled) {
|
||||||
$html .= sprintf(
|
$html .= sprintf(
|
||||||
'<div class="roi-rail-ad roi-rail-ad-right">
|
'<div class="roi-rail-ad roi-rail-ad-right">
|
||||||
<ins class="adsbygoogle" style="display:block;height:%dpx"
|
<ins class="adsbygoogle" style="display:inline-block;width:160px;height:%dpx"
|
||||||
data-ad-client="%s" data-ad-slot="%s"
|
data-ad-client="%s" data-ad-slot="%s"></ins>
|
||||||
data-full-width-responsive="true"></ins>
|
|
||||||
<script type="%s"%s>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
<script type="%s"%s>(adsbygoogle = window.adsbygoogle || []).push({});</script>
|
||||||
</div>',
|
</div>',
|
||||||
$height, esc_attr($publisherId), esc_attr($slotId), $scriptType, $dataAttr
|
$height, esc_attr($publisherId), esc_attr($slotId), $scriptType, $dataAttr
|
||||||
|
|||||||
Reference in New Issue
Block a user