Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluginupdater #14

Merged
merged 5 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions admin/src/PluginUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PluginUpdater

private $github_response;

public function __construct($file, $repository, $token = "")
public function __construct($file, $repository, $token = '')
{
$this->file = $file;
$this->username = 'Trizelos';
Expand Down Expand Up @@ -91,7 +91,7 @@ public function modify_transient($transient): mixed
$slug = current(explode('/', $this->basename)); // Create valid slug

$plugin = [ // setup our plugin info
'url' => $this->plugin["PluginURI"],
'url' => $this->plugin['PluginURI'],
'slug' => $slug,
'package' => $new_files,
'new_version' => $this->github_response['tag_name']
Expand Down Expand Up @@ -143,7 +143,7 @@ public function plugin_popup($result, $action, $args): mixed

// Set it to an array
$plugin = [
'name' => $this->plugin["Name"],
'name' => $this->plugin['Name'],
'slug' => $this->basename,
'requires' => '5.3',
// 'tested' => '5.*',
Expand All @@ -152,14 +152,14 @@ public function plugin_popup($result, $action, $args): mixed
// 'downloaded' => '1',
// 'added' => '2016-01-05',
'version' => $this->github_response['tag_name'],
'author' => $this->plugin["AuthorName"],
'author_profile' => $this->plugin["AuthorURI"],
'author' => $this->plugin['AuthorName'],
'author_profile' => $this->plugin['AuthorURI'],
'last_updated' => $this->github_response['published_at'],
'homepage' => $this->plugin["PluginURI"],
'short_description' => $this->plugin["Description"],
'homepage' => $this->plugin['PluginURI'],
'short_description' => $this->plugin['Description'],
'sections' => [
'Updates' => $this->github_response['body'],
'Description' => $this->plugin["Description"],
'Description' => $this->plugin['Description'],
],
'download_link' => $this->github_response['zipball_url']
];
Expand All @@ -172,7 +172,7 @@ public function download_package($args, $url): mixed

if (null !== $args['filename']) {
if ($this->authorize_token) {
$args = array_merge($args, ["headers" => ["Authorization" => "token {$this->authorize_token}"]]);
$args = array_merge($args, ['headers' => ['Authorization' => "token {$this->authorize_token}"]]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions admin/src/RepoInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public function downloadExtractRepo( string $repository ): void
{
$response = $this->repoManager->getRepoInfoByRepoName( $repository );

if ( ! isset( $response["zipball_url"] ) ) {
if ( ! isset( $response['zipball_url'] ) ) {
wp_redirect( wp_get_referer() );

return;
}

$zip_url = $response["zipball_url"];
$destination_path = WP_PLUGIN_DIR . '/' . $repository . ".zip";
$zip_url = $response['zipball_url'];
$destination_path = WP_PLUGIN_DIR . '/' . $repository . '.zip';

if ( ! $this->downloadZipFile( $zip_url, $destination_path ) ) {
wp_redirect( wp_get_referer() );
Expand Down
2 changes: 1 addition & 1 deletion admin/src/RepoManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getRepoList(): array
$repoInfos = $this->getRepoInfoByRepoName($name);

if (empty($repoInfos)) {
$repoInfos = "";
$repoInfos = '';
}

$pluginFile = WP_PLUGIN_DIR . '/' . $name . '/' . $name . '.php';
Expand Down
2 changes: 1 addition & 1 deletion admin/src/SettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public final function settingsPage(): void
data-repo="<?= empty( $data['name'] ) ? '' : $data['name']; ?>"
<?= $state == 'update' ? 'disabled' : ''; ?>
onclick="document.querySelector('#repo-to-install').value =this.dataset.repo;">
<?= $state == 'install' ? "Install" : "Update" ?>
<?= $state == 'install' ? 'Install' : 'Update' ?>
</button>
</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions cerberus-plugins-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
/**
* Plugin Name: Cerberus Plugins Manager
* Description: Manages the cerberus plugins
* Version: 1.0.9
* Version: 1.1.0
* Requires at least: 5.7
* Author: Casey
*/

use Cerberus\AdminPluginsManager\PluginUpdater;
use Cerberus\AdminPluginsManager\SettingsPage;

require_once "vendor/autoload.php";
require_once 'vendor/autoload.php';

if (is_admin()) {
$settingsPage = new SettingsPage(__FILE__);
Expand Down