Skip to content

Commit

Permalink
v3.7.7 released
Browse files Browse the repository at this point in the history
  • Loading branch information
trgino committed Sep 10, 2023
1 parent 7acca17 commit 3e7aa40
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions core/library/Optimisthub_Update_Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Optimisthub_Update_Checker

public function __construct()
{
$this->plugin_slug = 'moka-woocommerce-master';
$this->plugin_slug = OPTIMISTHUB_MOKA_BASENAME;
$this->version = OPTIMISTHUB_MOKA_PAY_VERSION;
$this->cache_key = 'moka_woocommerce_update_check';
$this->cache_allowed = true;
Expand All @@ -37,13 +37,13 @@ public function __construct()
public function request()
{
$remote = get_transient( $this->cache_key );
if( false === $remote || ! $this->cache_allowed )
{
if( $remote && $this->cache_allowed ) {
return $remote;
}else{
$remote = wp_remote_post( $this->endpoint,
[
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'timeout' => 30,
'httpversion' => '1.0',
'blocking' => true,
'headers' => [],
Expand All @@ -58,26 +58,27 @@ public function request()
);

if(
is_wp_error( $remote )
|| 200 !== wp_remote_retrieve_response_code( $remote )
is_wp_error( $remote )
|| 200 != wp_remote_retrieve_response_code( $remote )
|| empty( wp_remote_retrieve_body( $remote ) )
) {
return false;
}

$remote = json_decode( wp_remote_retrieve_body( $remote ) );

if( !$remote || !isset($remote->data) )
{
return false;
}

$remote = data_get($remote,'data');

set_transient( $this->cache_key, $remote, DAY_IN_SECONDS );

}

$remote = json_decode( wp_remote_retrieve_body( $remote ) );
$remote = data_get($remote, 'data');
return $remote;

if( ! $remote )
{
return false;
}

return $remote;
}

/**
Expand Down Expand Up @@ -145,7 +146,7 @@ public function info( $response, $action, $args )
*/
public function update( $transient ) {

if ( empty($transient->checked ) ) {
if ( isset($transient->checked ) && empty($transient->checked ) ) {
return $transient;
}

Expand All @@ -157,7 +158,7 @@ public function update( $transient ) {
) {
$_response = new stdClass();
$_response->slug = $this->plugin_slug;
$_response->plugin = 'moka-woocommerce-master/index.php';
$_response->plugin = OPTIMISTHUB_MOKA_BASENAME;
$_response->new_version = data_get($remote, 'version');
$_response->tested = data_get($remote, 'tested');
$_response->package = data_get($remote, 'download_url');
Expand All @@ -182,8 +183,8 @@ public function purge()
global $options;
if (
$this->cache_allowed
&& 'update' === data_get($options, 'action') && $options['action']
&& 'plugin' === data_get($options, 'type') && $options[ 'type' ]
&& isset($options['action']) && $options['action'] && 'update' === data_get($options, 'action')
&& isset($options['type']) && $options['type'] && 'plugin' === data_get($options, 'type')
) {
delete_transient( $this->cache_key );
}
Expand Down

0 comments on commit 3e7aa40

Please sign in to comment.