JPKComGitPluginUpdater
in package
Class JPKComGitPluginUpdater
Handles plugin updates from a GitHub-hosted JSON manifest.
Table of Contents
Properties
- $cache_enabled : bool
- $cache_key : string
- $current_version : string
- $manifest_url : string
- $plugin_file : string
- $plugin_slug : string
Methods
- __construct() : mixed
- Constructor
- check_update() : object
- Check for available plugin updates.
- clear_cache() : void
- Clear cached manifest after a successful update.
- plugin_info() : mixed
- Provide detailed plugin info in the “View Details” modal.
- verify_download_checksum() : bool|WP_Error
- Verify download checksum before installation.
- get_remote_manifest() : object|null
- Fetch and decode the remote manifest file.
Properties
$cache_enabled
private
bool
$cache_enabled
= true
Whether caching is enabled
$cache_key
private
string
$cache_key
Cache key for transient
$current_version
private
string
$current_version
Current plugin version
$manifest_url
private
string
$manifest_url
Remote manifest URL
$plugin_file
private
string
$plugin_file
Path to main plugin file
$plugin_slug
private
string
$plugin_slug
Plugin slug (directory name)
Methods
__construct()
Constructor
public
__construct(string $plugin_file, string $current_version, string $manifest_url) : mixed
Parameters
- $plugin_file : string
-
Absolute path to the main plugin file (FILE).
- $current_version : string
-
Current plugin version.
- $manifest_url : string
-
Full URL to the remote JSON manifest.
check_update()
Check for available plugin updates.
public
check_update(object $transient) : object
Parameters
- $transient : object
-
WordPress transient data.
Return values
objectclear_cache()
Clear cached manifest after a successful update.
public
clear_cache(WP_Upgrader $upgrader, array<string|int, mixed> $options) : void
Parameters
- $upgrader : WP_Upgrader
-
WordPress upgrader instance.
- $options : array<string|int, mixed>
-
Upgrade options.
plugin_info()
Provide detailed plugin info in the “View Details” modal.
public
plugin_info(mixed $result, string $action, object $args) : mixed
Parameters
- $result : mixed
-
Default response.
- $action : string
-
Current action.
- $args : object
-
API request arguments.
verify_download_checksum()
Verify download checksum before installation.
public
verify_download_checksum(bool $reply, string $package, WP_Upgrader $upgrader) : bool|WP_Error
This hook fires before WordPress downloads the plugin package, allowing us to verify the SHA256 checksum from the manifest matches the actual download.
Parameters
- $reply : bool
-
Whether to bail without returning the package (default false).
- $package : string
-
The package file name or URL.
- $upgrader : WP_Upgrader
-
The WP_Upgrader instance.
Return values
bool|WP_Error —True to proceed, WP_Error if verification fails.
get_remote_manifest()
Fetch and decode the remote manifest file.
private
get_remote_manifest() : object|null
Uses a locking mechanism to prevent race conditions when multiple requests try to fetch the manifest simultaneously.
Return values
object|null —Decoded manifest or null on failure.