feat: add admin-controlled authentication debug mode
This commit is contained in:
+24
-1
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('view')) {
|
||||
function view(string $view): string
|
||||
function view(string $view, array $data = []): string
|
||||
{
|
||||
$basedir = plugin_dir_path(__FILE__);
|
||||
extract($data, EXTR_SKIP);
|
||||
ob_start();
|
||||
include "{$basedir}resources/views/$view.php";
|
||||
|
||||
@@ -11,6 +12,28 @@ if (!function_exists('view')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mahak_debug_enabled')) {
|
||||
function mahak_debug_enabled(): bool
|
||||
{
|
||||
return (bool) get_configured_option('debug-mode', false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mahak_render_error')) {
|
||||
function mahak_render_error(\Throwable $exception, int $status = 500, string $fallbackView = 'server-error'): void
|
||||
{
|
||||
if (mahak_debug_enabled()) {
|
||||
wp_die(
|
||||
view('debug-error', ['exception' => $exception]),
|
||||
'Mahak Authentication Error',
|
||||
['response' => $status]
|
||||
);
|
||||
}
|
||||
|
||||
wp_die(view($fallbackView), 'Authentication Error', ['response' => $status]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dd')) {
|
||||
function dd(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user