src/UpdateWatcher.php
protected function updateGithubData()
    {
        if (!empty($this->githubLatestRelease)) return false;  // this filter gets called twice, so the second time bail.

        $url = \esc_url_raw("https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases");
        $response = \wp_remote_retrieve_body(\wp_remote_get($url));
        if (is_wp_error($response)) {
            error_log($response->get_error_message());
            return false;
        }

        $jsonDecodedResponse = json_decode($response, true);
        if (is_null($jsonDecodedResponse)) {
            error_log('Unable to parse response: ' . json_last_error_msg());
            return false;
        }

        if (empty($jsonDecodedResponse[0])) {
            error_log('There is no release information gathered.');
            return false;
        }

        $this->githubLatestRelease = $jsonDecodedResponse[0];

        return true;
    }
protected function updateGithubData()
    {
        if (!empty($this->githubLatestRelease)) return false;  // this filter gets called twice, so the second time bail.

        $url = \esc_url_raw("https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases");
        $response = \wp_remote_retrieve_body(\wp_remote_get($url));
        if (is_wp_error($response)) {
            error_log($response->get_error_message());
            return false;
        }

        $jsonDecodedResponse = json_decode($response, true);
        if (is_null($jsonDecodedResponse)) {
            error_log('Unable to parse response: ' . json_last_error_msg());
            return false;
        }

        if (empty($jsonDecodedResponse[0])) {
            error_log('There is no release information gathered.');
            return false;
        }

        $this->githubLatestRelease = $jsonDecodedResponse[0];

        return true;
    }
protected function updateGithubData ( ) { if ( ! empty ( $ this -> githubLatestRelease ) ) return false ; // this filter gets called twice, so the second time bail. $ url = \ esc_url_raw ( "https://api.github.com/repos/{$this->githubNamespace}/{$this->githubProject}/releases" ) ; $ response = \ wp_remote_retrieve_body ( \ wp_remote_get ( $ url ) ) ; if ( is_wp_error ( $ response ) ) { error_log ( $ response -> get_error_message ( ) ) ; return false ; } $ jsonDecodedResponse = json_decode ( $ response , true ) ; if ( is_null ( $ jsonDecodedResponse ) ) { error_log ( 'Unable to parse response: ' . json_last_error_msg ( ) ) ; return false ; } if ( empty ( $ jsonDecodedResponse [ 0 ] ) ) { error_log ( 'There is no release information gathered.' ) ; return false ; } $ this -> githubLatestRelease = $ jsonDecodedResponse [ 0 ] ; return true ; }
Update the data from GitHub

@return bool
Update the data from GitHub