| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use SyncBasalam\Config\Endpoints; |
| 6 | 6 | use SyncBasalam\Logger\Logger; |
| 7 | 7 | use SyncBasalam\Services\ApiServiceManager; |
| 8 | +use SyncBasalam\Services\ForceUpdateGate; | |
| 8 | 9 | |
| 9 | 10 | defined('ABSPATH') || exit; |
| 10 | 11 | |
| 11 | 12 | class FetchVersionDetail |
| @@ -32,8 +33,13 @@ | ||
| 32 | 33 | } |
| 33 | 34 | |
| 34 | 35 | public function checkForceUpdate() |
| 35 | 36 | { |
| 37 | + if (wp_get_environment_type() === 'local') { | |
| 38 | + delete_option('sync_basalam_force_update'); | |
| 39 | + return false; | |
| 40 | + } | |
| 41 | + | |
| 36 | 42 | try { |
| 37 | 43 | $response = $this->Fetch(); |
| 38 | 44 | |
| 39 | 45 | if (!is_array($response) || !isset($response['body'])) return false; |
| @@ -43,9 +49,13 @@ | ||
| 43 | 49 | if (json_last_error() !== JSON_ERROR_NONE || !is_array($data) || !array_key_exists('force_update', $data)) { |
| 44 | 50 | return false; |
| 45 | 51 | } |
| 46 | 52 | |
| 47 | - if (!empty($data['force_update'])) { | |
| 53 | + if (ForceUpdateGate::shouldHonorRemoteFlag( | |
| 54 | + $data['force_update'], | |
| 55 | + $this->version, | |
| 56 | + isset($data['latest_version']) ? (string) $data['latest_version'] : null | |
| 57 | + )) { | |
| 48 | 58 | update_option('sync_basalam_force_update', true); |
| 49 | 59 | return true; |
| 50 | 60 | } |
| 51 | 61 | |