sanitize_file_name($file['name'] ?? ''), 'type' => sanitize_mime_type($file['type'] ?? ''), 'tmp_name' => sanitize_text_field($file['tmp_name'] ?? ''), 'error' => absint($file['error'] ?? UPLOAD_ERR_NO_FILE), 'size' => absint($file['size'] ?? 0), ]; } public static function allowed_post_status($value, $default = 'draft', $allow_publish = true) { $value = sanitize_key($value); $allowed = $allow_publish ? ['draft', 'pending', 'private', 'publish'] : ['draft', 'pending', 'private']; return in_array($value, $allowed, true) ? $value : $default; } public static function aiwest_admin_page_slug($default = 'aiwest-dashboard') { $page = self::get_key('page', $default); return strpos($page, 'aiwest-') === 0 ? $page : $default; } public static function safe_referer_or_admin_page($fallback_page = 'aiwest-dashboard') { $referer = wp_get_referer(); if ($referer && wp_validate_redirect($referer, false)) { return $referer; } return admin_url('admin.php?page=' . self::aiwest_admin_page_slug($fallback_page)); } // phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended }