Viewing File: /usr/local/cpanel/3rdparty/wpinstaller/src/WpDownloader/Component/BluehostPlugin.php

<?php
namespace WpDownloader\Component;

use WpDownloader\BluehostApi;
use WpDownloader\Log;
use WpDownloader\Utility;

class BluehostPlugin extends Plugin
{
    public $slug = 'bluehost-wordpress-plugin';

    public function getLatestVersion()
    {
        $basePath = "https://hiive.cloud/workers/release-api/plugins/bluehost/".$this->slug;
        $params = [];
        $versionData = BluehostApi::getVersionData($basePath, $params);

        return $versionData['version']['latest'];
    }
    
    public function getDownloadUrl()
    {
        return $this->componentData['endpoint'];
    }

    public function getActivationFile()
    {
        return '{$slug}/{$this->componentData["file"]}';
    }

    public function downloadLatestVersion()
    {
        $downloadUrl = $this->componentData['endpoint'];
        $version = $this->getLatestVersion();

        $localFile = $this->downloadFile($downloadUrl, "{$this->temporaryDirectory}/{$this->slug}.php");

        if (!$localFile || !file_exists($localFile)) {
            Log::throwException("Downloaded failed or local file {$localFile} does not exist.");
        }

        $this->extractArchive($localFile);

        $this->commitTempToPersistent();

        $this->appendLocalData(['version' => $version]);

        return $version;
    }
}
Back to Directory File Manager