Skip to content

Commit

Permalink
fix pro updater
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbot committed Dec 20, 2023
1 parent c81d167 commit 768fb15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
16 changes: 8 additions & 8 deletions includes/Admin/Updaters/Pro_Plugin_Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ public function __construct() {
$this->active = $status['active'];
$this->current_version = $status['version'];

// Allow the update server to be overridden for development.
if ( isset( $_ENV['WCPOS_PRO_UPDATE_SERVER'] ) ) {
$this->update_server = $_ENV['WCPOS_PRO_UPDATE_SERVER'];
}

if ( $this->installed ) {
add_filter( 'update_plugins_updates.wcpos.com', array( $this, 'update_plugins' ), 10, 4 );
// add_filter( 'site_transient_update_plugins', array( $this, 'modify_plugin_update_transient' ) );
add_action( 'upgrader_process_complete', array( $this, 'after_plugin_update' ), 10, 2 );
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 4 );
add_action( 'in_plugin_update_message-' . $this->pro_plugin_path, array( $this, 'plugin_update_message' ), 10, 2 );
Expand Down Expand Up @@ -207,12 +211,10 @@ public function update_plugins( $update, $plugin_data, $plugin_file, $locales )
*/
public function check_pro_plugin_updates( $force = false ) {
$update_data = get_transient( $this->update_data_transient_key );
$is_development = isset( $_ENV['DEVELOPMENT'] ) && $_ENV['DEVELOPMENT'];

if ( empty( $update_data ) || $force ) {
$expiration = 60 * 60 * 12; // 12 hours.
$endpoint = $is_development ? 'http://localhost:8080/pro' : $this->update_server;
$url = $endpoint . '/update/' . $this->current_version;
$url = $this->update_server . '/update/' . $this->current_version;

// make the api call.
$response = wp_remote_get(
Expand Down Expand Up @@ -256,9 +258,7 @@ public function check_pro_plugin_updates( $force = false ) {
*/
private function check_license_status( $force = false ) {
$license_status = get_transient( $this->license_status_transient_key );
$is_development = isset( $_ENV['DEVELOPMENT'] ) && $_ENV['DEVELOPMENT'];
$expiration = 60 * 60 * 12; // 12 hours.
$endpoint = $is_development ? 'http://localhost:8080/pro' : $this->update_server;

/**
* TODO: How to allow for multisite?
Expand Down Expand Up @@ -287,7 +287,7 @@ private function check_license_status( $force = false ) {
'key' => $license_settings['key'],
'instance' => $license_settings['instance'],
),
$endpoint . '/license/status'
$this->update_server . '/license/status'
);

// make the api call.
Expand All @@ -305,7 +305,7 @@ private function check_license_status( $force = false ) {

if ( is_wp_error( $data ) ) {
Logger::log( $data );
$expiration = $is_development ? 1 : 60 * 60 * 1; // try again in an hour if error.
$expiration = 60 * 60 * 1; // try again in an hour if error.
}

set_transient( $this->license_status_transient_key, $data, $expiration );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wcpos/woocommerce-pos",
"version": "1.4.0-beta.3",
"version": "1.4.0-beta.4",
"description": "A simple front-end for taking WooCommerce orders at the Point of Sale.",
"main": "index.js",
"workspaces": {
Expand Down
2 changes: 1 addition & 1 deletion tests/includes/Test_Wcpos_Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @coversNothing
*/
class Test_WCPOS_Functions extends WP_UnitTestCase {
class Test_Wcpos_Functions extends WP_UnitTestCase {
public function setup(): void {
parent::setup();
}
Expand Down
5 changes: 2 additions & 3 deletions woocommerce-pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
* Plugin Name: WooCommerce POS
* Plugin URI: https://wordpress.org/plugins/woocommerce-pos/
* Description: A simple front-end for taking WooCommerce orders at the Point of Sale. Requires <a href="http://wordpress.org/plugins/woocommerce/">WooCommerce</a>.
* Version: 1.4.0-beta.3
* Version: 1.4.0-beta.4
* Author: kilbot
* Author URI: http://wcpos.com
* Update URI: https://updates.wcpos.com/pro/
* Text Domain: woocommerce-pos
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
Expand All @@ -23,7 +22,7 @@
namespace WCPOS\WooCommercePOS;

// Define plugin constants.
const VERSION = '1.4.0-beta.3';
const VERSION = '1.4.0-beta.4';
const PLUGIN_NAME = 'woocommerce-pos';
const SHORT_NAME = 'wcpos';
\define( __NAMESPACE__ . '\PLUGIN_FILE', plugin_basename( __FILE__ ) ); // 'woocommerce-pos/woocommerce-pos.php'
Expand Down

0 comments on commit 768fb15

Please sign in to comment.