PluginProbe
Disk Usage Insights / trunk
Disk Usage Insights vtrunk
trunk 1.0 1.10 1.11 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9
← All changes | src/Plugin.php +21 -6 1.6trunk View file →
@@ -51,14 +51,29 @@
51 51 // Add JavaScript libs + CSS
52 52 add_action('admin_enqueue_scripts', [$this, 'addScripts']);
53 53
54 54 // Add AJAX
55 - add_action('wp_ajax_dui_scan', function() { (new ScanController())->scan(); });
56 - add_action('wp_ajax_dui_worker', function() { (new ScanWorkerController())->worker(); });
57 - add_action('wp_ajax_dui_status', function() { (new ScanStatusController())->status(); });
58 - add_action('wp_ajax_dui_delete_snapshot', function() { (new DeleteSnapshotController())->delete(); });
59 - add_action('wp_ajax_dui_list_snapshots', function() { (new ShowSnapshotsController())->execute(); });
60 - add_action('wp_ajax_dui_results_table', function() { (new ShowResultsTableController())->execute(); });
55 + add_action('wp_ajax_dui_scan', $this->wrapErrors(function() { (new ScanController())->scan(); }));
56 + add_action('wp_ajax_dui_worker', $this->wrapErrors(function() { (new ScanWorkerController())->worker(); }));
57 + add_action('wp_ajax_dui_status', $this->wrapErrors(function() { (new ScanStatusController())->status(); }));
58 + add_action('wp_ajax_dui_delete_snapshot', $this->wrapErrors(function() { (new DeleteSnapshotController())->delete(); }));
59 + add_action('wp_ajax_dui_list_snapshots', $this->wrapErrors(function() { (new ShowSnapshotsController())->execute(); }));
60 + add_action('wp_ajax_dui_results_table', $this->wrapErrors(function() { (new ShowResultsTableController())->execute(); }));
61 + }
62 +
63 + public function wrapErrors(callable $fn) {
64 + return function() use ($fn) {
65 + try {
66 + return $fn();
67 + } catch (\Throwable $e) {
68 + status_header(500, 'Interner Fehler');
69 + //echo 'Fehler: Interner Serverfehler.';
70 + echo "\n\n";
71 + echo esc_html($e->getMessage());
72 + echo esc_html($e->getTraceAsString());
73 + wp_die();
74 + }
75 + };
61 76 }
62 77
63 78 public function addScripts($hook_suffix) {
64 79 if ($hook_suffix != 'tools_page_disk-usage-insights') {