Files
roi-theme/wp-content/plugins/wp-debug/wp-debug.php

146 lines
3.4 KiB
PHP

<?php
/**
* Plugin Name: WP Debug
* Plugin URI: https://github.com/prime-leads-app/wp-debug
* Description: Sistema avanzado de debug y diagnóstico para WordPress. Monitorea hooks, templates, assets, queries y performance en tiempo real.
* Version: 1.0.0
* Author: Developer Team
* Author URI: https://github.com/prime-leads-app
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-debug
* Domain Path: /languages
* Requires at least: 6.0
* Requires PHP: 7.4
*
* @package WP_Debug
* @since 1.0.0
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
/**
* Plugin Constants
*/
define('WP_DEBUG_VERSION', '1.0.0');
define('WP_DEBUG_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WP_DEBUG_PLUGIN_URL', plugin_dir_url(__FILE__));
define('WP_DEBUG_PLUGIN_BASENAME', plugin_basename(__FILE__));
/**
* Activation Hook
*/
function wp_debug_activate() {
require_once WP_DEBUG_PLUGIN_DIR . 'inc/activation.php';
WP_Debug_Activation::activate();
}
register_activation_hook(__FILE__, 'wp_debug_activate');
/**
* Deactivation Hook
*/
function wp_debug_deactivate() {
require_once WP_DEBUG_PLUGIN_DIR . 'inc/deactivation.php';
WP_Debug_Deactivation::deactivate();
}
register_deactivation_hook(__FILE__, 'wp_debug_deactivate');
/**
* Autoloader - Load all modules
*/
require_once WP_DEBUG_PLUGIN_DIR . 'inc/autoloader.php';
/**
* Initialize the plugin
*/
function wp_debug_init() {
// Load text domain for translations
load_plugin_textdomain('wp-debug', false, dirname(WP_DEBUG_PLUGIN_BASENAME) . '/languages');
// Initialize autoloader
WP_Debug_Autoloader::init();
}
add_action('plugins_loaded', 'wp_debug_init');
/**
* Admin Menu
*/
function wp_debug_admin_menu() {
require_once WP_DEBUG_PLUGIN_DIR . 'inc/admin-menu.php';
WP_Debug_Admin_Menu::init();
}
add_action('admin_menu', 'wp_debug_admin_menu');
/**
* Public API Functions
*
* These functions can be used by themes and other plugins
*/
/**
* Log a debug message
*
* @param string $message Message to log
* @param string $level Log level: INFO, WARNING, ERROR, DEBUG
* @return bool True on success, false on failure
*/
function wp_debug_log($message, $level = 'INFO') {
if (class_exists('WP_Debug_Logger')) {
return WP_Debug_Logger::log($message, $level);
}
return false;
}
/**
* Start a performance timer
*
* @param string $name Timer name
* @return bool True on success
*/
function wp_debug_start_timer($name) {
if (class_exists('WP_Debug_Profiler')) {
return WP_Debug_Profiler::start_timer($name);
}
return false;
}
/**
* End a performance timer
*
* @param string $name Timer name
* @return float|bool Elapsed time in seconds, or false on failure
*/
function wp_debug_end_timer($name) {
if (class_exists('WP_Debug_Profiler')) {
return WP_Debug_Profiler::end_timer($name);
}
return false;
}
/**
* Get list of executed hooks
*
* @return array List of hooks
*/
function wp_debug_get_hooks() {
if (class_exists('WP_Debug_Hook_Monitor')) {
return WP_Debug_Hook_Monitor::get_hooks();
}
return array();
}
/**
* Get list of loaded templates
*
* @return array List of templates
*/
function wp_debug_get_templates() {
if (class_exists('WP_Debug_Template_Tracer')) {
return WP_Debug_Template_Tracer::get_templates();
}
return array();
}