'; $html .= '
'; $html .= '
'; $html .= '

'; $html .= ' '; $html .= ' AdSense y Analytics'; $html .= '

'; $html .= '

'; $html .= ' Configura Google AdSense y Analytics con ubicaciones visuales'; $html .= '

'; $html .= '
'; $html .= '
'; $html .= ''; // LAYOUT 2 COLUMNAS $html .= '
'; // COLUMNA IZQUIERDA (7 cols) $html .= '
'; $html .= $this->buildVisibilityGroup($componentId); $html .= $this->buildDiagramSection(); $html .= $this->buildPostLocationsGroup($componentId); $html .= $this->buildInContentAdsGroup($componentId); $html .= '
'; // COLUMNA DERECHA (5 cols) $html .= '
'; $html .= $this->buildCredentialsGroup($componentId); $html .= $this->buildAnalyticsGroup($componentId); $html .= $this->buildRailAdsGroup($componentId); $html .= $this->buildExclusionsGroup($componentId); $html .= '
'; $html .= '
'; return $html; } private function buildVisibilityGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Activacion Global'; $html .= '
'; $html .= '
'; $html .= '
'; $enabled = $this->renderer->getFieldValue($cid, 'visibility', 'is_enabled', false); $html .= $this->buildSwitch($cid . 'Enabled', 'Activar AdSense', $enabled, 'bi-power'); $html .= '
'; $html .= '
'; $showMobile = $this->renderer->getFieldValue($cid, 'visibility', 'show_on_mobile', true); $html .= $this->buildSwitch($cid . 'ShowOnMobile', 'Mostrar en movil', $showMobile, 'bi-phone'); $html .= '
'; $html .= '
'; $showDesktop = $this->renderer->getFieldValue($cid, 'visibility', 'show_on_desktop', true); $html .= $this->buildSwitch($cid . 'ShowOnDesktop', 'Mostrar en escritorio', $showDesktop, 'bi-display'); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } /** * Diagrama visual de ubicaciones de anuncios */ private function buildDiagramSection(): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Mapa de Ubicaciones'; $html .= '
'; // Diagrama visual del layout $html .= '
'; // Header $html .= '
'; $html .= ' HEADER'; $html .= '
'; // Hero / Featured Image $html .= '
'; $html .= ' Featured Image / Hero'; $html .= '
'; // Ad: Post Top $html .= '
'; $html .= ' 📍 POST-TOP (Despues de imagen)'; $html .= '
'; // Content container $html .= '
'; $html .= '
📝 CONTENIDO DEL POST
'; $html .= '
Parrafo 1...
'; $html .= '
Parrafo 2...
'; $html .= '
Parrafo 3...
'; // In-content ad $html .= '
'; $html .= ' 📍 IN-CONTENT #1'; $html .= '
'; $html .= '
Parrafo 4...
'; $html .= '
Parrafo 5...
'; $html .= '
Parrafo 6...
'; // In-content ad 2 $html .= '
'; $html .= ' 📍 IN-CONTENT #2 (random)'; $html .= '
'; $html .= '
Mas parrafos...
'; $html .= '
'; // Ad: Post Bottom $html .= '
'; $html .= ' 📍 POST-BOTTOM (Despues del contenido)'; $html .= '
'; // Related Posts $html .= '
'; $html .= ' Related Posts'; $html .= '
'; // Ad: After Related $html .= '
'; $html .= ' 📍 AFTER-RELATED'; $html .= '
'; // Footer $html .= '
'; $html .= ' FOOTER'; $html .= '
'; // Rail Ads (laterales) $html .= '
'; $html .= '
'; $html .= ' 📍 RAIL IZQ
(160x600)'; $html .= '
'; $html .= '
'; $html .= ' 📍 RAIL DER
(160x600)'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ' Los anuncios amarillos son configurables abajo.'; $html .= ' Los rojos solo aparecen en pantallas >1600px.'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildPostLocationsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Ubicaciones en Posts'; $html .= '
'; // === POST-TOP === $html .= '
'; $html .= '
'; $html .= ' POST-TOP'; $html .= ' Despues de la imagen destacada'; $html .= '
'; $html .= '
'; $html .= '
'; $postTopEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_top_enabled', true); $html .= $this->buildSwitch($cid . 'PostTopEnabled', 'Activar', $postTopEnabled); $html .= '
'; $html .= '
'; $html .= $this->buildSelect($cid . 'PostTopFormat', 'Formato', $this->renderer->getFieldValue($cid, 'behavior', 'post_top_format', 'auto'), [ 'auto' => 'Auto (responsive)', 'in-article' => 'In-Article (fluid)', 'display' => 'Display (728x90)', 'display-large' => 'Display Large (970x250)' ] ); $html .= '
'; $html .= '
'; $html .= '
'; // === POST-BOTTOM === $html .= '
'; $html .= '
'; $html .= ' POST-BOTTOM'; $html .= ' Despues del contenido, antes de Related'; $html .= '
'; $html .= '
'; $html .= '
'; $postBottomEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_bottom_enabled', true); $html .= $this->buildSwitch($cid . 'PostBottomEnabled', 'Activar', $postBottomEnabled); $html .= '
'; $html .= '
'; $html .= $this->buildSelect($cid . 'PostBottomFormat', 'Formato', $this->renderer->getFieldValue($cid, 'behavior', 'post_bottom_format', 'auto'), ['auto' => 'Auto', 'in-article' => 'In-Article', 'display' => 'Display'] ); $html .= '
'; $html .= '
'; $html .= '
'; // === AFTER-RELATED === $html .= '
'; $html .= '
'; $html .= ' AFTER-RELATED'; $html .= ' Despues de Related Posts'; $html .= '
'; $html .= '
'; $html .= '
'; $afterRelatedEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'after_related_enabled', false); $html .= $this->buildSwitch($cid . 'AfterRelatedEnabled', 'Activar', $afterRelatedEnabled); $html .= '
'; $html .= '
'; $html .= $this->buildSelect($cid . 'AfterRelatedFormat', 'Formato', $this->renderer->getFieldValue($cid, 'behavior', 'after_related_format', 'autorelaxed'), ['autorelaxed' => 'Autorelaxed (feed)', 'auto' => 'Auto'] ); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } /** * Seccion especial para in-content ads con configuracion de 1-8 random */ private function buildInContentAdsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Anuncios Dentro del Contenido'; $html .= ' 1-8 ads'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Modo Random: Inserta entre 1 y 8 anuncios en posiciones aleatorias entre parrafos.'; $html .= ' Mejor UX al variar la posicion en cada visita.'; $html .= '
'; // Master switch $postContentEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_enabled', false); $html .= '
'; $html .= $this->buildSwitch($cid . 'PostContentEnabled', 'Activar In-Content Ads', $postContentEnabled, 'bi-power'); $html .= '
'; // Configuracion de cantidad $html .= '
'; $html .= '
'; $minAdsValue = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_min_ads', '1'); $html .= $this->buildSelect($cid . 'PostContentMinAds', 'Minimo de anuncios', is_string($minAdsValue) ? $minAdsValue : '1', ['1' => '1 anuncio', '2' => '2 anuncios', '3' => '3 anuncios', '4' => '4 anuncios'] ); $html .= '
'; $html .= '
'; $maxAdsValue = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_max_ads', '3'); $html .= $this->buildSelect($cid . 'PostContentMaxAds', 'Maximo de anuncios', is_string($maxAdsValue) ? $maxAdsValue : '3', [ '1' => '1 anuncio', '2' => '2 anuncios', '3' => '3 anuncios', '4' => '4 anuncios', '5' => '5 anuncios', '6' => '6 anuncios', '7' => '7 anuncios', '8' => '8 anuncios' ] ); $html .= '
'; $html .= '
'; // Configuracion de posicionamiento $html .= '
'; $html .= '
'; $afterPara = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_after_paragraphs', '3'); $html .= $this->buildTextInput($cid . 'PostContentAfterParagraphs', 'Primer ad despues del parrafo #', (string)$afterPara, '3'); $html .= '
'; $html .= '
'; $minBetweenValue = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_min_paragraphs_between', '4'); $html .= $this->buildSelect($cid . 'PostContentMinParagraphsBetween', 'Parrafos entre ads', is_string($minBetweenValue) ? $minBetweenValue : '4', ['2' => '2 parrafos', '3' => '3 parrafos', '4' => '4 parrafos', '5' => '5 parrafos', '6' => '6 parrafos'] ); $html .= '
'; $html .= '
'; // Modo y formato $html .= '
'; $html .= '
'; $randomMode = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_random_mode', true); $html .= $this->buildSwitch($cid . 'PostContentRandomMode', 'Posiciones aleatorias', $randomMode, 'bi-shuffle'); $html .= '
'; $html .= '
'; $formatValue = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_format', 'in-article'); $html .= $this->buildSelect($cid . 'PostContentFormat', 'Formato de ads', is_string($formatValue) ? $formatValue : 'in-article', ['in-article' => 'In-Article (fluid)', 'auto' => 'Auto (responsive)'] ); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildCredentialsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Credenciales AdSense'; $html .= '
'; // Publisher ID $pubId = $this->renderer->getFieldValue($cid, 'content', 'publisher_id', 'ca-pub-8476420265998726'); $html .= $this->buildTextInput($cid . 'PublisherId', 'Publisher ID', $pubId, 'ca-pub-XXXXX'); $html .= '
'; $html .= '

Slots por tipo de anuncio:

'; // Slots con descripciones claras $html .= '
'; $slotAuto = $this->renderer->getFieldValue($cid, 'content', 'slot_auto', '8471732096'); $html .= $this->buildTextInput($cid . 'SlotAuto', '📱 Auto (responsive)', $slotAuto); $html .= '
Para: Post-Top, Post-Bottom, globales
'; $html .= '
'; $html .= '
'; $slotInArticle = $this->renderer->getFieldValue($cid, 'content', 'slot_inarticle', '7285187368'); $html .= $this->buildTextInput($cid . 'SlotInarticle', '📝 In-Article (fluid)', $slotInArticle); $html .= '
Para: In-Content (dentro del texto)
'; $html .= '
'; $html .= '
'; $slotDisplay = $this->renderer->getFieldValue($cid, 'content', 'slot_display', '2873062302'); $html .= $this->buildTextInput($cid . 'SlotDisplay', '🖥️ Display (fijo)', $slotDisplay); $html .= '
Para: 728x90, 970x250 (opcional)
'; $html .= '
'; $html .= '
'; $slotRelaxed = $this->renderer->getFieldValue($cid, 'content', 'slot_autorelaxed', '9205569855'); $html .= $this->buildTextInput($cid . 'SlotAutorelaxed', '📋 Autorelaxed (feed)', $slotRelaxed); $html .= '
Para: After-Related, archives
'; $html .= '
'; $html .= '
'; $slotSkyscraper = $this->renderer->getFieldValue($cid, 'content', 'slot_skyscraper', ''); $html .= $this->buildTextInput($cid . 'SlotSkyscraper', '🏢 Skyscraper (tall)', $slotSkyscraper); $html .= '
Para: Rail Ads laterales (160x600)
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildAnalyticsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Google Analytics'; $html .= '
'; // Switch: Analytics Enabled $analyticsEnabled = $this->renderer->getFieldValue($cid, 'analytics', 'analytics_enabled', false); $html .= $this->buildSwitch($cid . 'AnalyticsEnabled', 'Activar Analytics', $analyticsEnabled, 'bi-power'); // Tracking ID $gaTrackingId = $this->renderer->getFieldValue($cid, 'analytics', 'ga_tracking_id', ''); $html .= $this->buildTextInput($cid . 'GaTrackingId', 'Google Analytics ID', $gaTrackingId, 'G-XXXXXXXXXX'); $html .= '
Formato: G-XXXXXXXXXX (GA4) o UA-XXXXXXXX-X
'; // Anonymize IP $gaAnonymizeIp = $this->renderer->getFieldValue($cid, 'analytics', 'ga_anonymize_ip', true); $html .= $this->buildSwitch($cid . 'GaAnonymizeIp', 'Anonimizar IP (GDPR)', $gaAnonymizeIp, 'bi-shield-check'); $html .= '
'; $html .= '
'; return $html; } private function buildRailAdsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Rail Ads (Laterales)'; $html .= ' >1600px'; $html .= '
'; $html .= '

Anuncios fijos en los margenes del viewport. Solo en pantallas muy anchas.

'; // Master switch $railEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'rail_ads_enabled', false); $html .= $this->buildSwitch($cid . 'RailAdsEnabled', 'Activar Rail Ads', $railEnabled, 'bi-power'); // Left/Right toggles $html .= '
'; $html .= '
'; $leftEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'rail_left_enabled', true); $html .= $this->buildSwitch($cid . 'RailLeftEnabled', 'Rail izquierdo', $leftEnabled); $html .= '
'; $html .= '
'; $rightEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'rail_right_enabled', true); $html .= $this->buildSwitch($cid . 'RailRightEnabled', 'Rail derecho', $rightEnabled); $html .= '
'; $html .= '
'; // Format select - Opciones de altura para anuncios verticales $railFormat = $this->renderer->getFieldValue($cid, 'behavior', 'rail_format', 'skyscraper'); $html .= $this->buildSelect($cid . 'RailFormat', 'Formato', $railFormat, [ 'slim-small' => 'Slim Small (160x300)', 'slim-medium' => 'Slim Medium (160x400)', 'slim-large' => 'Slim Large (160x500)', 'skyscraper' => 'Skyscraper (160x600)', 'slim-xlarge' => 'Slim XLarge (160x700)', 'wide-skyscraper' => 'Wide Skyscraper (160x800)', 'half-page' => 'Half Page (300x600)', 'large-skyscraper' => 'Large Skyscraper (300x1050)' ] ); // Top offset - Select con opciones predefinidas $topOffset = $this->renderer->getFieldValue($cid, 'behavior', 'rail_top_offset', '300'); $html .= $this->buildSelect($cid . 'RailTopOffset', 'Distancia desde arriba', $topOffset, [ '150' => '150px (Cerca del header)', '200' => '200px', '300' => '300px (Recomendado)', '400' => '400px', '500' => '500px', '700' => '700px (Debajo del fold)' ] ); $html .= '
'; $html .= '
'; return $html; } private function buildExclusionsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Exclusiones y Rendimiento'; $html .= '
'; // Accordion para exclusiones $html .= '
'; // Exclusiones $html .= '
'; $html .= '

'; $html .= ' '; $html .= '

'; $html .= '
'; $html .= '
'; $excludeCats = $this->renderer->getFieldValue($cid, 'forms', 'exclude_categories', ''); $html .= $this->buildTextarea($cid . 'ExcludeCategories', 'Excluir categorias (IDs)', $excludeCats, 'Ej: 5,12,23'); $excludeTypes = $this->renderer->getFieldValue($cid, 'forms', 'exclude_post_types', ''); $html .= $this->buildTextarea($cid . 'ExcludePostTypes', 'Excluir tipos de post', $excludeTypes, 'Ej: page,attachment'); $excludeIds = $this->renderer->getFieldValue($cid, 'forms', 'exclude_post_ids', ''); $html .= $this->buildTextarea($cid . 'ExcludePostIds', 'Excluir posts (IDs)', $excludeIds, 'Ej: 100,205,310'); $minLength = $this->renderer->getFieldValue($cid, 'forms', 'min_content_length', '500'); $html .= $this->buildTextInput($cid . 'MinContentLength', 'Longitud minima de contenido', $minLength); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; // end accordion // Delay settings (siempre visibles) $html .= '
'; $html .= '

Rendimiento:

'; $delayEnabled = $this->renderer->getFieldValue($cid, 'forms', 'delay_enabled', true); $html .= $this->buildSwitch($cid . 'DelayEnabled', 'Retrasar carga (mejor PageSpeed)', $delayEnabled, 'bi-hourglass-split'); $delayTimeout = $this->renderer->getFieldValue($cid, 'forms', 'delay_timeout', '5000'); $html .= $this->buildTextInput($cid . 'DelayTimeout', 'Timeout de delay (ms)', $delayTimeout); $html .= '
'; $html .= '
'; return $html; } // === HELPERS === private function buildSwitch(string $id, string $label, $value, string $icon = ''): string { $checked = checked($value, true, false); $iconHtml = $icon ? '' : ''; return sprintf( '
', esc_attr($id), $checked, esc_attr($id), $iconHtml, esc_html($label) ); } private function buildTextInput(string $id, string $label, string $value, string $placeholder = ''): string { return sprintf( '
', esc_attr($id), esc_html($label), esc_attr($id), esc_attr($value), esc_attr($placeholder) ); } private function buildTextarea(string $id, string $label, string $value, string $placeholder = ''): string { return sprintf( '
', esc_attr($id), esc_html($label), esc_attr($id), esc_attr($placeholder), esc_textarea($value) ); } private function buildSelect(string $id, string $label, string $value, array $options): string { $optionsHtml = ''; foreach ($options as $optValue => $optLabel) { $selected = selected($value, $optValue, false); $optionsHtml .= sprintf( '', esc_attr($optValue), $selected, esc_html($optLabel) ); } return sprintf( '
', esc_attr($id), esc_html($label), esc_attr($id), $optionsHtml ); } }