diff --git a/composer.lock b/composer.lock index ef8d3cf..52fb37d 100644 --- a/composer.lock +++ b/composer.lock @@ -8,25 +8,26 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v4.6", + "version": "v4.9", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "45374e3c02126fbebebf0244c5d5da4c5e0166ac" + "reference": "28f29c940cc22754aff85a99645e3c0a51c097e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/45374e3c02126fbebebf0244c5d5da4c5e0166ac", - "reference": "45374e3c02126fbebebf0244c5d5da4c5e0166ac", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/28f29c940cc22754aff85a99645e3c0a51c097e8", + "reference": "28f29c940cc22754aff85a99645e3c0a51c097e8", "shasum": "" }, "require": { + "ext-json": "*", "php": ">=5.2.0" }, "type": "library", "autoload": { "files": [ - "plugin-update-checker.php" + "load-v4p9.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -49,7 +50,7 @@ "theme updates", "wordpress" ], - "time": "2019-04-02T17:56:11+00:00" + "time": "2020-02-07T11:07:19+00:00" } ], "packages-dev": [], diff --git a/src/Api.php b/src/Api.php index 107054a..5d97b64 100644 --- a/src/Api.php +++ b/src/Api.php @@ -10,10 +10,10 @@ class Api { private $slug; private $type; - public function __construct($path, $slug) { + public function __construct($path, $slug, $type = null) { $this->path = $path; $this->slug = $slug; - $this->type = strpos($path, '/plugins/') !== false ? 'plugin' : 'theme'; + $this->type = $type ?: (strpos($path, '/themes/') !== false ? 'theme' : 'plugin'); // Auto-update $detailsUrl = add_query_arg([ @@ -51,13 +51,13 @@ public function getLicense() { if (in_array(wp_remote_retrieve_response_code($response), [200, 400])) { $licenseData = json_decode(wp_remote_retrieve_body($response), true); - set_transient($this->slug . '-license-data', $licenseData, 24 * WEEK_IN_SECONDS); + set_transient($this->slug . '-license-data', $licenseData, WEEK_IN_SECONDS); } else { $licenseData = [ 'error_code' => 'license_invalid', 'error_message' => 'Could not verify the License Key' ]; - set_transient($this->slug . '-license-data', $licenseData, DAY_IN_SECONDS); + set_transient($this->slug . '-license-data', $licenseData, 6 * HOUR_IN_SECONDS); } }