|
|
|
|
@@ -0,0 +1,381 @@
|
|
|
|
|
<?php
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace ROITheme\Admin\AdsensePlacement\Infrastructure\Ui;
|
|
|
|
|
|
|
|
|
|
use ROITheme\Admin\Infrastructure\Ui\AdminDashboardRenderer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* FormBuilder para AdSense Placement
|
|
|
|
|
*/
|
|
|
|
|
final class AdsensePlacementFormBuilder
|
|
|
|
|
{
|
|
|
|
|
public function __construct(
|
|
|
|
|
private AdminDashboardRenderer $renderer
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
public function buildForm(string $componentId): string
|
|
|
|
|
{
|
|
|
|
|
$html = '';
|
|
|
|
|
|
|
|
|
|
// HEADER CON GRADIENTE
|
|
|
|
|
$html .= '<div class="rounded p-4 mb-4 shadow text-white" style="background: linear-gradient(135deg, #0E2337 0%, #1e3a5f 100%); border-left: 4px solid #FF8600;">';
|
|
|
|
|
$html .= ' <div class="d-flex align-items-center justify-content-between flex-wrap gap-3">';
|
|
|
|
|
$html .= ' <div>';
|
|
|
|
|
$html .= ' <h3 class="h4 mb-1 fw-bold">';
|
|
|
|
|
$html .= ' <i class="bi bi-megaphone me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Control de Anuncios AdSense';
|
|
|
|
|
$html .= ' </h3>';
|
|
|
|
|
$html .= ' <p class="mb-0 small" style="opacity: 0.85;">';
|
|
|
|
|
$html .= ' Configura ubicaciones manuales de anuncios para evitar Auto Ads';
|
|
|
|
|
$html .= ' </p>';
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
// LAYOUT 2 COLUMNAS
|
|
|
|
|
$html .= '<div class="row g-3">';
|
|
|
|
|
|
|
|
|
|
// COLUMNA IZQUIERDA
|
|
|
|
|
$html .= ' <div class="col-lg-6">';
|
|
|
|
|
$html .= $this->buildVisibilityGroup($componentId);
|
|
|
|
|
$html .= $this->buildCredentialsGroup($componentId);
|
|
|
|
|
$html .= $this->buildPostLocationsGroup($componentId);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
|
|
|
|
|
// COLUMNA DERECHA
|
|
|
|
|
$html .= ' <div class="col-lg-6">';
|
|
|
|
|
$html .= $this->buildRailAdsGroup($componentId);
|
|
|
|
|
$html .= $this->buildArchiveLocationsGroup($componentId);
|
|
|
|
|
$html .= $this->buildExclusionsGroup($componentId);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildVisibilityGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-toggle-on me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Activacion y Visibilidad';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
|
|
|
|
|
// Switch: Enabled
|
|
|
|
|
$enabled = $this->renderer->getFieldValue($cid, 'visibility', 'is_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'Enabled', 'Activar Placement Manual', $enabled, 'bi-power');
|
|
|
|
|
|
|
|
|
|
// Switch: Disable Auto Ads
|
|
|
|
|
$disableAuto = $this->renderer->getFieldValue($cid, 'visibility', 'disable_auto_ads', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'DisableAutoAds', 'Deshabilitar Auto Ads de Google', $disableAuto, 'bi-shield-x');
|
|
|
|
|
|
|
|
|
|
// Switch: Show on Mobile
|
|
|
|
|
$showMobile = $this->renderer->getFieldValue($cid, 'visibility', 'show_on_mobile', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'ShowOnMobile', 'Mostrar en movil', $showMobile, 'bi-phone');
|
|
|
|
|
|
|
|
|
|
// Switch: Show on Desktop
|
|
|
|
|
$showDesktop = $this->renderer->getFieldValue($cid, 'visibility', 'show_on_desktop', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'ShowOnDesktop', 'Mostrar en escritorio', $showDesktop, 'bi-display');
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildCredentialsGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-key me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Credenciales AdSense';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
|
|
|
|
|
// Publisher ID
|
|
|
|
|
$pubId = $this->renderer->getFieldValue($cid, 'content', 'publisher_id', 'ca-pub-8476420265998726');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'PublisherId', 'Publisher ID', $pubId, 'ca-pub-XXXXX');
|
|
|
|
|
|
|
|
|
|
// Slots (grid 2 columnas)
|
|
|
|
|
$html .= '<div class="row g-2 mt-2">';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$slotDisplay = $this->renderer->getFieldValue($cid, 'content', 'slot_display', '2873062302');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'SlotDisplay', 'Slot Display', $slotDisplay);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$slotAuto = $this->renderer->getFieldValue($cid, 'content', 'slot_auto', '8471732096');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'SlotAuto', 'Slot Auto', $slotAuto);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$slotRelaxed = $this->renderer->getFieldValue($cid, 'content', 'slot_autorelaxed', '9205569855');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'SlotAutorelaxed', 'Slot Autorelaxed', $slotRelaxed);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$slotInArticle = $this->renderer->getFieldValue($cid, 'content', 'slot_inarticle', '7285187368');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'SlotInarticle', 'Slot In-Article', $slotInArticle);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$slotSkyscraper = $this->renderer->getFieldValue($cid, 'content', 'slot_skyscraper', '');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'SlotSkyscraper', 'Slot Skyscraper (Rail Ads)', $slotSkyscraper);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildPostLocationsGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-file-text me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Ubicaciones en Posts';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
|
|
|
|
|
// Post Top
|
|
|
|
|
$postTopEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_top_enabled', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'PostTopEnabled', 'Despues de Featured Image', $postTopEnabled);
|
|
|
|
|
$html .= $this->buildSelect($cid . 'PostTopFormat', 'Formato',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'behavior', 'post_top_format', 'auto'),
|
|
|
|
|
['auto' => 'Auto (responsive)', 'in-article' => 'In-Article', 'display' => 'Display (728x90)', 'display-large' => 'Display Large (970x250)']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Post Content
|
|
|
|
|
$postContentEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'PostContentEnabled', 'Insertar dentro del contenido', $postContentEnabled);
|
|
|
|
|
|
|
|
|
|
$html .= '<div class="row g-2">';
|
|
|
|
|
$html .= ' <div class="col-4">';
|
|
|
|
|
$afterPara = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_after_paragraphs', '3');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'PostContentAfterParagraphs', 'Despues parrafo #', $afterPara);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-4">';
|
|
|
|
|
$maxAds = $this->renderer->getFieldValue($cid, 'behavior', 'post_content_max_ads', '2');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'PostContentMaxAds', 'Max ads', $maxAds);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-4">';
|
|
|
|
|
$html .= $this->buildSelect($cid . 'PostContentFormat', 'Formato',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'behavior', 'post_content_format', 'in-article'),
|
|
|
|
|
['in-article' => 'In-Article', 'auto' => 'Auto']
|
|
|
|
|
);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
// Post Bottom
|
|
|
|
|
$postBottomEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'post_bottom_enabled', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'PostBottomEnabled', 'Despues del contenido', $postBottomEnabled);
|
|
|
|
|
$html .= $this->buildSelect($cid . 'PostBottomFormat', 'Formato',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'behavior', 'post_bottom_format', 'auto'),
|
|
|
|
|
['auto' => 'Auto', 'in-article' => 'In-Article', 'display' => 'Display']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// After Related
|
|
|
|
|
$afterRelatedEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'after_related_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'AfterRelatedEnabled', 'Despues de Related Posts', $afterRelatedEnabled);
|
|
|
|
|
$html .= $this->buildSelect($cid . 'AfterRelatedFormat', 'Formato',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'behavior', 'after_related_format', 'autorelaxed'),
|
|
|
|
|
['autorelaxed' => 'Autorelaxed', 'auto' => 'Auto']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildRailAdsGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-layout-sidebar me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Rail Ads (Margenes Laterales)';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
$html .= ' <p class="small text-muted mb-3">Anuncios fijos en los espacios laterales del viewport. Solo visibles en pantallas >= 1600px.</p>';
|
|
|
|
|
|
|
|
|
|
// 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 .= '<div class="row g-2 mt-2">';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$leftEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'rail_left_enabled', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'RailLeftEnabled', 'Rail izquierdo', $leftEnabled);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= ' <div class="col-6">';
|
|
|
|
|
$rightEnabled = $this->renderer->getFieldValue($cid, 'behavior', 'rail_right_enabled', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'RailRightEnabled', 'Rail derecho', $rightEnabled);
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
// Format select
|
|
|
|
|
$railFormat = $this->renderer->getFieldValue($cid, 'behavior', 'rail_format', 'skyscraper');
|
|
|
|
|
$html .= $this->buildSelect($cid . 'RailFormat', 'Formato',
|
|
|
|
|
$railFormat,
|
|
|
|
|
['skyscraper' => 'Skyscraper (160x600)', 'half-page' => 'Half Page (300x600)']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Top offset
|
|
|
|
|
$topOffset = $this->renderer->getFieldValue($cid, 'behavior', 'rail_top_offset', '150');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'RailTopOffset', 'Distancia desde arriba (px)', $topOffset);
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildArchiveLocationsGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-grid me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Ubicaciones Archives/Globales';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
|
|
|
|
|
// Archive locations
|
|
|
|
|
$archiveTopEnabled = $this->renderer->getFieldValue($cid, 'layout', 'archive_top_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'ArchiveTopEnabled', 'Arriba del listado', $archiveTopEnabled);
|
|
|
|
|
|
|
|
|
|
$archiveBetweenEnabled = $this->renderer->getFieldValue($cid, 'layout', 'archive_between_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'ArchiveBetweenEnabled', 'Entre posts del listado', $archiveBetweenEnabled);
|
|
|
|
|
|
|
|
|
|
$archiveEvery = $this->renderer->getFieldValue($cid, 'layout', 'archive_between_every', '4');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'ArchiveBetweenEvery', 'Mostrar cada X posts', $archiveEvery);
|
|
|
|
|
|
|
|
|
|
$archiveBottomEnabled = $this->renderer->getFieldValue($cid, 'layout', 'archive_bottom_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'ArchiveBottomEnabled', 'Abajo del listado', $archiveBottomEnabled);
|
|
|
|
|
|
|
|
|
|
// Archive format (aplica a todas las ubicaciones archive)
|
|
|
|
|
$html .= $this->buildSelect($cid . 'ArchiveFormat', 'Formato para archives',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'layout', 'archive_format', 'autorelaxed'),
|
|
|
|
|
['autorelaxed' => 'Autorelaxed', 'auto' => 'Auto']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$html .= '<hr class="my-3">';
|
|
|
|
|
$html .= '<p class="small text-muted mb-2"><strong>Ubicaciones Globales</strong></p>';
|
|
|
|
|
|
|
|
|
|
// Global locations
|
|
|
|
|
$headerBelowEnabled = $this->renderer->getFieldValue($cid, 'layout', 'header_below_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'HeaderBelowEnabled', 'Debajo del header (global)', $headerBelowEnabled);
|
|
|
|
|
|
|
|
|
|
$footerAboveEnabled = $this->renderer->getFieldValue($cid, 'layout', 'footer_above_enabled', false);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'FooterAboveEnabled', 'Arriba del footer (global)', $footerAboveEnabled);
|
|
|
|
|
|
|
|
|
|
// Global format
|
|
|
|
|
$html .= $this->buildSelect($cid . 'GlobalFormat', 'Formato para globales',
|
|
|
|
|
$this->renderer->getFieldValue($cid, 'layout', 'global_format', 'auto'),
|
|
|
|
|
['auto' => 'Auto', 'display-large' => 'Display Large (970x250)']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildExclusionsGroup(string $cid): string
|
|
|
|
|
{
|
|
|
|
|
$html = '<div class="card shadow-sm mb-3" style="border-left: 4px solid #1e3a5f;">';
|
|
|
|
|
$html .= ' <div class="card-body">';
|
|
|
|
|
$html .= ' <h5 class="fw-bold mb-3" style="color: #1e3a5f;">';
|
|
|
|
|
$html .= ' <i class="bi bi-slash-circle me-2" style="color: #FF8600;"></i>';
|
|
|
|
|
$html .= ' Exclusiones y Rendimiento';
|
|
|
|
|
$html .= ' </h5>';
|
|
|
|
|
|
|
|
|
|
// Exclusions
|
|
|
|
|
$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);
|
|
|
|
|
|
|
|
|
|
// Delay settings
|
|
|
|
|
$delayEnabled = $this->renderer->getFieldValue($cid, 'forms', 'delay_enabled', true);
|
|
|
|
|
$html .= $this->buildSwitch($cid . 'DelayEnabled', 'Retrasar carga de anuncios', $delayEnabled, 'bi-hourglass-split');
|
|
|
|
|
|
|
|
|
|
$delayTimeout = $this->renderer->getFieldValue($cid, 'forms', 'delay_timeout', '5000');
|
|
|
|
|
$html .= $this->buildTextInput($cid . 'DelayTimeout', 'Timeout de delay (ms)', $delayTimeout);
|
|
|
|
|
|
|
|
|
|
$html .= ' </div>';
|
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// === HELPERS ===
|
|
|
|
|
|
|
|
|
|
private function buildSwitch(string $id, string $label, $value, string $icon = ''): string
|
|
|
|
|
{
|
|
|
|
|
$checked = checked($value, true, false);
|
|
|
|
|
$iconHtml = $icon ? '<i class="bi ' . $icon . ' me-1" style="color: #FF8600;"></i>' : '';
|
|
|
|
|
|
|
|
|
|
return sprintf(
|
|
|
|
|
'<div class="mb-2">
|
|
|
|
|
<div class="form-check form-switch">
|
|
|
|
|
<input class="form-check-input" type="checkbox" id="%s" %s>
|
|
|
|
|
<label class="form-check-label small" for="%s">%s%s</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>',
|
|
|
|
|
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(
|
|
|
|
|
'<div class="mb-3">
|
|
|
|
|
<label for="%s" class="form-label small fw-semibold">%s</label>
|
|
|
|
|
<input type="text" class="form-control form-control-sm" id="%s" value="%s" placeholder="%s">
|
|
|
|
|
</div>',
|
|
|
|
|
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(
|
|
|
|
|
'<div class="mb-3">
|
|
|
|
|
<label for="%s" class="form-label small fw-semibold">%s</label>
|
|
|
|
|
<textarea class="form-control form-control-sm" id="%s" rows="2" placeholder="%s">%s</textarea>
|
|
|
|
|
</div>',
|
|
|
|
|
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(
|
|
|
|
|
'<option value="%s" %s>%s</option>',
|
|
|
|
|
esc_attr($optValue),
|
|
|
|
|
$selected,
|
|
|
|
|
esc_html($optLabel)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sprintf(
|
|
|
|
|
'<div class="mb-2">
|
|
|
|
|
<label for="%s" class="form-label small fw-semibold">%s</label>
|
|
|
|
|
<select class="form-select form-select-sm" id="%s">%s</select>
|
|
|
|
|
</div>',
|
|
|
|
|
esc_attr($id), esc_html($label), esc_attr($id), $optionsHtml
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|