handle(); } /** * Handle the form post. Requires the explicit confirmation field. */ public function handle(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Sorry, you are not allowed to manage this plugin.', 'agentmysite' ), '', array( 'response' => 403 ) ); } check_admin_referer( AgentMySite_Settings_Page::ACTION_DISCONNECT ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- verified by check_admin_referer() above. $confirm = isset( $_POST['confirm'] ) && is_string( $_POST['confirm'] ) ? sanitize_key( wp_unslash( $_POST['confirm'] ) ) : ''; if ( '1' !== $confirm ) { $this->redirect( AgentMySite_Connect::settings_url() . '&ams_view=' . AgentMySite_Settings_Page::VIEW_CONFIRM_DISCONNECT ); return; } AgentMySite_Options::clear_connection(); AgentMySite_Catalog::clear_scheduled(); AgentMySite_Verifier_Store::clear(); AgentMySite_Flash::set( get_current_user_id(), array( 'kind' => 'disconnected' ) ); $this->redirect( AgentMySite_Connect::settings_url() ); } /** * Stop after redirecting. Overridden in tests. */ protected function terminate(): void { exit; } /** * Redirect and stop. * * @param string $url Destination on this site. */ private function redirect( string $url ): void { wp_safe_redirect( $url ); $this->terminate(); } }