Skip to content

Commit

Permalink
Merge pull request #5 from RBAtkins0n/master
Browse files Browse the repository at this point in the history
= 2.2.10 - October 14, 2019 =
  • Loading branch information
appinlet authored Dec 2, 2019
2 parents dcfb884 + 06797e9 commit ecceb45
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 53 deletions.
4 changes: 2 additions & 2 deletions CountriesArray.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/*
* Copyright (c) 2018 PayGate (Pty) Ltd
* Copyright (c) 2019 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
*
* Released under the GNU General Public License
*/
class CountriesArray
Expand Down
Binary file added assets/images/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
= 2.2.10 - October 14, 2019 =
* Fix WP Error in updater class

= 2.2.9 - December 29, 2018 =

* Add auto-update feature
1 change: 0 additions & 1 deletion flot/jquery.flot.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion paygate-tools.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2018 PayGate (Pty) Ltd
* Copyright (c) 2019 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
11 changes: 6 additions & 5 deletions paygate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
* Plugin Name: Gravity Forms PayGate Add-On
* Plugin URI: https://github.com/PayGate/PayWeb_Gravity_Forms
* Description: Integrates Gravity Forms with PayGate, a South African payment gateway.
* Version: 2.2.9
* Version: 2.2.10
* Tested: 5.3.0
* Author: PayGate (Pty) Ltd
* Author URI: https://www.paygate.co.za/
* Developer: App Inlet (Pty) Ltd
* Developer URI: https://www.appinlet.com/
* Text Domain: gravityformspaygate
* Domain Path: /languages
*
* Copyright: © 2018 PayGate (Pty) Ltd.
*
* Copyright: © 2019 PayGate (Pty) Ltd.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand All @@ -27,7 +28,7 @@

function paygate_init()
{
/**
/**
* Auto updates from GIT
*
* @since 2.2.9
Expand All @@ -49,7 +50,7 @@ function paygate_init()
'homepage' => 'https://github.com/PayGate/PayWeb_Gravity_Forms',
'sslverify' => true,
'requires' => '4.0',
'tested' => '4.9.8',
'tested' => '5.3.0',
'readme' => 'README.md',
'access_token' => '',
);
Expand Down
2 changes: 1 addition & 1 deletion paygate_gf_class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (c) 2018 PayGate (Pty) Ltd
* Copyright (c) 2019 PayGate (Pty) Ltd
*
* Author: App Inlet (Pty) Ltd
*
Expand Down
162 changes: 120 additions & 42 deletions updater.class.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

// Prevent loading this file directly and/or if the class is already defined
if ( !defined( 'ABSPATH' ) || class_exists( 'WPGitHubUpdater' ) || class_exists( 'WP_GitHub_Updater' ) ) {
if ( !defined( 'ABSPATH' ) || class_exists( 'WP_GitHub_Updater_PW3' ) ) {
return;
}

/**
*
*
* @version 1.6
* @version 1.7
* @author Joachim Kudish <info@jkudish.com>
* @link http://jkudish.com
* @package WP_GitHub_Updater
* @package WP_GitHub_Updater_PW3
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @copyright Copyright (c) 2011-2013, Joachim Kudish
*
Expand All @@ -32,13 +32,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
class WP_GitHub_Updater
class WP_GitHub_Updater_PW3
{

/**
* GitHub Updater version
*/
const VERSION = 1.6;
const VERSION = 1.7;

/**
* @var $config the config for the updater
Expand Down Expand Up @@ -155,10 +155,22 @@ public function set_defaults()
$this->config['zip_url'] = $zip_url;
}

if ( !isset( $this->config['raw_response'] ) ) {
$this->config['raw_response'] = $this->get_raw_response();
}

if ( !isset( $this->config['new_version'] ) ) {
$this->config['new_version'] = $this->get_new_version();
}

if ( !isset( $this->config['new_tested'] ) ) {
$this->config['new_tested'] = $this->get_new_tested();
}

if ( !isset( $this->config['icons'] ) ) {
$this->config['icons'] = $this->get_icons();
}

if ( !isset( $this->config['last_updated'] ) ) {
$this->config['last_updated'] = $this->get_date();
}
Expand Down Expand Up @@ -222,6 +234,35 @@ public function http_request_sslverify( $args, $url )
return $args;
}

/**
* Get Icons from GitHub
*
* @since 1.7
* @return array $icons the plugin icons
*/
public function get_icons()
{
$assest_url = $this->config['raw_url'] . '/assets/images/';
$icons = array(
'default' => $assest_url . 'icon-128x128.png',
'1x' => $assest_url . 'icon-128x128.png',
'2x' => $assest_url . 'icon-256x256.png',
);
return $icons;
}

/**
* Get Raw Response from GitHub
*
* @since 1.7
* @return int $raw_response the raw response
*/
public function get_raw_response()
{
$raw_response = $this->remote_get( trailingslashit( $this->config['raw_url'] ) . basename( $this->config['slug'] ) );
return $raw_response;
}

/**
* Get New Version from GitHub
*
Expand All @@ -234,7 +275,7 @@ public function get_new_version()

if ( $this->overrule_transients() || ( !isset( $version ) || !$version || '' == $version ) ) {

$raw_response = $this->remote_get( trailingslashit( $this->config['raw_url'] ) . basename( $this->config['slug'] ) );
$raw_response = $this->config['raw_response'];

if ( is_wp_error( $raw_response ) ) {
$version = false;
Expand All @@ -253,34 +294,55 @@ public function get_new_version()
$version = $matches[1];
}

// back compat for older readme version handling
// only done when there is no version found in file name
if ( false === $version ) {
$raw_response = $this->remote_get( trailingslashit( $this->config['raw_url'] ) . $this->config['readme'] );
// refresh every 6 hours
if ( false !== $version ) {
set_site_transient( md5( $this->config['slug'] ) . '_new_version', $version, 60 * 60 * 6 );
}

if ( is_wp_error( $raw_response ) ) {
return $version;
}
}

preg_match( '#^\s*`*~Current Version\:\s*([^~]*)~#im', $raw_response['body'], $__version );
return $version;
}

if ( isset( $__version[1] ) ) {
$version_readme = $__version[1];
if ( -1 == version_compare( $version, $version_readme ) ) {
$version = $version_readme;
}
/**
* Get New Tested from GitHub
*
* @since 1.7
* @return int $tested the tested number
*/
public function get_new_tested()
{
$tested = get_site_transient( md5( $this->config['slug'] ) . '_new_tested' );

if ( $this->overrule_transients() || ( !isset( $tested ) || !$tested || '' == $tested ) ) {

$raw_response = $this->config['raw_response'];

if ( is_wp_error( $raw_response ) ) {
$tested = false;
}

if ( is_array( $raw_response ) ) {
if ( !empty( $raw_response['body'] ) ) {
preg_match( '/.*Tested\:\s*(.*)$/mi', $raw_response['body'], $matches );
}

}

if ( empty( $matches[1] ) ) {
$tested = $this->config['tested'];
} else {
$tested = $matches[1];
}

// refresh every 6 hours
if ( false !== $version ) {
set_site_transient( md5( $this->config['slug'] ) . '_new_version', $version, 60 * 60 * 6 );
if ( false !== $tested ) {
set_site_transient( md5( $this->config['slug'] ) . '_new_tested', $tested, 60 * 60 * 6 );
}

}

return $version;
return $tested;
}

/**
Expand Down Expand Up @@ -369,10 +431,18 @@ public function get_description()
*/
public function get_changelog()
{
$_changelog = $this->remote_get( $this->config['raw_url'] . '/changelog.txt' );
$_changelog = nl2br( $_changelog['body'] );
$_changelog = '';
if ( !is_wp_error( $this->config ) ) {
$_changelog = $this->remote_get( $this->config['raw_url'] . '/changelog.txt' );
}
if ( !is_wp_error( $_changelog ) ) {
$_changelog = nl2br( $_changelog['body'] );
} else {
$_changelog = '';
}
// return
return ( !empty( $_changelog ) ? $_changelog : 'Could not get changelog from server.' );

}

/**
Expand Down Expand Up @@ -413,6 +483,8 @@ public function api_check( $transient )
$response->slug = $this->config['proper_folder_name'];
$response->url = add_query_arg( array( 'access_token' => $this->config['access_token'] ), $this->config['github_url'] );
$response->package = $this->config['zip_url'];
$response->icons = $this->config['icons'];
$response->tested = $this->config['new_tested'];

// If response is false, don't alter the transient
if ( false !== $response ) {
Expand All @@ -439,25 +511,31 @@ public function get_plugin_info( $false, $action, $response )
// Check if this call API is for the right plugin
if ( !isset( $response->slug ) || $response->slug != $this->config['proper_folder_name'] ) {
return false;
} else {
$res = new stdClass();
$res->name = $this->config['plugin_name'];
$res->slug = $this->config['slug'];
$res->version = $this->config['new_version'];
$res->author = $this->config['author'];
$res->homepage = $this->config['homepage'];
$res->requires = $this->config['requires'];
$res->tested = $this->config['new_tested'];
$res->downloaded = 0;
$res->last_updated = $this->config['last_updated'];
$res->sections = array(
'description' => $this->config['description'],
'changelog' => $this->config['changelog'],
);
$res->download_link = $this->config['zip_url'];

// Useful fields for a later version
// $res->rating = '100';
// $res->num_ratings = '1124';
// $res->active_installs = '11056';
// $res->downloaded = '18056';

return $res;
}

$res = new stdClass();
$res->name = $this->config['plugin_name'];
$res->slug = $this->config['slug'];
$res->version = $this->config['new_version'];
$res->author = $this->config['author'];
$res->homepage = $this->config['homepage'];
$res->requires = $this->config['requires'];
$res->tested = $this->config['tested'];
$res->downloaded = 0;
$res->last_updated = $this->config['last_updated'];
$res->sections = array(
'description' => $this->config['description'],
'changelog' => $this->config['changelog'],
);
$res->download_link = $this->config['zip_url'];

return $res;
}

/**
Expand Down

0 comments on commit ecceb45

Please sign in to comment.