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 / SaveGscSettingsHandler.php

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

38 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 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Handles action 'saveGscSettings': persists Google Search Console OAuth
9 * credentials submitted from the GSC settings form. Returns the validation
10 * error string from GoogleSearchConsole::saveSettings() (empty on success).
11 *
12 * Uses a custom nonce arg '_wpnonce_gsc' to scope the GSC form's nonce
13 * separately from other admin actions on the same page.
14 */
15 class ABJ_404_Solution_SaveGscSettingsHandler implements ABJ_404_Solution_AdminActionHandlerInterface {
16
17 public function nonceAction(): string {
18 return 'abj404_gsc_save';
19 }
20
21 public function nonceArg(): string {
22 return '_wpnonce_gsc';
23 }
24
25 public function useCheckAdminReferer(): bool {
26 return true;
27 }
28
29 public function handle(string $action, string &$sub): string {
30 $logger = abj_service('logging');
31 $gsc = new ABJ_404_Solution_GoogleSearchConsole($logger);
32 $error = $gsc->oauthStore()->saveSettings($_POST);
33 return ($error === '')
34 ? __('Google Search Console credentials saved.', '404-solution')
35 : $error;
36 }
37 }
38