Skip to content

Commit

Permalink
Fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoteun committed Jun 18, 2023
1 parent 9cbf33a commit 89198f0
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions updater.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php

class WP_LNC_Bitcoinlightning_Updater {

private $file;
private $plugin;
private $plugin;
private $basename;
private $active;
private $username;
Expand Down Expand Up @@ -42,7 +41,7 @@ private function get_repository_info() {
if ( is_null( $this->github_response ) ) { // Do we have a response?
$args = array();
$request_uri = sprintf( 'https://api.github.com/repos/%s/%s/releases', $this->username, $this->repository ); // Build URI

var_dump($request_uri);
$args = array();

if( $this->authorize_token ) { // Is there an access token?
Expand All @@ -63,7 +62,7 @@ public function initialize() {
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'modify_transient' ), 10, 1 );
add_filter( 'plugins_api', array( $this, 'plugin_popup' ), 10, 3);
add_filter( 'upgrader_post_install', array( $this, 'after_install' ), 10, 3 );

// Add Authorization Token to download_package
add_filter( 'upgrader_pre_download',
function() {
Expand All @@ -80,8 +79,7 @@ public function modify_transient( $transient ) {
if( $checked = $transient->checked ) { // Did Wordpress check for updates?
$this->get_repository_info(); // Get the repo info

$out_of_date = version_compare( $this->github_response['tag_name'], $checked[ $this->basename ], 'gt' ); // Check if we're out of date
$out_of_date = version_compare( $this->github_response['tag_name'], $checked[ $this->basename ] ); // Check if we're out of date

if( $out_of_date ) {

Expand All @@ -107,7 +105,7 @@ public function modify_transient( $transient ) {
public function plugin_popup( $result, $action, $args ) {

if( ! empty( $args->slug ) ) { // If there is a slug

if( $args->slug == current( explode( '/' , $this->basename ) ) ) { // And it's our slug

$this->get_repository_info(); // Get our repo info
Expand All @@ -116,12 +114,6 @@ public function plugin_popup( $result, $action, $args ) {
$plugin = array(
'name' => $this->plugin["Name"],
'slug' => $this->basename,
'requires' => '3.3',
'tested' => '4.4.1',
'rating' => '100.0',
'num_ratings' => '10823',
'downloaded' => '14249',
'added' => '2016-01-05',
'version' => $this->github_response['tag_name'],
'author' => $this->plugin["AuthorName"],
'author_profile' => $this->plugin["AuthorURI"],
Expand All @@ -141,15 +133,15 @@ public function plugin_popup( $result, $action, $args ) {
}
return $result; // Otherwise return default
}

public function download_package( $args, $url ) {

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

remove_filter( 'http_request_args', [ $this, 'download_package' ] );

return $args;
Expand Down

0 comments on commit 89198f0

Please sign in to comment.