| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | $this->cronHook = $this->identifier . '_cron'; |
| 27 | 27 | |
| 28 | 28 | add_filter('cron_schedules', array($this, 'addCronInterval')); |
| 29 | 29 | |
| 30 | - add_action('wp_ajax_' . $this->identifier, array($this, 'handleAsyncRequest')); | |
| 31 | - add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'handleAsyncRequest')); | |
| 30 | + add_action('wp_ajax_' . $this->identifier, array($this, 'maybeHandleAsyncRequest')); | |
| 31 | + add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'maybeHandleAsyncRequest')); | |
| 32 | 32 | add_action($this->cronHook, array($this, 'handleCronHealthcheck')); |
| 33 | 33 | |
| 34 | 34 | $this->init(); |
| 35 | 35 | } |
| @@ -123,8 +123,15 @@ | ||
| 123 | 123 | |
| 124 | 124 | spawn_cron(); |
| 125 | 125 | |
| 126 | 126 | return true; |
| 127 | + } | |
| 128 | + | |
| 129 | + public function maybeHandleAsyncRequest() | |
| 130 | + { | |
| 131 | + check_ajax_referer($this->identifier, 'nonce'); | |
| 132 | + | |
| 133 | + $this->handleAsyncRequest(); | |
| 127 | 134 | } |
| 128 | 135 | |
| 129 | 136 | public function handleAsyncRequest() |
| 130 | 137 | { |