| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Handles action 'clearSpellingCache': truncates the spelling cache table via |
| 9 |
* the content repository so the next suggestion request rebuilds it from |
| 10 |
* scratch (used after large content changes or troubleshooting bad matches). |
| 11 |
*/ |
| 12 |
class ABJ_404_Solution_ClearSpellingCacheHandler implements ABJ_404_Solution_AdminActionHandlerInterface { |
| 13 |
|
| 14 |
/** @var ABJ_404_Solution_PluginLogicAdminActions */ |
| 15 |
private $parent; |
| 16 |
|
| 17 |
public function __construct(ABJ_404_Solution_PluginLogicAdminActions $parent) { |
| 18 |
$this->parent = $parent; |
| 19 |
} |
| 20 |
|
| 21 |
public function nonceAction(): string { |
| 22 |
return 'abj404_clearSpellingCache'; |
| 23 |
} |
| 24 |
|
| 25 |
public function nonceArg(): string { |
| 26 |
return '_wpnonce'; |
| 27 |
} |
| 28 |
|
| 29 |
public function useCheckAdminReferer(): bool { |
| 30 |
return true; |
| 31 |
} |
| 32 |
|
| 33 |
public function handle(string $action, string &$sub): string { |
| 34 |
$this->parent->getContentRepo()->deleteSpellingCache(); |
| 35 |
return __('Spelling cache cleared successfully.', '404-solution'); |
| 36 |
} |
| 37 |
} |
| 38 |
|