downloader = $downloader; $this->nonce_action = $nonce_action; $this->capability = $capability; $this->action = $action; } /** * Handle the Request * * @return void */ public function handle() { if ( ! $this->verify_request() ) { return; } $this->downloader->download(); } /** * Verify Request * * @return bool True if verified, false otherwise. Die if nonce is not valid */ private function verify_request() { // phpcs:ignore if ( ! isset( $_GET['action'] ) || $this->action !== filter_var( $_GET['action'], FILTER_SANITIZE_STRING ) ) { return false; } check_admin_referer( $this->nonce_action, $this->nonce_action ); if ( ! current_user_can( $this->capability ) ) { wp_die( 'Cheating Uh?' ); } return true; } }