Skip to content

Commit

Permalink
skip plugin update check if API timing out
Browse files Browse the repository at this point in the history
  • Loading branch information
octoxan committed Dec 19, 2023
1 parent 1bea8e8 commit 15f3ede
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 16 additions & 3 deletions embold-sage10-tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: emBold Sage10 Tweaks
* Plugin URI: https://embold.com
* Description: A collection of tweaks and changes to the Sage 10 framework.
* Version: 0.8.0
* Version: 0.9.0
* Author: emBold
* Author URI: https://embold.com/
* Primary Branch: master
Expand All @@ -28,9 +28,22 @@
);

$update_key_url = 'https://embold.net/api/wp-plugin-key';
$update_key = @trim(file_get_contents($update_key_url));

if ($update_key) {
// Initialize cURL session
$ch = curl_init($update_key_url);

// Set cURL options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 0.2); // Set timeout in seconds

// Execute cURL session
$update_key = @curl_exec($ch);

if ($update_key !== false && ($update_key = trim($update_key))) {
// Close cURL session
curl_close($ch);

// Set authentication and enable release assets
$embold_update_checker->setAuthentication($update_key);
$embold_update_checker->getVcsApi()->enableReleaseAssets();
}
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: itsjsutxan
Tags: sage, tweaks
Requires at least: 6.0
Tested up to: 6.2.2
Stable tag: 0.8.0
Stable tag: 0.9.0
Requires PHP: 8.0

A collection of tweaks and changes to the Sage 10 framework.
Expand All @@ -20,6 +20,9 @@ a drag and drop plugin.

== Changelog ==

= 0.9.0 =
* gracefully timeout after a fraction of a second if API call fails

= 0.8.0 =
* Add plugin update ability

Expand Down

0 comments on commit 15f3ede

Please sign in to comment.