PluginProbe
Debug Log Viewer / 2.4
Debug Log Viewer v2.4
2.5 2.5.1 2.5.2 2.4 trunk 1.0.2 1.0.3 1.1 1.1.1 1.2 1.2.1 1.3 1.4 1.4.1 1.4.2 1.4.3 2.0.1 2.0.3 2.0.4 2.0.5 2.1 2.2.3
debug-log-viewer / admin / controllers / BaseController.php

BaseController.php in Debug Log Viewer 2.4, at admin/controllers/BaseController.php

40 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace DebugLogViewer\Admin\Controllers;
4
5 if (! defined('ABSPATH')) {
6 exit;
7 }
8
9 abstract class BaseController
10 {
11 protected function verifyAjaxRequest($nonce_action = 'ajax_nonce', $capability = 'manage_options')
12 {
13 $nonce = isset($_POST['wp_nonce']) ? sanitize_text_field(wp_unslash($_POST['wp_nonce'])) : '';
14
15 if (! wp_verify_nonce($nonce, $nonce_action)) {
16 wp_send_json_error(__('Please refresh the page', 'debug-log-viewer'), 403);
17 }
18
19 if (! current_user_can($capability)) {
20 wp_send_json_error(__('Insufficient permissions', 'debug-log-viewer'), 403);
21 }
22 }
23
24 protected function verifyRequest($nonce_action, $capability = 'manage_options', $method = null)
25 {
26 $method = $method ?: $_SERVER['REQUEST_METHOD'];
27 $source = ($method === 'POST') ? $_POST : $_GET;
28
29 $nonce = isset($source['_wpnonce']) ? sanitize_text_field(wp_unslash($source['_wpnonce'])) : '';
30
31 if (! wp_verify_nonce($nonce, $nonce_action)) {
32 wp_die(esc_html__('Security check failed', 'debug-log-viewer'), 403);
33 }
34
35 if (! current_user_can($capability)) {
36 wp_die(esc_html__('You do not have permission to perform this action', 'debug-log-viewer'), 403);
37 }
38 }
39 }
40