aiautotool_logall = get_option('aiautotool_logall', array()); } public function set_log($log_type, $data) { $time = current_time('mysql'); if (!isset($this->aiautotool_logall[$log_type])) { $this->aiautotool_logall[$log_type] = array(); } $this->aiautotool_logall[$log_type][] = array( 'time' => $time, 'data' => $data, ); update_option('aiautotool_logall', $this->aiautotool_logall); } public function get_log($log_type = '') { if (empty($log_type)) { return $this->aiautotool_logall; } if (isset($this->aiautotool_logall[$log_type])) { return $this->aiautotool_logall[$log_type]; } return array(); } private function sort_logs_by_time($logs) { // Sử dụng array_multisort để sắp xếp mảng theo thời gian giảm dần array_multisort(array_column($logs, 'time'), SORT_DESC, $logs); return $logs; } private function display_table($data) { if (!is_object($data)) { return ''; // Nếu không phải là đối tượng, trả về chuỗi trống } $table_html = '
| Time | Data |
|---|---|
| '; echo esc_html__('No logs available', 'ai-auto-tool'); echo ' | |
| ' . esc_html($log['time']) . ' | '; echo '' . $this->display_table((Object)$log['data']) . ' | '; echo '