| @@ -5,8 +5,9 @@ | ||
| 5 | 5 | use WPIDE\App\Kernel\Request; |
| 6 | 6 | use WPIDE\App\Kernel\Response; |
| 7 | 7 | use WPIDE\App\Services\Service; |
| 8 | 8 | use WPIDE\App\Services\Logger\LoggerInterface; |
| 9 | +use const WPIDE\Constants\SLUG; | |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * @codeCoverageIgnore |
| 12 | 13 | */ |
| @@ -26,9 +27,9 @@ | ||
| 26 | 27 | } |
| 27 | 28 | |
| 28 | 29 | public function init(array $config = []) |
| 29 | 30 | { |
| 30 | - if(!wp_doing_ajax() || wp_doing_cron() || defined('WPIDE_DOING_TASK')) { | |
| 31 | + if(wp_doing_cron() || defined('WPIDE_DOING_TASK') || ! $this->isProtectedRequest()) { | |
| 31 | 32 | return; |
| 32 | 33 | } |
| 33 | 34 | |
| 34 | 35 | $nonce = wp_create_nonce(); |
| @@ -84,6 +85,16 @@ | ||
| 84 | 85 | die; |
| 85 | 86 | } |
| 86 | 87 | } |
| 87 | 88 | |
| 89 | + } | |
| 90 | + | |
| 91 | + protected function isProtectedRequest(): bool | |
| 92 | + { | |
| 93 | + if(wp_doing_ajax()) { | |
| 94 | + return true; | |
| 95 | + } | |
| 96 | + | |
| 97 | + return $this->request->query->get('page') === SLUG | |
| 98 | + && $this->request->query->has('req'); | |
| 88 | 99 | } |
| 89 | 100 | } |