Reset_Overview.php
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\AJAX; |
| 4 | |
| 5 | use IAWP\Capability_Manager; |
| 6 | use IAWP\Overview\Modules\Module; |
| 7 | /** @internal */ |
| 8 | class Reset_Overview extends \IAWP\AJAX\AJAX |
| 9 | { |
| 10 | protected function action_name() : string |
| 11 | { |
| 12 | return 'iawp_reset_overview'; |
| 13 | } |
| 14 | protected function action_callback() : void |
| 15 | { |
| 16 | if (!Capability_Manager::can_edit()) { |
| 17 | \wp_send_json_error([], 400); |
| 18 | } |
| 19 | $confirmation = $this->get_field('confirmation'); |
| 20 | $valid = \strtolower($confirmation) == 'reset overview report'; |
| 21 | if (!$valid) { |
| 22 | \wp_send_json_error([], 400); |
| 23 | } |
| 24 | Module::reset(); |
| 25 | \wp_send_json_success([]); |
| 26 | } |
| 27 | } |
| 28 |