fix(adsense): Use adsense-placement settings instead of non-existent adsense-delay component
- Change roi_delay_adsense_scripts() to read from 'adsense-placement' component - Change roi_add_adsense_init_script() to use same settings source - Use 'forms.delay_enabled' field path instead of 'visibility.is_enabled' - Add clarifying comments about output buffer purpose The 'adsense-delay' component was never created in the database, causing the delay functions to always use default values. Now properly reads from the existing 'adsense-placement' component settings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -17,8 +17,10 @@ if (!defined('ABSPATH')) {
|
|||||||
/**
|
/**
|
||||||
* Retarda la carga de scripts de AdSense interceptando el buffer de salida
|
* Retarda la carga de scripts de AdSense interceptando el buffer de salida
|
||||||
*
|
*
|
||||||
* Esta función inicia el output buffering y reemplaza los scripts de AdSense
|
* NOTA: Este output buffer solo se activa cuando delay_enabled está activo
|
||||||
* con versiones retrasadas cuando se renderiza la página.
|
* en adsense-placement. El renderer ya genera scripts con type="text/plain",
|
||||||
|
* pero este buffer procesa scripts de AdSense que vienen de otras fuentes
|
||||||
|
* (plugins, código manual, etc.)
|
||||||
*/
|
*/
|
||||||
function roi_delay_adsense_scripts() {
|
function roi_delay_adsense_scripts() {
|
||||||
// Solo ejecutar en frontend
|
// Solo ejecutar en frontend
|
||||||
@@ -26,10 +28,11 @@ function roi_delay_adsense_scripts() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verificar si el retardo de AdSense está habilitado (Clean Architecture)
|
// Verificar si el retardo de AdSense está habilitado desde adsense-placement
|
||||||
$is_enabled = roi_get_component_setting('adsense-delay', 'visibility', 'is_enabled', true);
|
// IMPORTANTE: Usar adsense-placement (no adsense-delay que no existe)
|
||||||
|
$delay_enabled = roi_get_component_setting('adsense-placement', 'forms', 'delay_enabled', true);
|
||||||
|
|
||||||
if (!$is_enabled) {
|
if (!$delay_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +111,10 @@ function roi_replace_adsense_scripts($html) {
|
|||||||
* después de que adsense-loader.js ha sido enqueued.
|
* después de que adsense-loader.js ha sido enqueued.
|
||||||
*/
|
*/
|
||||||
function roi_add_adsense_init_script() {
|
function roi_add_adsense_init_script() {
|
||||||
// Verificar si el retardo de AdSense está habilitado (Clean Architecture)
|
// Verificar si el retardo de AdSense está habilitado desde adsense-placement
|
||||||
$is_enabled = roi_get_component_setting('adsense-delay', 'visibility', 'is_enabled', true);
|
$delay_enabled = roi_get_component_setting('adsense-placement', 'forms', 'delay_enabled', true);
|
||||||
|
|
||||||
if (!$is_enabled || is_admin()) {
|
if (!$delay_enabled || is_admin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user