'; $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 .= $this->buildExclusionsGroup($componentId); $html .= '
'; // COLUMNA DERECHA (5 cols) $html .= '
'; $html .= $this->buildCredentialsGroup($componentId); $html .= $this->buildAnalyticsGroup($componentId); $html .= $this->buildRailAdsGroup($componentId); $html .= $this->buildAnchorAdsGroup($componentId); $html .= $this->buildVignetteAdsGroup($componentId); $html .= $this->buildSearchResultsGroup($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 .= '
'; // Opcion para ocultar anuncios a usuarios logueados $html .= '
'; $hideForLoggedIn = $this->renderer->getFieldValue($cid, 'visibility', 'hide_for_logged_in', false); $html .= $this->buildSwitch($cid . 'HideForLoggedIn', 'Ocultar para usuarios logueados', $hideForLoggedIn, 'bi-person-lock'); $html .= 'No mostrar anuncios a usuarios con sesion iniciada en WordPress'; $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 .= '
'; // Anchor Top $html .= '
'; $html .= ' ANCHOR TOP (fijo, collapsible)'; $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 .= '
'; // Anchor Bottom $html .= '
'; $html .= ' ANCHOR BOTTOM (fijo, collapsible)'; $html .= '
'; // Rail Ads (laterales) $html .= '
'; $html .= '
'; $html .= ' 📍 RAIL IZQ
(160x600)'; $html .= '
'; $html .= '
'; $html .= ' 📍 RAIL DER
(160x600)'; $html .= '
'; $html .= '
'; // Vignette Ad (modal) $html .= '
'; $html .= ' VIGNETTE (modal pantalla completa)'; $html .= '
Aparece segun trigger configurado'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ' Amarillo = Posts, '; $html .= ' Rojo = Rails >1600px, '; $html .= ' Cyan = Anchors, '; $html .= ' Morado = Vignette'; $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 - Solo altura (el ancho es responsive) $railFormat = $this->renderer->getFieldValue($cid, 'behavior', 'rail_format', 'h600'); $html .= $this->buildSelect($cid . 'RailFormat', 'Altura del Rail', $railFormat, [ 'h250' => '250px (Compacto)', 'h300' => '300px (Pequeno)', 'h400' => '400px (Mediano)', 'h500' => '500px', 'h600' => '600px (Recomendado)', 'h700' => '700px', 'h800' => '800px (Grande)', 'h1050' => '1050px (Extra grande)' ] ); $html .= 'El ancho se ajusta automaticamente al espacio disponible.'; // 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; } /** * Seccion para Anchor Ads (anuncios fijos top/bottom) */ private function buildAnchorAdsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Anuncios Fijos (Anchor)'; $html .= '
'; $html .= '

Anuncios fijos en el borde superior o inferior de la pantalla.

'; // Master switch $anchorEnabled = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_enabled', false); $html .= $this->buildSwitch($cid . 'AnchorEnabled', 'Activar Anchor Ads', $anchorEnabled, 'bi-power'); // Posicion $anchorPosition = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_position', 'bottom'); $html .= $this->buildSelect($cid . 'AnchorPosition', 'Posicion del anuncio', $anchorPosition, [ 'top' => 'Solo en la parte superior', 'bottom' => 'Solo en la parte inferior', 'both' => 'Superior e inferior' ] ); // Altura $anchorHeight = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_height', '90'); $html .= $this->buildSelect($cid . 'AnchorHeight', 'Altura del anchor', $anchorHeight, ['50' => '50px', '90' => '90px', '100' => '100px', '120' => '120px'] ); // Collapsible toggle $collapsible = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_collapsible_enabled', true); $html .= $this->buildSwitch($cid . 'AnchorCollapsibleEnabled', 'Permitir minimizar', $collapsible, 'bi-arrows-collapse'); $html .= 'Usuario puede minimizar en lugar de cerrar'; // Pantallas $html .= '
'; $html .= '
'; $showMobile = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_show_on_mobile', true); $html .= $this->buildSwitch($cid . 'AnchorShowOnMobile', 'Mostrar en movil', $showMobile, 'bi-phone'); $html .= '
'; $html .= '
'; $showWide = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_show_on_wide_screens', false); $html .= $this->buildSwitch($cid . 'AnchorShowOnWideScreens', 'Pantallas anchas', $showWide, 'bi-display'); $html .= '
'; $html .= '
'; // Recordar estado $html .= '
'; $rememberState = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_remember_state', true); $html .= $this->buildSwitch($cid . 'AnchorRememberState', 'Recordar cierre/colapso', $rememberState, 'bi-clock-history'); $rememberDuration = $this->renderer->getFieldValue($cid, 'anchor_ads', 'anchor_remember_duration', 'session'); $html .= $this->buildSelect($cid . 'AnchorRememberDuration', 'Duracion', $rememberDuration, [ 'session' => 'Solo esta sesion', '1hour' => '1 hora', '1day' => '1 dia', '1week' => '1 semana' ] ); $html .= '
'; $html .= '
'; $html .= '
'; return $html; } /** * Seccion para Vignette Ads (pantalla completa) */ private function buildVignetteAdsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Anuncios de Vineta'; $html .= ' Pantalla Completa'; $html .= '
'; $html .= '

Anuncios que ocupan toda la pantalla, aparecen segun el trigger configurado.

'; // Master switch $vignetteEnabled = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_enabled', false); $html .= $this->buildSwitch($cid . 'VignetteEnabled', 'Activar Vignette Ads', $vignetteEnabled, 'bi-power'); // Trigger $vignetteTrigger = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_trigger', 'pageview'); $html .= $this->buildSelect($cid . 'VignetteTrigger', 'Cuando mostrar', (string)$vignetteTrigger, [ 'pageview' => 'Al cargar la pagina', 'scroll_50' => 'Al scrollear 50%', 'scroll_75' => 'Al scrollear 75%', 'exit_intent' => 'Al intentar salir', 'time_delay' => 'Despues de X segundos' ] ); // Delay inicial $triggerDelay = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_trigger_delay', '5'); $html .= $this->buildTextInput($cid . 'VignetteTriggerDelay', 'Delay inicial (segundos)', (string)$triggerDelay, '5'); // Tamano y opacidad $html .= '
'; $html .= '
'; $size = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_size', 'auto'); $html .= $this->buildSelect($cid . 'VignetteSize', 'Tamano', (string)$size, [ 'auto' => 'Auto (recomendado)', 'responsive' => 'Responsive (fluid)', '1280x720' => '1280x720 (HD 720p)', '960x540' => '960x540 (qHD)', '854x480' => '854x480 (480p)', '800x450' => '800x450 (16:9)', '640x360' => '640x360 (360p)', '560x315' => '560x315 (YouTube)', '300x250' => '300x250 (Rectangle)', '336x280' => '336x280 (Large Rectangle)', ] ); $html .= '
'; $html .= '
'; $opacity = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_overlay_opacity', '0.7'); $html .= $this->buildSelect($cid . 'VignetteOverlayOpacity', 'Opacidad fondo', (string)$opacity, ['0.5' => '50%', '0.6' => '60%', '0.7' => '70%', '0.8' => '80%', '0.9' => '90%'] ); $html .= '
'; $html .= '
'; // Pantallas $html .= '
'; $html .= '
'; $showMobile = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_show_on_mobile', true); $html .= $this->buildSwitch($cid . 'VignetteShowOnMobile', 'Mostrar en movil', $showMobile, 'bi-phone'); $html .= '
'; $html .= '
'; $showDesktop = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_show_on_desktop', true); $html .= $this->buildSwitch($cid . 'VignetteShowOnDesktop', 'Mostrar en desktop', $showDesktop, 'bi-display'); $html .= '
'; $html .= '
'; // Reaparicion $html .= '
'; $html .= '

Reaparicion

'; $reshowEnabled = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_reshow_enabled', true); $html .= $this->buildSwitch($cid . 'VignetteReshowEnabled', 'Permitir reaparicion', $reshowEnabled); $html .= '
'; $html .= '
'; $reshowTime = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_reshow_time', '5'); $html .= $this->buildSelect($cid . 'VignetteReshowTime', 'Tiempo (min)', (string)$reshowTime, ['1' => '1 min', '2' => '2 min', '3' => '3 min', '4' => '4 min', '5' => '5 min', '10' => '10 min', '15' => '15 min', '30' => '30 min'] ); $html .= '
'; $html .= '
'; $maxSession = $this->renderer->getFieldValue($cid, 'vignette_ads', 'vignette_max_per_session', '3'); $html .= $this->buildSelect($cid . 'VignetteMaxPerSession', 'Max/sesion', (string)$maxSession, ['1' => '1', '2' => '2', '3' => '3', '5' => '5', 'unlimited' => 'Sin limite'] ); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } /** * Seccion para anuncios en resultados de busqueda (ROI APU Search) */ private function buildSearchResultsGroup(string $cid): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Resultados de Busqueda'; $html .= ' ROI APU Search'; $html .= '
'; $html .= '

Insertar anuncios en los resultados del buscador de Analisis de Precios Unitarios.

'; // Master switch $searchAdsEnabled = $this->renderer->getFieldValue($cid, 'search_results', 'search_ads_enabled', false); $html .= $this->buildSwitch($cid . 'SearchAdsEnabled', 'Activar ads en busqueda', $searchAdsEnabled, 'bi-power'); // Anuncio superior $html .= '
'; $html .= '
'; $html .= ' ANUNCIO SUPERIOR'; $html .= ' Debajo del campo de busqueda'; $html .= '
'; $html .= '
'; $html .= '
'; $topEnabled = $this->renderer->getFieldValue($cid, 'search_results', 'search_top_ad_enabled', true); $html .= $this->buildSwitch($cid . 'SearchTopAdEnabled', 'Activar', $topEnabled); $html .= '
'; $html .= '
'; $topFormat = $this->renderer->getFieldValue($cid, 'search_results', 'search_top_ad_format', 'auto'); $html .= $this->buildSelect($cid . 'SearchTopAdFormat', 'Formato', (string)$topFormat, ['auto' => 'Auto (responsive)', 'display' => 'Display (fijo)', 'in-article' => 'In-Article (fluid)'] ); $html .= '
'; $html .= '
'; $html .= '
'; // Anuncios entre resultados $html .= '
'; $html .= '
'; $html .= ' ENTRE RESULTADOS'; $html .= ' Intercalados con los resultados'; $html .= '
'; $html .= '
'; $html .= '
'; $betweenEnabled = $this->renderer->getFieldValue($cid, 'search_results', 'search_between_enabled', true); $html .= $this->buildSwitch($cid . 'SearchBetweenEnabled', 'Activar', $betweenEnabled); $html .= '
'; $html .= '
'; $betweenMax = $this->renderer->getFieldValue($cid, 'search_results', 'search_between_max', '1'); $html .= $this->buildSelect($cid . 'SearchBetweenMax', 'Maximo ads', (string)$betweenMax, ['1' => '1 anuncio', '2' => '2 anuncios', '3' => '3 anuncios (max)'] ); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $betweenFormat = $this->renderer->getFieldValue($cid, 'search_results', 'search_between_format', 'in-article'); $html .= $this->buildSelect($cid . 'SearchBetweenFormat', 'Formato', (string)$betweenFormat, ['in-article' => 'In-Article (fluid)', 'auto' => 'Auto (responsive)', 'autorelaxed' => 'Autorelaxed (feed)'] ); $html .= '
'; $html .= '
'; $betweenPosition = $this->renderer->getFieldValue($cid, 'search_results', 'search_between_position', 'random'); $html .= $this->buildSelect($cid . 'SearchBetweenPosition', 'Posicion', (string)$betweenPosition, ['random' => 'Aleatorio', 'fixed' => 'Fijo (cada N)', 'first_half' => 'Primera mitad'] ); $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $betweenEvery = $this->renderer->getFieldValue($cid, 'search_results', 'search_between_every', '5'); $html .= $this->buildSelect($cid . 'SearchBetweenEvery', 'Cada N resultados (si es fijo)', (string)$betweenEvery, ['3' => 'Cada 3', '4' => 'Cada 4', '5' => 'Cada 5', '6' => 'Cada 6', '7' => 'Cada 7', '8' => 'Cada 8', '10' => 'Cada 10'] ); $html .= '
'; $html .= '
'; $html .= '
'; $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 ); } }