# debug-log-viewer/2.2.3/admin/controllers/BaseController.php

Debug Log Viewer, version 2.2.3. 40 lines.

- Page: https://pluginprobe.com/plugins/debug-log-viewer/2.2.3/code/admin/controllers/BaseController.php
- Raw: https://pluginprobe.com/plugins/debug-log-viewer/2.2.3/raw/admin/controllers/BaseController.php
- Modified: 2026-04-30T07:44:04+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/debug-log-viewer/2.2.3/code/admin/controllers/BaseController.php#L10-L20`.

```php
<?php

namespace DebugLogViewer\Admin\Controllers;

if (! defined('ABSPATH')) {
	exit;
}

abstract class BaseController
{
	protected function verifyAjaxRequest($nonce_action = 'ajax_nonce', $capability = 'manage_options')
	{
		$nonce = isset($_POST['wp_nonce']) ? sanitize_text_field(wp_unslash($_POST['wp_nonce'])) : '';
		
		if (! wp_verify_nonce($nonce, $nonce_action)) {
			wp_send_json_error(__('Please refresh the page', 'debug-log-viewer'), 403);
		}

		if (! current_user_can($capability)) {
			wp_send_json_error(__('Insufficient permissions', 'debug-log-viewer'), 403);
		}
	}

	protected function verifyRequest($nonce_action, $capability = 'manage_options', $method = null)
	{
		$method = $method ?: $_SERVER['REQUEST_METHOD'];
		$source = ($method === 'POST') ? $_POST : $_GET;
		
		$nonce = isset($source['_wpnonce']) ? sanitize_text_field(wp_unslash($source['_wpnonce'])) : '';
		
		if (! wp_verify_nonce($nonce, $nonce_action)) {
			wp_die(esc_html__('Security check failed', 'debug-log-viewer'), 403);
		}

		if (! current_user_can($capability)) {
			wp_die(esc_html__('You do not have permission to perform this action', 'debug-log-viewer'), 403);
		}
	}
}

```
