Skip to content

Commit

Permalink
Add Tested up to header to replace setTestedWpVersion()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansechrest authored Jul 16, 2024
1 parent db390da commit 41dcba4
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions plugin/GitHubUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @author Ryan Sechrest
* @package RYSE\GitHubUpdaterDemo
* @version 1.0.5
* @version 1.0.6
*/
class GitHubUpdater
{
Expand Down Expand Up @@ -110,11 +110,11 @@ class GitHubUpdater
/*------------------------------------------------------------------------*/

/**
* Tested WordPress version.
* Tested up to specified WordPress version.
*
* @var string 6.5.2
* @var string 6.6
*/
private string $testedWpVersion = '';
private string $testedUpTo = '';

/**************************************************************************/

Expand Down Expand Up @@ -158,6 +158,7 @@ public function add(): void
* $pluginSlug Plugin slug ryansechrest-github-updater-demo
* $pluginUrl Plugin URL https://ryansechrest.github.io/github-updater-demo
* $pluginVersion Plugin version 1.0.0
* $testedUpTo Tested up to 6.6
*/
private function load(): void
{
Expand All @@ -167,6 +168,7 @@ private function load(): void
[
'PluginURI' => 'Plugin URI',
'Version' => 'Version',
'TestedUpTo' => 'Tested up to',
'UpdateURI' => 'Update URI',
]
);
Expand All @@ -175,12 +177,13 @@ private function load(): void
$pluginUri = $pluginData['PluginURI'] ?? '';
$updateUri = $pluginData['UpdateURI'] ?? '';
$version = $pluginData['Version'] ?? '';
$testedUpTo = $pluginData['TestedUpTo'] ?? '';

// If required fields were not set, exit
if (!$pluginUri || !$updateUri || !$version) {
$this->addAdminNotice('Plugin <b>%s</b> is missing one or more required header fields: <b>Plugin URI</b>, <b>Version</b>, and/or <b>Update URI</b>.');
return;
};
}

// e.g. `https://github.com/ryansechrest/github-updater-demo`
$this->gitHubUrl = $updateUri;
Expand Down Expand Up @@ -216,6 +219,9 @@ private function load(): void

// e.g. `1.0.0`
$this->pluginVersion = $version;

// e.g. `6.6`
$this->testedUpTo = $testedUpTo;
}

/**
Expand Down Expand Up @@ -375,7 +381,7 @@ public function _checkPluginUpdates(
'2x' => $this->pluginUrl . '/icon-256x256.png',
'1x' => $this->pluginUrl . '/icon-128x128.png',
],
'tested' => $this->testedWpVersion,
'tested' => $this->testedUpTo,
];
}

Expand Down Expand Up @@ -641,17 +647,4 @@ public function setAccessToken(string $accessToken): self

return $this;
}

/**
* Set tested WordPress version.
*
* @param string $version 6.5.2
* @return $this
*/
public function setTestedWpVersion(string $version): self
{
$this->testedWpVersion = $version;

return $this;
}
}
}

0 comments on commit 41dcba4

Please sign in to comment.