target_page = $target_page; $this->target_action = $target_action; $this->url = $url; } public function redirect() { $url = empty( $this->url ) ? $this->generate_url() : $this->url; header( 'Location: ' . $url ); die(); } /** * @return string */ private function generate_url() { $url = get_admin_url(); $url .= 'admin.php?'; $query = array(); $query['page'] = $this->target_page; if ( ! empty( $this->target_action ) ) { $query['twofas-action'] = $this->target_action; } $url .= http_build_query( $query ); return $url; } }