message; }
}
class HarnessWpDie extends \RuntimeException {}
class HarnessRedirect extends \RuntimeException {}
class WP_User {
public function __construct(public $ID, public $display_name) {}
}
function __($text, $domain = '') { return (string) $text; }
function esc_html($text) { return htmlspecialchars((string) $text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }
function esc_attr($text) { return esc_html($text); }
function esc_textarea($text) { return esc_html($text); }
function esc_html__($text, $domain = '') { return esc_html($text); }
function esc_attr__($text, $domain = '') { return esc_attr($text); }
function esc_url($url) {
$url = (string) $url;
return preg_match('/^\s*javascript:/i', $url) ? '' : esc_attr($url);
}
function admin_url($path = '') { return 'https://example.test/wp-admin/' . ltrim((string) $path, '/'); }
function get_edit_user_link($id) { return admin_url('user-edit.php?user_id=' . abs((int) $id)); }
function get_avatar_url($id, $args = []) { return 'https://example.test/avatar.png?user=' . abs((int) $id); }
function get_userdata($id) {
$id = (int) $id;
return isset($GLOBALS['users'][$id]) ? new WP_User($id, $GLOBALS['users'][$id]) : false;
}
function current_user_can($capability, ...$args) { return !empty($GLOBALS['caps'][$capability]); }
function get_current_user_id() { return $GLOBALS['current_user_id'] ?? 7; }
function is_user_logged_in() { return get_current_user_id() > 0; }
function get_attached_file($id) { return false; }
function get_post_mime_type($id) { return 'image/png'; }
function delete_user_meta($user_id, $key) {
$GLOBALS['delete_user_meta_calls'][] = [(int) $user_id, (string) $key];
unset($GLOBALS['user_meta'][(int) $user_id][(string) $key]);
return true;
}
function update_user_meta($user_id, $key, $value) {
$GLOBALS['user_meta'][(int) $user_id][(string) $key] = $value;
return true;
}
function wp_die($message = '') { throw new HarnessWpDie((string) $message); }
function wp_unslash($value) { return $value; }
function absint($value) { return abs((int) $value); }
function sanitize_key($text) { return preg_replace('/[^a-z0-9_\-]/', '', strtolower((string) $text)) ?? ''; }
function sanitize_text_field($text) {
$text = strip_tags((string) $text);
$text = preg_replace('/[\r\n\t ]+/', ' ', $text) ?? '';
return trim($text);
}
function sanitize_textarea_field($text) {
$text = strip_tags((string) $text);
$text = preg_replace('/[\r\t ]+/', ' ', $text) ?? '';
$text = preg_replace('/\n{3,}/', "\n\n", $text) ?? '';
return trim($text);
}
function is_wp_error($value) { return $value instanceof WP_Error; }
function number_format_i18n($number) { return number_format((float) $number); }
function get_date_from_gmt($date, $format = 'Y-m-d H:i:s') {
if ((string) $date === '') return '';
$utc = new DateTimeImmutable((string) $date, new DateTimeZone('UTC'));
return $utc->setTimezone(new DateTimeZone('Asia/Shanghai'))->format($format);
}
function wp_create_nonce($action) { return 'nonce:' . (string) $action; }
function wp_nonce_field($action, $name = '_wpnonce', $referer = true, $display = true) {
$html = '';
if ($display) echo $html;
return $html;
}
function check_admin_referer($action, $query_arg = '_wpnonce') {
$GLOBALS['checked_nonces'][] = [$action, $query_arg];
$provided = (string) ($_POST[$query_arg] ?? '');
if (!hash_equals(wp_create_nonce($action), $provided)) {
throw new HarnessWpDie('nonce verification failed');
}
return 1;
}
function add_query_arg($key, $value = '', $url = '') {
if (is_array($key)) {
$args = $key;
$url = (string) $value;
} else {
$args = [$key => $value];
if ($url === '') $url = (string) ($_SERVER['REQUEST_URI'] ?? '');
}
$parts = parse_url((string) $url) ?: [];
parse_str($parts['query'] ?? '', $query);
foreach ($args as $name => $item) $query[$name] = $item;
$base = '';
if (isset($parts['scheme'])) $base .= $parts['scheme'] . '://';
if (isset($parts['host'])) $base .= $parts['host'];
if (isset($parts['port'])) $base .= ':' . $parts['port'];
$base .= $parts['path'] ?? '';
return $base . ($query !== [] ? '?' . http_build_query($query) : '') . (isset($parts['fragment']) ? '#' . $parts['fragment'] : '');
}
function cache_users($ids) { $GLOBALS['cache_calls'][] = array_values($ids); }
function update_meta_cache($type, $ids) { $GLOBALS['meta_cache_calls'][] = [$type, array_values($ids)]; }
function get_post_meta($id, $key, $single = false) { return $GLOBALS['post_meta'][(int) $id][$key] ?? ''; }
function get_post_type($id) { return in_array((int) $id, $GLOBALS['attachment_ids'], true) ? 'attachment' : false; }
function wp_delete_attachment($id, $force = false) {
$GLOBALS['deleted_attachments'][] = [(int) $id, (bool) $force];
return true;
}
function wp_enqueue_style(...$args) { $GLOBALS['assets'][] = ['style', ...$args]; }
function wp_enqueue_script(...$args) { $GLOBALS['assets'][] = ['script', ...$args]; }
function esc_html_e($text, $domain = '') { echo esc_html($text); }
final class FakeWpdb {
public $users = 'wp_users';
public $prepared = [];
public $executed = [];
public $delete_calls = [];
public $total = 45;
public $application_delete_result = 1;
public $event_delete_result = 1;
public $applications = [];
public function prepare($sql, ...$params) {
$params = count($params) === 1 && is_array($params[0]) ? $params[0] : $params;
$this->prepared[] = ['sql' => (string) $sql, 'params' => $params];
return (string) $sql;
}
public function esc_like($text) { return addcslashes((string) $text, '_%\\'); }
public function get_var($sql) {
$this->executed[] = (string) $sql;
return str_contains((string) $sql, 'SELECT COUNT(*)') ? $this->total : null;
}
public function get_results($sql, $format = null) {
$this->executed[] = (string) $sql;
if (str_contains((string) $sql, 'GROUP BY a.status')) {
return [
['status' => 'manual_pending', 'total' => 2],
['status' => 'verified', 'total' => 1],
['status' => 'rejected', 'total' => 1],
];
}
if (str_contains((string) $sql, 'LIMIT %d OFFSET %d')) return $GLOBALS['render_rows'];
return [];
}
public function get_row($sql, $format = null) {
$this->executed[] = (string) $sql;
$query = $this->prepared[count($this->prepared) - 1] ?? ['params' => []];
$requested_uuid = (string) ($query['params'][0] ?? '');
foreach ($this->applications as $application) {
if (
str_contains((string) $sql, 'application_uuid = %s')
&& str_contains((string) $sql, 'identity_application')
&& (string) ($application['application_uuid'] ?? '') === $requested_uuid
) {
return $application;
}
}
return null;
}
public function delete($table, $data, $format = null) {
$this->delete_calls[] = ['table' => $table, 'data' => $data, 'format' => $format];
if (str_contains((string) $table, 'identity_application')) return $this->application_delete_result;
if (str_contains((string) $table, 'identity_event')) return $this->event_delete_result;
return 1;
}
}
require $root . '/src/Admin/Native/NativeUi.php';
require $root . '/src/Admin/Native/AdminListPagination.php';
require $root . '/src/Identity/ApplicationRepository.php';
require $root . '/src/Identity/EvidenceService.php';
require $root . '/src/Identity/EventRepository.php';
require $root . '/src/Admin/Native/UsersMenusVerifyDialogs.php';
require $root . '/src/Admin/Native/UsersMenusVerify.php';
final class VerifyAdminProbe {
use \Jio\Admin\Native\UsersMenusVerify;
public const CAPABILITY = 'manage_options';
public $cap_checks = 0;
private function ensure_cap(): void {
$this->cap_checks++;
if (!current_user_can('manage_options')) wp_die('capability denied');
}
private function flash(): void {}
private function redirect(string $page, string $message, array $extra = []): void {
$url = add_query_arg(array_merge(['page' => $page, 'jio_users_msg' => $message], $extra), admin_url('users.php'));
throw new HarnessRedirect($url);
}
public function invoke(string $method, ...$args) { return $this->$method(...$args); }
public function page(): string {
ob_start();
$this->render_verify_page();
return (string) ob_get_clean();
}
public function html(string $method, ...$args): string {
ob_start();
$this->$method(...$args);
return (string) ob_get_clean();
}
}
$GLOBALS['users'] = [
41 => 'Applicant ',
42 => 'Approved User',
9 => 'Reviewer
',
];
$GLOBALS['caps'] = ['manage_options' => true, 'jio_review_identity' => true];
$GLOBALS['post_meta'] = [
1001 => [
'_jio_verify_evidence_owner' => 41,
'_jio_identity_application_uuid' => 'uuid-pending-301',
],
1002 => [
'_jio_verify_evidence_owner' => 42,
'_jio_identity_application_uuid' => 'uuid-approved-302',
],
];
$GLOBALS['attachment_ids'] = [1001, 1002];
$GLOBALS['deleted_attachments'] = [];
$GLOBALS['cache_calls'] = [];
$GLOBALS['meta_cache_calls'] = [];
$GLOBALS['checked_nonces'] = [];
$GLOBALS['review_calls'] = [];
$GLOBALS['assets'] = [];
$GLOBALS['delete_user_meta_calls'] = [];
$GLOBALS['user_meta'] = [41 => ['auth' => 1, 'auth_info' => ['name' => 'Already verified', 'desc' => 'kept']]];
$GLOBALS['render_rows'] = [
[
'id' => 301,
'application_uuid' => 'uuid-pending-301',
'user_id' => 41,
'status' => 'manual_pending',
'public_name' => 'Applicant name ',
'description' => 'Bio
& text',
'manual_reason' => 'Reason