Agregar plugin WP Debug para diagnóstico sistemático

This commit is contained in:
FrankZamora
2025-11-06 22:57:52 -06:00
parent 9670659267
commit 7e422d5499
16 changed files with 4105 additions and 0 deletions

View File

@@ -0,0 +1,457 @@
/**
* WP Debug Frontend Panel Styles
*
* @package WP_Debug
* @since 1.0.0
*/
/* Toggle Button */
.wp-debug-toggle {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 99998;
background: #2271b1;
color: #fff;
border: none;
border-radius: 4px;
padding: 10px 15px;
cursor: pointer;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
display: flex;
align-items: center;
gap: 8px;
font-size: 14px;
font-weight: 500;
transition: all 0.3s ease;
}
.wp-debug-toggle:hover {
background: #135e96;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.wp-debug-toggle .dashicons {
font-size: 18px;
width: 18px;
height: 18px;
}
.wp-debug-toggle .label {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
/* Main Panel */
.wp-debug-panel {
position: fixed;
bottom: 80px;
right: 20px;
width: 800px;
max-width: calc(100vw - 40px);
max-height: calc(100vh - 120px);
background: #fff;
border-radius: 8px;
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
z-index: 99999;
overflow: hidden;
display: flex;
flex-direction: column;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
/* Panel Header */
.wp-debug-panel-header {
background: #2271b1;
color: #fff;
padding: 15px 20px;
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
border-bottom: 3px solid #135e96;
}
.wp-debug-panel-header h3 {
margin: 0;
font-size: 18px;
font-weight: 600;
color: #fff;
}
/* Tabs */
.wp-debug-panel-tabs {
display: flex;
gap: 5px;
margin: 0 auto;
}
.wp-debug-tab {
background: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.8);
border: none;
border-radius: 4px;
padding: 6px 12px;
cursor: pointer;
font-size: 13px;
transition: all 0.2s ease;
}
.wp-debug-tab:hover {
background: rgba(255, 255, 255, 0.2);
color: #fff;
}
.wp-debug-tab.active {
background: #fff;
color: #2271b1;
font-weight: 600;
}
/* Close Button */
.wp-debug-panel-close {
background: rgba(255, 255, 255, 0.1);
color: #fff;
border: none;
width: 32px;
height: 32px;
border-radius: 4px;
cursor: pointer;
font-size: 24px;
line-height: 1;
transition: all 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
}
.wp-debug-panel-close:hover {
background: rgba(255, 255, 255, 0.2);
}
/* Panel Content */
.wp-debug-panel-content {
padding: 20px;
overflow-y: auto;
flex: 1;
background: #f9f9f9;
}
.wp-debug-tab-content {
display: none;
}
.wp-debug-tab-content.active {
display: block;
}
/* Typography */
.wp-debug-panel-content h4 {
margin: 0 0 15px 0;
font-size: 16px;
font-weight: 600;
color: #1d2327;
border-bottom: 2px solid #2271b1;
padding-bottom: 8px;
}
.wp-debug-panel-content h5 {
margin: 20px 0 10px 0;
font-size: 14px;
font-weight: 600;
color: #1d2327;
}
.wp-debug-panel-content p {
margin: 10px 0;
color: #50575e;
line-height: 1.6;
}
/* Tables */
.wp-debug-table {
width: 100%;
border-collapse: collapse;
background: #fff;
border-radius: 4px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
margin: 10px 0 20px 0;
}
.wp-debug-table thead {
background: #f0f0f1;
}
.wp-debug-table th {
padding: 12px;
text-align: left;
font-weight: 600;
font-size: 13px;
color: #1d2327;
border-bottom: 2px solid #dcdcde;
}
.wp-debug-table td {
padding: 10px 12px;
border-bottom: 1px solid #f0f0f1;
font-size: 13px;
color: #50575e;
}
.wp-debug-table tr:last-child td {
border-bottom: none;
}
.wp-debug-table tr:hover {
background: #f9f9f9;
}
.wp-debug-table code {
background: #f0f0f1;
padding: 2px 6px;
border-radius: 3px;
font-size: 12px;
color: #d63638;
font-family: "Courier New", Courier, monospace;
}
/* Lists */
.wp-debug-list {
list-style: none;
padding: 0;
margin: 10px 0;
}
.wp-debug-list li {
background: #fff;
padding: 10px 12px;
margin-bottom: 5px;
border-radius: 4px;
border-left: 3px solid #2271b1;
display: flex;
align-items: center;
gap: 10px;
font-size: 13px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.wp-debug-list li.missing {
border-left-color: #d63638;
}
.wp-debug-list li.duplicate {
border-left-color: #dba617;
}
.wp-debug-list code {
background: #f0f0f1;
padding: 2px 6px;
border-radius: 3px;
font-size: 12px;
font-family: "Courier New", Courier, monospace;
}
/* Module List */
.wp-debug-module-list {
list-style: none;
padding: 0;
margin: 0;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 10px;
}
.wp-debug-module-list li {
background: #fff;
padding: 10px;
border-radius: 4px;
font-size: 13px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
/* Status Badges */
.status-active {
display: inline-block;
padding: 2px 8px;
background: #00a32a;
color: #fff;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.status-inactive {
display: inline-block;
padding: 2px 8px;
background: #dcdcde;
color: #50575e;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.status-error {
display: inline-block;
padding: 2px 8px;
background: #d63638;
color: #fff;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.template-type {
display: inline-block;
padding: 2px 8px;
background: #f0f0f1;
color: #2271b1;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
}
/* Query Items */
.wp-debug-queries {
display: flex;
flex-direction: column;
gap: 10px;
margin: 10px 0;
}
.query-item {
background: #fff;
padding: 12px;
border-radius: 4px;
border-left: 3px solid #2271b1;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.query-item.n-plus-one {
border-left-color: #d63638;
}
.query-time {
display: inline-block;
padding: 2px 6px;
background: #f0f0f1;
color: #d63638;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
margin-bottom: 8px;
}
.query-count {
display: inline-block;
padding: 2px 6px;
background: #d63638;
color: #fff;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
margin-bottom: 8px;
margin-right: 5px;
}
.query-sql {
display: block;
background: #f9f9f9;
padding: 8px;
border-radius: 3px;
font-size: 12px;
color: #1d2327;
font-family: "Courier New", Courier, monospace;
word-break: break-all;
}
.count {
background: #dba617;
color: #fff;
padding: 2px 6px;
border-radius: 3px;
font-size: 11px;
font-weight: 600;
}
/* Scrollbar */
.wp-debug-panel-content::-webkit-scrollbar {
width: 8px;
}
.wp-debug-panel-content::-webkit-scrollbar-track {
background: #f0f0f1;
}
.wp-debug-panel-content::-webkit-scrollbar-thumb {
background: #c3c4c7;
border-radius: 4px;
}
.wp-debug-panel-content::-webkit-scrollbar-thumb:hover {
background: #a7aaad;
}
/* Responsive */
@media (max-width: 768px) {
.wp-debug-panel {
width: calc(100vw - 40px);
bottom: 80px;
right: 20px;
max-height: calc(100vh - 120px);
}
.wp-debug-panel-header {
flex-direction: column;
gap: 10px;
align-items: flex-start;
}
.wp-debug-panel-tabs {
width: 100%;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
.wp-debug-tab {
white-space: nowrap;
}
.wp-debug-panel-close {
position: absolute;
top: 15px;
right: 15px;
}
.wp-debug-module-list {
grid-template-columns: 1fr;
}
.wp-debug-table {
font-size: 12px;
}
.wp-debug-table th,
.wp-debug-table td {
padding: 8px;
}
}
/* Animation */
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.wp-debug-panel[data-visible="true"] {
animation: slideUp 0.3s ease;
}

View File

@@ -0,0 +1,229 @@
/**
* WP Debug Frontend Panel JavaScript
*
* @package WP_Debug
* @since 1.0.0
*/
(function($) {
'use strict';
/**
* WP Debug Panel
*/
const WPDebugPanel = {
/**
* Initialize
*/
init: function() {
this.toggleButton = $('#wp-debug-toggle');
this.panel = $('#wp-debug-panel');
this.closeButton = $('.wp-debug-panel-close');
this.tabs = $('.wp-debug-tab');
// Restore panel state from localStorage
this.restoreState();
// Bind events
this.bindEvents();
// Log initialization
if (window.console && console.log) {
console.log('[WP Debug] Panel initialized');
}
},
/**
* Bind events
*/
bindEvents: function() {
const self = this;
// Toggle button click
this.toggleButton.on('click', function(e) {
e.preventDefault();
self.togglePanel();
});
// Close button click
this.closeButton.on('click', function(e) {
e.preventDefault();
self.hidePanel();
});
// Tab clicks
this.tabs.on('click', function(e) {
e.preventDefault();
const tabName = $(this).data('tab');
self.switchTab(tabName);
});
// Press Escape to close
$(document).on('keydown', function(e) {
if (e.key === 'Escape' && self.panel.is(':visible')) {
self.hidePanel();
}
});
// Click outside to close
$(document).on('click', function(e) {
if (self.panel.is(':visible') &&
!self.panel.is(e.target) &&
self.panel.has(e.target).length === 0 &&
!self.toggleButton.is(e.target) &&
self.toggleButton.has(e.target).length === 0) {
self.hidePanel();
}
});
},
/**
* Toggle panel visibility
*/
togglePanel: function() {
if (this.panel.is(':visible')) {
this.hidePanel();
} else {
this.showPanel();
}
},
/**
* Show panel
*/
showPanel: function() {
this.panel.attr('data-visible', 'true').fadeIn(300);
this.saveState('visible', true);
// Log
if (window.console && console.log) {
console.log('[WP Debug] Panel opened');
}
},
/**
* Hide panel
*/
hidePanel: function() {
this.panel.fadeOut(300, function() {
$(this).attr('data-visible', 'false');
});
this.saveState('visible', false);
// Log
if (window.console && console.log) {
console.log('[WP Debug] Panel closed');
}
},
/**
* Switch tab
*/
switchTab: function(tabName) {
// Update tab buttons
this.tabs.removeClass('active');
this.tabs.filter('[data-tab="' + tabName + '"]').addClass('active');
// Update tab content
$('.wp-debug-tab-content').removeClass('active');
$('.wp-debug-tab-content[data-tab="' + tabName + '"]').addClass('active');
// Save active tab
this.saveState('activeTab', tabName);
// Log
if (window.console && console.log) {
console.log('[WP Debug] Switched to tab: ' + tabName);
}
},
/**
* Save state to localStorage
*/
saveState: function(key, value) {
if (typeof Storage !== 'undefined') {
try {
localStorage.setItem('wpDebugPanel_' + key, JSON.stringify(value));
} catch (e) {
// Ignore storage errors
}
}
},
/**
* Get state from localStorage
*/
getState: function(key, defaultValue) {
if (typeof Storage !== 'undefined') {
try {
const value = localStorage.getItem('wpDebugPanel_' + key);
return value !== null ? JSON.parse(value) : defaultValue;
} catch (e) {
return defaultValue;
}
}
return defaultValue;
},
/**
* Restore panel state
*/
restoreState: function() {
// Restore visibility
const isVisible = this.getState('visible', false);
if (isVisible) {
this.panel.show().attr('data-visible', 'true');
}
// Restore active tab
const activeTab = this.getState('activeTab', 'overview');
this.switchTab(activeTab);
},
/**
* Refresh panel data (for future AJAX updates)
*/
refresh: function() {
if (window.console && console.log) {
console.log('[WP Debug] Refreshing panel data...');
}
// This could be extended to fetch fresh data via AJAX
// For now, it just logs
if (typeof wpDebugData !== 'undefined' && wpDebugData.ajaxUrl) {
$.ajax({
url: wpDebugData.ajaxUrl,
type: 'POST',
data: {
action: 'wp_debug_refresh',
nonce: wpDebugData.nonce
},
success: function(response) {
if (window.console && console.log) {
console.log('[WP Debug] Panel data refreshed', response);
}
},
error: function(xhr, status, error) {
if (window.console && console.error) {
console.error('[WP Debug] Refresh failed:', error);
}
}
});
}
}
};
/**
* Initialize on document ready
*/
$(document).ready(function() {
WPDebugPanel.init();
});
/**
* Expose to window for external access
*/
window.WPDebugPanel = WPDebugPanel;
})(jQuery);