PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / admin / actions / UpdateOptionsHandler.php

UpdateOptionsHandler.php in 404 Solution trunk, at includes/admin/actions/UpdateOptionsHandler.php

54 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Handles action 'updateOptions': either deletes the debug file (if
9 * deleteDebugFile flag is set) or rewrites $sub to 'abj404_options' so the
10 * settings page submission proceeds through the normal options pipeline.
11 *
12 * This is the one handler that uses wp_verify_nonce() against $_POST['nonce']
13 * (not check_admin_referer), preserving the pre-refactor behavior exactly.
14 */
15 class ABJ_404_Solution_UpdateOptionsHandler implements ABJ_404_Solution_AdminActionHandlerInterface {
16
17 /** @var ABJ_404_Solution_PluginLogicAdminActions */
18 private $parent;
19
20 public function __construct(ABJ_404_Solution_PluginLogicAdminActions $parent) {
21 $this->parent = $parent;
22 }
23
24 public function nonceAction(): string {
25 return 'abj404UpdateOptions';
26 }
27
28 public function nonceArg(): string {
29 return 'nonce';
30 }
31
32 public function useCheckAdminReferer(): bool {
33 return false;
34 }
35
36 public function handle(string $action, string &$sub): string {
37 $logger = $this->parent->getLogger();
38
39 if (array_key_exists('deleteDebugFile', $_POST) && $_POST['deleteDebugFile']) {
40 $filepath = $logger->getDebugFilePath();
41 if (!file_exists($filepath)) {
42 return sprintf(__("Debug file not found. (%s)", '404-solution'), $filepath);
43 } else if ($logger->deleteDebugFile()) {
44 return sprintf(__("Debug file(s) deleted. (%s)", '404-solution'), $filepath);
45 } else {
46 return sprintf(__("Issue deleting debug file. (%s)", '404-solution'), $filepath);
47 }
48 }
49
50 $sub = 'abj404_options';
51 return '';
52 }
53 }
54