1000ms // Frontend panel settings add_option('wp_debug_panel_enabled', true); add_option('wp_debug_panel_position', 'bottom-right'); // bottom-right, bottom-left, top-right, top-left // Query analyzer settings add_option('wp_debug_query_threshold', 100); // Log queries taking >100ms add_option('wp_debug_detect_n_plus_one', true); } /** * Create logs directory */ private static function create_logs_directory() { $logs_dir = WP_CONTENT_DIR . '/logs/wp-debug'; if (!file_exists($logs_dir)) { wp_mkdir_p($logs_dir); // Create .htaccess to protect logs $htaccess_file = $logs_dir . '/.htaccess'; $htaccess_content = "Order deny,allow\nDeny from all"; file_put_contents($htaccess_file, $htaccess_content); // Create index.php to prevent directory listing $index_file = $logs_dir . '/index.php'; $index_content = "get_charset_collate(); // Logs table $table_logs = $wpdb->prefix . 'wp_debug_logs'; $sql_logs = "CREATE TABLE IF NOT EXISTS $table_logs ( id bigint(20) NOT NULL AUTO_INCREMENT, timestamp datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, level varchar(20) DEFAULT 'INFO' NOT NULL, message text NOT NULL, context text, user_id bigint(20), url varchar(255), ip_address varchar(45), PRIMARY KEY (id), KEY level (level), KEY timestamp (timestamp), KEY user_id (user_id) ) $charset_collate;"; // Hooks table $table_hooks = $wpdb->prefix . 'wp_debug_hooks'; $sql_hooks = "CREATE TABLE IF NOT EXISTS $table_hooks ( id bigint(20) NOT NULL AUTO_INCREMENT, timestamp datetime DEFAULT CURRENT_TIMESTAMP NOT NULL, hook_name varchar(255) NOT NULL, hook_type varchar(20) NOT NULL, execution_time float, args_count int, PRIMARY KEY (id), KEY hook_name (hook_name), KEY timestamp (timestamp), KEY hook_type (hook_type) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql_logs); dbDelta($sql_hooks); } }