feat(dashboard): cards colapsables en Analytics Dashboard

- Convertir 9 cards a estructura colapsable con Bootstrap 5 Collapse
- Headers fuera de cards como botones clickeables
- Cards contraídos por defecto para reducir scroll
- Añadir animación de rotación del chevron (180°)
- Ajustar selector JS de loading overlay a .collapsible-section
- CSS para estados hover, focus y bordes redondeados

Cards modificados:
1. CTR 0% (collapse-ctr-zero)
2. Quick Wins (collapse-quick-wins)
3. Contenido Decadencia (collapse-decay)
4. Contenido Estrella (collapse-star)
5. Infraposicionados (collapse-infrapos)
6. Click Distribution (collapse-click-dist)
7. Top Búsquedas (collapse-top-searches)
8. Top Clicks (collapse-top-clicks)
9. Sin Resultados (collapse-zero-results)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
FrankZamora
2025-12-04 19:58:01 -06:00
parent 9acfd0a495
commit 287de596f2
3 changed files with 614 additions and 414 deletions

View File

@@ -212,6 +212,89 @@ body .card {
font-size: 0.875rem; font-size: 0.875rem;
} }
/* =================================================================
Collapsible Cards
================================================================= */
.dashboard-analytics-wrap .collapsible-section {
margin-bottom: 1rem;
}
.dashboard-analytics-wrap .collapsible-header {
cursor: pointer;
transition: all 0.2s ease;
text-align: left;
font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}
.dashboard-analytics-wrap .collapsible-header:hover {
filter: brightness(1.1);
}
.dashboard-analytics-wrap .collapsible-header:focus {
outline: none;
box-shadow: 0 0 0 2px rgba(255, 134, 0, 0.5);
}
/* Chevron rotation */
.dashboard-analytics-wrap .collapse-chevron {
transition: transform 0.3s ease;
font-size: 1rem;
}
.dashboard-analytics-wrap .collapsible-header:not(.collapsed) .collapse-chevron {
transform: rotate(180deg);
}
/* Header bordes */
.dashboard-analytics-wrap .collapsible-header {
border-radius: 0.375rem;
}
.dashboard-analytics-wrap .collapsible-header:not(.collapsed) {
border-radius: 0.375rem 0.375rem 0 0;
}
/* Card sin borde superior cuando está expandido */
.dashboard-analytics-wrap .collapsible-section .card {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-top: none;
}
/* Loading en collapsible section */
.dashboard-analytics-wrap .collapsible-section.is-loading-table {
position: relative;
pointer-events: none;
}
.dashboard-analytics-wrap .collapsible-section.is-loading-table::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.7);
z-index: 10;
border-radius: 0.375rem;
}
.dashboard-analytics-wrap .collapsible-section.is-loading-table::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 24px;
height: 24px;
margin: -12px 0 0 -12px;
border: 3px solid #f3f3f3;
border-top: 3px solid #FF8600;
border-radius: 50%;
z-index: 11;
animation: spin 0.8s linear infinite;
}
/* ================================================================= /* =================================================================
Responsive Responsive
================================================================= */ ================================================================= */

View File

@@ -99,10 +99,10 @@
return; return;
} }
// Find the card container and add loading state (keeps size, shows overlay) // Find the collapsible section container and add loading state (keeps size, shows overlay)
var card = tbody.closest('.card'); var section = tbody.closest('.collapsible-section');
if (card) { if (section) {
card.classList.add('is-loading-table'); section.classList.add('is-loading-table');
} }
// Build form data // Build form data
@@ -157,8 +157,8 @@
tbody.innerHTML = html; tbody.innerHTML = html;
// Remove loading state // Remove loading state
if (card) { if (section) {
card.classList.remove('is-loading-table'); section.classList.remove('is-loading-table');
} }
// Update pagination // Update pagination
@@ -167,16 +167,16 @@
bindPaginationEvents(paginationDiv, tableId); bindPaginationEvents(paginationDiv, tableId);
} }
} else { } else {
if (card) { if (section) {
card.classList.remove('is-loading-table'); section.classList.remove('is-loading-table');
} }
showErrorMessage('Error al cargar datos'); showErrorMessage('Error al cargar datos');
console.error('AJAX error:', result); console.error('AJAX error:', result);
} }
}) })
.catch(function(error) { .catch(function(error) {
if (card) { if (section) {
card.classList.remove('is-loading-table'); section.classList.remove('is-loading-table');
} }
console.error('Fetch error:', error); console.error('Fetch error:', error);
showErrorMessage('Error de conexión'); showErrorMessage('Error de conexión');

View File

@@ -480,43 +480,56 @@ final class ROI_APU_Analytics_Dashboard
<!-- 🟡 REVISAR: Títulos con CTR 0% --> <!-- 🟡 REVISAR: Títulos con CTR 0% -->
<?php if (!empty($ctr_zero)) : ?> <?php if (!empty($ctr_zero)) : ?>
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #f59e0b;"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #f59e0b; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-ctr-zero"
aria-expanded="false"
aria-controls="collapse-ctr-zero"
style="background-color: #f59e0b; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-pencil-square"></i> <i class="bi bi-pencil-square"></i>
<?php esc_html_e('REVISAR: Títulos con CTR 0%', 'roi-apu-search'); ?> <strong><?php esc_html_e('REVISAR: Títulos con CTR 0%', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo count($ctr_zero); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo count($ctr_zero); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Estos términos tienen resultados pero nadie hace click. Mejora títulos y descripciones.', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-ctr-zero">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #f59e0b;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Estos términos tienen resultados pero nadie hace click. Mejora títulos y descripciones.', 'roi-apu-search'); ?>
<th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Resultados', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Búsquedas', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <thead class="table-light">
</tr> <tr>
</thead> <th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th>
<tbody> <th class="text-center"><?php esc_html_e('Resultados', 'roi-apu-search'); ?></th>
<?php foreach ($ctr_zero as $term) : ?> <th class="text-center"><?php esc_html_e('Búsquedas', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td> </tr>
<td class="text-center"><?php echo esc_html(number_format((int)$term['resultados'])); ?></td> </thead>
<td class="text-center"> <tbody>
<span class="badge bg-warning text-dark"><?php echo esc_html(number_format((int)$term['busquedas'])); ?></span> <?php foreach ($ctr_zero as $term) : ?>
</td> <tr>
<td class="text-center"> <td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td>
<span class="badge bg-danger">0</span> <td class="text-center"><?php echo esc_html(number_format((int)$term['resultados'])); ?></td>
</td> <td class="text-center">
</tr> <span class="badge bg-warning text-dark"><?php echo esc_html(number_format((int)$term['busquedas'])); ?></span>
<?php endforeach; ?> </td>
</tbody> <td class="text-center">
</table> <span class="badge bg-danger">0</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -524,41 +537,54 @@ final class ROI_APU_Analytics_Dashboard
<!-- 🎯 QUICK WINS: Oportunidades Fáciles --> <!-- 🎯 QUICK WINS: Oportunidades Fáciles -->
<?php if (!empty($quick_wins)) : ?> <?php if (!empty($quick_wins)) : ?>
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #0284c7;"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #0284c7; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-quick-wins"
aria-expanded="false"
aria-controls="collapse-quick-wins"
style="background-color: #0284c7; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-bullseye"></i> <i class="bi bi-bullseye"></i>
<?php esc_html_e('QUICK WINS: Oportunidades Fáciles', 'roi-apu-search'); ?> <strong><?php esc_html_e('QUICK WINS: Oportunidades Fáciles', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo count($quick_wins); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo count($quick_wins); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Términos con clicks que no están en top 1. Una pequeña mejora = más visibilidad.', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-quick-wins">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #0284c7;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Términos con clicks que no están en top 1. Una pequeña mejora = más visibilidad.', 'roi-apu-search'); ?>
<th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('CTR', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
</tr> <thead class="table-light">
</thead> <tr>
<tbody> <th style="width: 50%;"><?php esc_html_e('Término buscado', 'roi-apu-search'); ?></th>
<?php foreach ($quick_wins as $term) : ?> <th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('CTR', 'roi-apu-search'); ?></th>
<td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td> </tr>
<td class="text-center"> </thead>
<span class="badge bg-secondary"><?php echo esc_html($term['pos_prom']); ?></span> <tbody>
</td> <?php foreach ($quick_wins as $term) : ?>
<td class="text-center"> <tr>
<span class="badge bg-info text-dark"><?php echo esc_html($term['ctr']); ?>%</span> <td><strong><?php echo esc_html(mb_strimwidth($term['q_term'], 0, 60, '...')); ?></strong></td>
</td> <td class="text-center">
</tr> <span class="badge bg-secondary"><?php echo esc_html($term['pos_prom']); ?></span>
<?php endforeach; ?> </td>
</tbody> <td class="text-center">
</table> <span class="badge bg-info text-dark"><?php echo esc_html($term['ctr']); ?>%</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -566,54 +592,67 @@ final class ROI_APU_Analytics_Dashboard
<!-- 📉 ATENCIÓN: Contenido en Decadencia --> <!-- 📉 ATENCIÓN: Contenido en Decadencia -->
<?php if (!empty($decay_content)) : ?> <?php if (!empty($decay_content)) : ?>
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #6b7280;"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #6b7280; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-decay"
aria-expanded="false"
aria-controls="collapse-decay"
style="background-color: #6b7280; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-graph-down"></i> <i class="bi bi-graph-down"></i>
<?php esc_html_e('ATENCIÓN: Contenido en Decadencia', 'roi-apu-search'); ?> <strong><?php esc_html_e('ATENCIÓN: Contenido en Decadencia', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo count($decay_content); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo count($decay_content); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Posts que perdieron >20% clicks vs período anterior. Revisa si están desactualizados.', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-decay">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #6b7280;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Posts que perdieron >20% clicks vs período anterior. Revisa si están desactualizados.', 'roi-apu-search'); ?>
<th style="width: 50%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Cambio', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Antes', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('Ahora', 'roi-apu-search'); ?></th> <thead class="table-light">
<th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th> <tr>
</tr> <th style="width: 50%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th>
</thead> <th class="text-center"><?php esc_html_e('Cambio', 'roi-apu-search'); ?></th>
<tbody> <th class="text-center"><?php esc_html_e('Antes', 'roi-apu-search'); ?></th>
<?php foreach ($decay_content as $post) : ?> <th class="text-center"><?php esc_html_e('Ahora', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th>
<td> </tr>
<strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong> </thead>
</td> <tbody>
<td class="text-center"> <?php foreach ($decay_content as $post) : ?>
<span class="badge bg-danger"><?php echo esc_html($post['cambio_pct']); ?>%</span> <tr>
</td> <td>
<td class="text-center"><?php echo esc_html($post['clicks_anterior']); ?></td> <strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong>
<td class="text-center"><?php echo esc_html($post['clicks_actual']); ?></td> </td>
<td class="text-center"> <td class="text-center">
<div class="btn-group btn-group-sm" role="group"> <span class="badge bg-danger"><?php echo esc_html($post['cambio_pct']); ?>%</span>
<a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>"> </td>
<i class="bi bi-pencil"></i> <td class="text-center"><?php echo esc_html($post['clicks_anterior']); ?></td>
</a> <td class="text-center"><?php echo esc_html($post['clicks_actual']); ?></td>
<a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-secondary" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>"> <td class="text-center">
<i class="bi bi-box-arrow-up-right"></i> <div class="btn-group btn-group-sm" role="group">
</a> <a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>">
</div> <i class="bi bi-pencil"></i>
</td> </a>
</tr> <a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-secondary" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>">
<?php endforeach; ?> <i class="bi bi-box-arrow-up-right"></i>
</tbody> </a>
</table> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -621,52 +660,65 @@ final class ROI_APU_Analytics_Dashboard
<!-- 🟢 MANTENER: Tu Contenido Estrella --> <!-- 🟢 MANTENER: Tu Contenido Estrella -->
<?php if (!empty($contenido_estrella)) : ?> <?php if (!empty($contenido_estrella)) : ?>
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #22c55e;"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #22c55e; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-star"
aria-expanded="false"
aria-controls="collapse-star"
style="background-color: #22c55e; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-star-fill"></i> <i class="bi bi-star-fill"></i>
<?php esc_html_e('MANTENER: Tu Contenido Estrella', 'roi-apu-search'); ?> <strong><?php esc_html_e('MANTENER: Tu Contenido Estrella', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo count($contenido_estrella); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo count($contenido_estrella); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Posts con más clicks. Mantén este contenido actualizado y optimizado.', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-star">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #22c55e;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Posts con más clicks. Mantén este contenido actualizado y optimizado.', 'roi-apu-search'); ?>
<th style="width: 55%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th> <thead class="table-light">
</tr> <tr>
</thead> <th style="width: 55%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th>
<tbody> <th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<?php foreach ($contenido_estrella as $post) : ?> <th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th>
<td> </tr>
<strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong> </thead>
</td> <tbody>
<td class="text-center"> <?php foreach ($contenido_estrella as $post) : ?>
<span class="badge bg-success"><?php echo esc_html(number_format((int)$post['clicks'])); ?></span> <tr>
</td> <td>
<td class="text-center"><?php echo esc_html($post['pos_prom']); ?></td> <strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong>
<td class="text-center"> </td>
<div class="btn-group btn-group-sm" role="group"> <td class="text-center">
<a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>"> <span class="badge bg-success"><?php echo esc_html(number_format((int)$post['clicks'])); ?></span>
<i class="bi bi-pencil"></i> </td>
</a> <td class="text-center"><?php echo esc_html($post['pos_prom']); ?></td>
<a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-success" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>"> <td class="text-center">
<i class="bi bi-box-arrow-up-right"></i> <div class="btn-group btn-group-sm" role="group">
</a> <a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>">
</div> <i class="bi bi-pencil"></i>
</td> </a>
</tr> <a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-success" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>">
<?php endforeach; ?> <i class="bi bi-box-arrow-up-right"></i>
</tbody> </a>
</table> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -674,54 +726,67 @@ final class ROI_APU_Analytics_Dashboard
<!-- Posts infraposicionados --> <!-- Posts infraposicionados -->
<?php if (!empty($infraposicionados)) : ?> <?php if (!empty($infraposicionados)) : ?>
<div class="card mb-4 shadow-sm" style="border-left: 4px solid #f59e0b;"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #f59e0b; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-infrapos"
aria-expanded="false"
aria-controls="collapse-infrapos"
style="background-color: #f59e0b; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-arrow-up-circle"></i> <i class="bi bi-arrow-up-circle"></i>
<?php esc_html_e('OPORTUNIDAD: Posts Infraposicionados', 'roi-apu-search'); ?> <strong><?php esc_html_e('OPORTUNIDAD: Posts Infraposicionados', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo count($infraposicionados); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo count($infraposicionados); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Estos posts reciben clicks pero aparecen muy abajo. Considera mejorar su scoring.', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-infrapos">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #f59e0b;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Estos posts reciben clicks pero aparecen muy abajo. Considera mejorar su scoring.', 'roi-apu-search'); ?>
<th style="width: 50%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th> <thead class="table-light">
</tr> <tr>
</thead> <th style="width: 50%;"><?php esc_html_e('Título', 'roi-apu-search'); ?></th>
<tbody> <th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<?php foreach ($infraposicionados as $post) : ?> <th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th>
<td> </tr>
<strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong> </thead>
</td> <tbody>
<td class="text-center"> <?php foreach ($infraposicionados as $post) : ?>
<span class="badge bg-warning text-dark"><?php echo esc_html(number_format((int)$post['clicks'])); ?></span> <tr>
</td> <td>
<td class="text-center"> <strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong>
<span class="badge bg-secondary"><?php echo esc_html($post['pos_prom']); ?></span> </td>
</td> <td class="text-center">
<td class="text-center"> <span class="badge bg-warning text-dark"><?php echo esc_html(number_format((int)$post['clicks'])); ?></span>
<div class="btn-group btn-group-sm" role="group"> </td>
<a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>"> <td class="text-center">
<i class="bi bi-pencil"></i> <span class="badge bg-secondary"><?php echo esc_html($post['pos_prom']); ?></span>
</a> </td>
<a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-warning" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>"> <td class="text-center">
<i class="bi bi-box-arrow-up-right"></i> <div class="btn-group btn-group-sm" role="group">
</a> <a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>">
</div> <i class="bi bi-pencil"></i>
</td> </a>
</tr> <a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-warning" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>">
<?php endforeach; ?> <i class="bi bi-box-arrow-up-right"></i>
</tbody> </a>
</table> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -738,224 +803,276 @@ final class ROI_APU_Analytics_Dashboard
<!-- 📊 Click Distribution --> <!-- 📊 Click Distribution -->
<?php if (!empty($click_distribution)) : ?> <?php if (!empty($click_distribution)) : ?>
<div class="card mb-4 shadow-sm"> <div class="collapsible-section">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #0E2337; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-click-dist"
aria-expanded="false"
aria-controls="collapse-click-dist"
style="background-color: #0E2337; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-bar-chart-fill"></i> <i class="bi bi-bar-chart-fill"></i>
<?php esc_html_e('Distribución de Clicks por Posición', 'roi-apu-search'); ?> <strong><?php esc_html_e('Distribución de Clicks por Posición', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo esc_html(array_sum(array_column($click_distribution, 'clicks'))); ?> <?php esc_html_e('clicks totales', 'roi-apu-search'); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo esc_html(array_sum(array_column($click_distribution, 'clicks'))); ?> <?php esc_html_e('clicks totales', 'roi-apu-search'); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<div class="table-responsive"> </span>
<table class="table table-striped table-hover mb-0"> </button>
<thead class="table-light"> <div class="collapse" id="collapse-click-dist">
<tr> <div class="card shadow-sm">
<th style="width: 15%;"><?php esc_html_e('Posición', 'roi-apu-search'); ?></th> <div class="card-body p-0">
<th class="text-center" style="width: 20%;"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center" style="width: 15%;"><?php esc_html_e('Porcentaje', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th style="width: 50%;"><?php esc_html_e('Distribución', 'roi-apu-search'); ?></th> <thead class="table-light">
</tr> <tr>
</thead> <th style="width: 15%;"><?php esc_html_e('Posición', 'roi-apu-search'); ?></th>
<tbody> <th class="text-center" style="width: 20%;"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<?php <th class="text-center" style="width: 15%;"><?php esc_html_e('Porcentaje', 'roi-apu-search'); ?></th>
$position_colors = [ <th style="width: 50%;"><?php esc_html_e('Distribución', 'roi-apu-search'); ?></th>
'Pos 1' => '#FF8600', </tr>
'Pos 2' => '#1e3a5f', </thead>
'Pos 3' => '#2c5282', <tbody>
'Pos 4' => '#3d6894', <?php
'Pos 5' => '#4a7eb0', $position_colors = [
'Pos 6' => '#5a8ec0', 'Pos 1' => '#FF8600',
'Pos 7' => '#6a9ed0', 'Pos 2' => '#1e3a5f',
'Pos 8' => '#7aaee0', 'Pos 3' => '#2c5282',
'Pos 9' => '#8abef0', 'Pos 4' => '#3d6894',
'Pos 10' => '#9aceff', 'Pos 5' => '#4a7eb0',
'Pos 11+' => '#6b7280', 'Pos 6' => '#5a8ec0',
]; 'Pos 7' => '#6a9ed0',
foreach ($click_distribution as $dist) : 'Pos 8' => '#7aaee0',
$color = $position_colors[$dist['posicion']] ?? '#6b7280'; 'Pos 9' => '#8abef0',
?> 'Pos 10' => '#9aceff',
<tr> 'Pos 11+' => '#6b7280',
<td><strong><?php echo esc_html($dist['posicion']); ?></strong></td> ];
<td class="text-center"> foreach ($click_distribution as $dist) :
<span class="badge" style="background-color: <?php echo esc_attr($color); ?>;"> $color = $position_colors[$dist['posicion']] ?? '#6b7280';
<?php echo esc_html(number_format((int)$dist['clicks'])); ?> ?>
</span> <tr>
</td> <td><strong><?php echo esc_html($dist['posicion']); ?></strong></td>
<td class="text-center"><?php echo esc_html($dist['porcentaje']); ?>%</td> <td class="text-center">
<td> <span class="badge" style="background-color: <?php echo esc_attr($color); ?>;">
<div class="progress" style="height: 18px;"> <?php echo esc_html(number_format((int)$dist['clicks'])); ?>
<div class="progress-bar" role="progressbar" </span>
style="width: <?php echo esc_attr($dist['porcentaje']); ?>%; background-color: <?php echo esc_attr($color); ?>;" </td>
aria-valuenow="<?php echo esc_attr($dist['porcentaje']); ?>" <td class="text-center"><?php echo esc_html($dist['porcentaje']); ?>%</td>
aria-valuemin="0" <td>
aria-valuemax="100"> <div class="progress" style="height: 18px;">
</div> <div class="progress-bar" role="progressbar"
</div> style="width: <?php echo esc_attr($dist['porcentaje']); ?>%; background-color: <?php echo esc_attr($color); ?>;"
</td> aria-valuenow="<?php echo esc_attr($dist['porcentaje']); ?>"
</tr> aria-valuemin="0"
<?php endforeach; ?> aria-valuemax="100">
</tbody> </div>
</table> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- 📊 Top Búsquedas Table --> <!-- 📊 Top Búsquedas Table -->
<div class="card mb-4 shadow-sm"> <div class="collapsible-section" id="section-top-searches">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #1e3a5f; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-top-searches"
aria-expanded="false"
aria-controls="collapse-top-searches"
style="background-color: #1e3a5f; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-search"></i> <i class="bi bi-search"></i>
<?php esc_html_e('Top Búsquedas', 'roi-apu-search'); ?> <strong><?php esc_html_e('Top Búsquedas', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_searches']); ?> <?php esc_html_e('términos', 'roi-apu-search'); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_searches']); ?> <?php esc_html_e('términos', 'roi-apu-search'); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<div class="table-responsive"> </span>
<table class="table table-striped table-hover mb-0"> </button>
<thead class="table-light"> <div class="collapse" id="collapse-top-searches">
<tr> <div class="card shadow-sm">
<th><?php esc_html_e('Término', 'roi-apu-search'); ?></th> <div class="card-body p-0">
<th class="text-center"><?php esc_html_e('Búsquedas', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('CTR', 'roi-apu-search'); ?></th> <thead class="table-light">
<th class="text-center"><?php esc_html_e('Resultados', 'roi-apu-search'); ?></th> <tr>
</tr> <th><?php esc_html_e('Término', 'roi-apu-search'); ?></th>
</thead> <th class="text-center"><?php esc_html_e('Búsquedas', 'roi-apu-search'); ?></th>
<tbody id="top-searches-body"> <th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<?php foreach ($top_searches as $search) : ?> <th class="text-center"><?php esc_html_e('CTR', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Resultados', 'roi-apu-search'); ?></th>
<td><strong><?php echo esc_html($search['q_term']); ?></strong></td> </tr>
<td class="text-center"><?php echo esc_html(number_format((int)$search['busquedas'])); ?></td> </thead>
<td class="text-center"><?php echo esc_html(number_format((int)$search['clicks'])); ?></td> <tbody id="top-searches-body">
<td class="text-center"> <?php foreach ($top_searches as $search) : ?>
<span class="badge <?php echo (float)$search['ctr'] > 0 ? 'bg-success' : 'bg-secondary'; ?>"> <tr>
<?php echo esc_html($search['ctr']); ?>% <td><strong><?php echo esc_html($search['q_term']); ?></strong></td>
</span> <td class="text-center"><?php echo esc_html(number_format((int)$search['busquedas'])); ?></td>
</td> <td class="text-center"><?php echo esc_html(number_format((int)$search['clicks'])); ?></td>
<td class="text-center"><?php echo esc_html(number_format((int)$search['resultados'])); ?></td> <td class="text-center">
</tr> <span class="badge <?php echo (float)$search['ctr'] > 0 ? 'bg-success' : 'bg-secondary'; ?>">
<?php endforeach; ?> <?php echo esc_html($search['ctr']); ?>%
</tbody> </span>
</table> </td>
<td class="text-center"><?php echo esc_html(number_format((int)$search['resultados'])); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php
$total_search_pages = (int) ceil($total_counts['total_searches'] / self::ITEMS_PER_PAGE);
if ($total_search_pages > 1) :
?>
<div class="card-footer" id="pagination-searches">
<?php echo $this->render_pagination(1, $total_search_pages, 'top-searches'); ?>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php
$total_search_pages = (int) ceil($total_counts['total_searches'] / self::ITEMS_PER_PAGE);
if ($total_search_pages > 1) :
?>
<div class="card-footer" id="pagination-searches">
<?php echo $this->render_pagination(1, $total_search_pages, 'top-searches'); ?>
</div>
<?php endif; ?>
</div> </div>
<!-- 📄 Top Posts Clickeados Table --> <!-- 📄 Top Posts Clickeados Table -->
<div class="card mb-4 shadow-sm"> <div class="collapsible-section" id="section-top-clicks">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #FF8600; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-top-clicks"
aria-expanded="false"
aria-controls="collapse-top-clicks"
style="background-color: #FF8600; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-file-earmark-text"></i> <i class="bi bi-file-earmark-text"></i>
<?php esc_html_e('Top Posts Clickeados', 'roi-apu-search'); ?> <strong><?php esc_html_e('Top Posts Clickeados', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_clicks']); ?> <?php esc_html_e('posts', 'roi-apu-search'); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_clicks']); ?> <?php esc_html_e('posts', 'roi-apu-search'); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<div class="table-responsive"> </span>
<table class="table table-striped table-hover mb-0"> </button>
<thead class="table-light"> <div class="collapse" id="collapse-top-clicks">
<tr> <div class="card shadow-sm">
<th><?php esc_html_e('Título', 'roi-apu-search'); ?></th> <div class="card-body p-0">
<th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
<th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th> <thead class="table-light">
</tr> <tr>
</thead> <th><?php esc_html_e('Título', 'roi-apu-search'); ?></th>
<tbody id="top-clicks-body"> <th class="text-center"><?php esc_html_e('Clicks', 'roi-apu-search'); ?></th>
<?php foreach ($top_clicks as $post) : ?> <th class="text-center"><?php esc_html_e('Pos. Prom.', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Acciones', 'roi-apu-search'); ?></th>
<td> </tr>
<strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong> </thead>
</td> <tbody id="top-clicks-body">
<td class="text-center"><?php echo esc_html(number_format((int)$post['clicks'])); ?></td> <?php foreach ($top_clicks as $post) : ?>
<td class="text-center"> <tr>
<span class="badge <?php echo (float)$post['pos_prom'] <= 3 ? 'bg-success' : ((float)$post['pos_prom'] <= 5 ? 'bg-warning text-dark' : 'bg-secondary'); ?>"> <td>
<?php echo esc_html($post['pos_prom']); ?> <strong><?php echo esc_html(mb_strimwidth($post['post_title'], 0, 80, '...')); ?></strong>
</span> </td>
</td> <td class="text-center"><?php echo esc_html(number_format((int)$post['clicks'])); ?></td>
<td class="text-center"> <td class="text-center">
<div class="btn-group btn-group-sm" role="group"> <span class="badge <?php echo (float)$post['pos_prom'] <= 3 ? 'bg-success' : ((float)$post['pos_prom'] <= 5 ? 'bg-warning text-dark' : 'bg-secondary'); ?>">
<a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>"> <?php echo esc_html($post['pos_prom']); ?>
<i class="bi bi-pencil"></i> </span>
</a> </td>
<a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-secondary" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>"> <td class="text-center">
<i class="bi bi-box-arrow-up-right"></i> <div class="btn-group btn-group-sm" role="group">
</a> <a href="<?php echo esc_url(admin_url('post.php?post=' . $post['post_id'] . '&action=edit')); ?>" target="_blank" class="btn btn-outline-primary" title="<?php esc_attr_e('Editar', 'roi-apu-search'); ?>">
</div> <i class="bi bi-pencil"></i>
</td> </a>
</tr> <a href="<?php echo esc_url($site_url . '/' . $post['post_name'] . '/'); ?>" target="_blank" class="btn btn-outline-secondary" title="<?php esc_attr_e('Ver', 'roi-apu-search'); ?>">
<?php endforeach; ?> <i class="bi bi-box-arrow-up-right"></i>
</tbody> </a>
</table> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php
$total_click_pages = (int) ceil($total_counts['total_clicks'] / self::ITEMS_PER_PAGE);
if ($total_click_pages > 1) :
?>
<div class="card-footer" id="pagination-clicks">
<?php echo $this->render_pagination(1, $total_click_pages, 'top-clicks'); ?>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php
$total_click_pages = (int) ceil($total_counts['total_clicks'] / self::ITEMS_PER_PAGE);
if ($total_click_pages > 1) :
?>
<div class="card-footer" id="pagination-clicks">
<?php echo $this->render_pagination(1, $total_click_pages, 'top-clicks'); ?>
</div>
<?php endif; ?>
</div> </div>
<!-- ❌ Búsquedas Sin Resultados Table --> <!-- ❌ Búsquedas Sin Resultados Table -->
<?php if (!empty($all_zero_results)) : ?> <?php if (!empty($all_zero_results)) : ?>
<div class="card mb-4 shadow-sm"> <div class="collapsible-section" id="section-zero-results">
<div class="card-header d-flex justify-content-between align-items-center" style="background-color: #ef4444; color: white;"> <button class="collapsible-header d-flex justify-content-between align-items-center w-100 p-3 border-0 shadow-sm collapsed"
<h6 class="mb-0 d-flex align-items-center gap-2"> type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-zero-results"
aria-expanded="false"
aria-controls="collapse-zero-results"
style="background-color: #ef4444; color: white;">
<span class="d-flex align-items-center gap-2">
<i class="bi bi-x-circle"></i> <i class="bi bi-x-circle"></i>
<?php esc_html_e('Búsquedas Sin Resultados', 'roi-apu-search'); ?> <strong><?php esc_html_e('Búsquedas Sin Resultados', 'roi-apu-search'); ?></strong>
</h6> </span>
<span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_zero_results']); ?> <?php esc_html_e('términos', 'roi-apu-search'); ?></span> <span class="d-flex align-items-center gap-2">
</div> <span class="badge bg-light text-dark"><?php echo esc_html($total_counts['total_zero_results']); ?> <?php esc_html_e('términos', 'roi-apu-search'); ?></span>
<div class="card-body p-0"> <i class="bi bi-chevron-down collapse-chevron"></i>
<p class="small text-muted px-3 pt-3 mb-2"> </span>
<?php esc_html_e('Los usuarios buscan esto pero NO encuentran nada. ¡Crea este contenido!', 'roi-apu-search'); ?> </button>
</p> <div class="collapse" id="collapse-zero-results">
<div class="table-responsive"> <div class="card shadow-sm" style="border-left: 4px solid #ef4444;">
<table class="table table-striped table-hover mb-0"> <div class="card-body p-0">
<thead class="table-light"> <p class="small text-muted px-3 pt-3 mb-2">
<tr> <?php esc_html_e('Los usuarios buscan esto pero NO encuentran nada. ¡Crea este contenido!', 'roi-apu-search'); ?>
<th><?php esc_html_e('Término', 'roi-apu-search'); ?></th> </p>
<th class="text-center"><?php esc_html_e('Frecuencia', 'roi-apu-search'); ?></th> <div class="table-responsive">
<th class="text-center"><?php esc_html_e('Última búsqueda', 'roi-apu-search'); ?></th> <table class="table table-striped table-hover mb-0">
</tr> <thead class="table-light">
</thead> <tr>
<tbody id="zero-results-body"> <th><?php esc_html_e('Término', 'roi-apu-search'); ?></th>
<?php foreach ($all_zero_results as $term) : ?> <th class="text-center"><?php esc_html_e('Frecuencia', 'roi-apu-search'); ?></th>
<tr> <th class="text-center"><?php esc_html_e('Última búsqueda', 'roi-apu-search'); ?></th>
<td><strong><?php echo esc_html($term['q_term']); ?></strong></td> </tr>
<td class="text-center"> </thead>
<span class="badge bg-danger"><?php echo esc_html(number_format((int)$term['frecuencia'])); ?></span> <tbody id="zero-results-body">
</td> <?php foreach ($all_zero_results as $term) : ?>
<td class="text-center"> <tr>
<small class="text-muted"><?php echo esc_html(date('d/m/Y H:i', strtotime($term['ultima_busqueda']))); ?></small> <td><strong><?php echo esc_html($term['q_term']); ?></strong></td>
</td> <td class="text-center">
</tr> <span class="badge bg-danger"><?php echo esc_html(number_format((int)$term['frecuencia'])); ?></span>
<?php endforeach; ?> </td>
</tbody> <td class="text-center">
</table> <small class="text-muted"><?php echo esc_html(date('d/m/Y H:i', strtotime($term['ultima_busqueda']))); ?></small>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php
$total_zero_pages = (int) ceil($total_counts['total_zero_results'] / self::ITEMS_PER_PAGE);
if ($total_zero_pages > 1) :
?>
<div class="card-footer" id="pagination-zero-results">
<?php echo $this->render_pagination(1, $total_zero_pages, 'zero-results'); ?>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php
$total_zero_pages = (int) ceil($total_counts['total_zero_results'] / self::ITEMS_PER_PAGE);
if ($total_zero_pages > 1) :
?>
<div class="card-footer" id="pagination-zero-results">
<?php echo $this->render_pagination(1, $total_zero_pages, 'zero-results'); ?>
</div>
<?php endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>