| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Handles the legacy remove-link action for redirect rows. |
| 9 |
*/ |
| 10 |
class ABJ_404_Solution_DeleteRedirectActionHandler { |
| 11 |
|
| 12 |
/** @var ABJ_404_Solution_PluginLogicAdminActions */ |
| 13 |
private $parent; |
| 14 |
|
| 15 |
public function __construct(ABJ_404_Solution_PluginLogicAdminActions $parent) { |
| 16 |
$this->parent = $parent; |
| 17 |
} |
| 18 |
|
| 19 |
/** @return string */ |
| 20 |
public function handle(): string { |
| 21 |
if (!array_key_exists('remove', $_GET) || $_GET['remove'] != 1) { |
| 22 |
return ''; |
| 23 |
} |
| 24 |
|
| 25 |
if (!is_admin() || !$this->parent->verifyLinkNonce('abj404_removeRedirect')) { |
| 26 |
return ''; |
| 27 |
} |
| 28 |
|
| 29 |
$id = $_GET['id'] ?? ''; |
| 30 |
if ($this->parent->getFunctions()->regexMatch('[0-9]+', $id)) { |
| 31 |
$this->parent->getRedirectsRepo()->deleteRedirect(absint($id)); |
| 32 |
return __('Redirect Removed Successfully!', '404-solution'); |
| 33 |
} |
| 34 |
|
| 35 |
return ''; |
| 36 |
} |
| 37 |
} |
| 38 |
|