get_link( true ); $types_map = $link->types_map(); $link_type = $types_map[ $link->get_type() ] ?? 'edited'; $this->request_body = array( 'site_id' => Utilities::site_id(), 'domain' => network_site_url(), 'link' => array( 'link' => $link_url, 'type' => $link_type, ), ); return $this->request(); } /** * Sends the data of link, that was processed by plugin, to HUB API. * * @return WP_HTTP_Response|null|WP_Error */ public function request() { $this->prepare_request(); /* * Request to get scan results. */ $args = array( 'method' => 'POST', 'url' => $this->get_request_url(), 'headers' => array( 'Authorization' => $this->api_key, 'Content-Type' => 'application/json; charset=utf-8', ), 'body' => $this->request_body, ); $response = $this->request_api->request( $args ); Utilities::log( " : \nResponse from Edit Link Request: " . var_export( $response, true ) ); } /** * Prepares some params. * * @return void */ private function prepare_request() { if ( is_null( $this->request_api ) ) { $this->request_api = Http_Request::instance(); } // WPMUDEV_Dashboard class has been checked already in `$this->can_do_request()`. $this->api_key = self::get_api_key(); } /** * Returns full request url. * * @return string */ public function get_request_url() { if ( is_null( $this->url ) ) { $this->url = Utilities::hub_edit_link_completed(); } return $this->url; } }