| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Starts asynchronous frontend suggestion generation when the 404 page needs it. |
| 9 |
*/ |
| 10 |
class ABJ_404_Solution_FrontendAsyncSuggestionTrigger { |
| 11 |
|
| 12 |
/** @var ABJ_404_Solution_SpellChecker */ |
| 13 |
private $spellChecker; |
| 14 |
|
| 15 |
/** |
| 16 |
* @param ABJ_404_Solution_SpellChecker $spellChecker |
| 17 |
*/ |
| 18 |
function __construct($spellChecker) { |
| 19 |
$this->spellChecker = $spellChecker; |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* @param string $requestedURL |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
function triggerIfNeeded(string $requestedURL): void { |
| 27 |
if ($this->spellChecker->does404PageHaveSuggestionsShortcode()) { |
| 28 |
$this->spellChecker->triggerAndCleanupOnFailure($requestedURL); |
| 29 |
} |
| 30 |
} |
| 31 |
} |
| 32 |
|