poller = $poller; add_action('admin_init', array($this, 'recover_schedule')); add_action('admin_post_' . self::ACTION, array($this, 'handle')); } public function recover_schedule() { if (current_user_can('manage_woocommerce')) Akkedli_V2_Binding_Poller::schedule_current(); } public function handle() { if (!isset($_SERVER['REQUEST_METHOD']) || 'POST' !== strtoupper(sanitize_text_field(wp_unslash($_SERVER['REQUEST_METHOD'])))) { $this->redirect('error'); } if (!current_user_can('manage_woocommerce')) { wp_die(esc_html__('You are not allowed to manage this connection.', 'akkedli-connector'), esc_html__('Permission denied', 'akkedli-connector'), array('response' => 403)); } $nonce = isset($_POST['_akkedli_v2_binding_nonce']) && is_string($_POST['_akkedli_v2_binding_nonce']) ? sanitize_text_field(wp_unslash($_POST['_akkedli_v2_binding_nonce'])) : ''; if (!wp_verify_nonce($nonce, self::NONCE)) $this->redirect('error'); $result = $this->poller->check_manual(); $allowed = array('verified', 'failed', 'pending', 'paused', 'retry', 'manual', 'busy', 'stale'); $this->redirect(in_array($result, $allowed, true) ? $result : 'error'); } private function redirect($notice) { wp_safe_redirect(add_query_arg(array('page' => 'akkedli-connector', 'akkedli_v2_notice' => $notice), admin_url('admin.php'))); exit; } }