Plugin_Updater implements Registerable
Handles plugin update checks for our EDD plugins.
Tags
Interfaces, Classes and Traits
- Registerable
- An object that can be registered with WordPress via the Plugin API, i.e. add_action() and add_filter().
Table of Contents
- $cache_key : string
- $license_api : License_API
- $plugin : Licensed_Plugin
- __construct() : mixed
- auto_update_setting_html() : string
- Callback that filters the HTML markup of the auto-updates link.
- check_update() : object
- Check for Updates at the defined API endpoint and modify the update array.
- get_plugin_details() : object
- Updates information on the "View version x.x details" page with custom data.
- register() : void
- Register this object with WordPress.
- update_available_notice() : mixed
- update_plugins_barn2_com() : object
- A callback function to the `update_plugins_barn2.com` filter.
- use_barn2_update_uri() : bool
- Determine whether the Update URI property in the plugin header can be used
- format_version_info_for_plugin_details_modal() : mixed
- format_version_info_for_plugin_update() : object
- Remove unrequired properties from EDD version info when storing in the 'update_plugins' transient.
- get_cache_key() : mixed
- get_cached_version_info() : mixed
- get_latest_version() : false|object
- Get the latest version data for this plugin.
- is_beta_testing() : mixed
- maybe_disable_automatic_update() : mixed
- set_cached_version_info() : mixed
Properties
$cache_key
private
string
$cache_key
= null
Internal key used for caching
$license_api
private
License_API
$license_api
The licensing API to fetch plugin updates from.
$plugin
private
Licensed_Plugin
$plugin
The plugin we're managing updates for.
Methods
__construct()
public
__construct(Licensed_Plugin $plugin, License_API $license_api) : mixed
Parameters
- $plugin : Licensed_Plugin
- $license_api : License_API
Return values
mixed —auto_update_setting_html()
Callback that filters the HTML markup of the auto-updates link.
public
auto_update_setting_html(string $html, string $plugin_file) : string
Parameters
- $html : string
-
The original HTML markup
- $plugin_file : string
-
The basename of the current plugin
Return values
string —check_update()
Check for Updates at the defined API endpoint and modify the update array.
public
check_update(object $transient_data) : object
This function dives into the update API just when WordPress creates its update array, then adds a custom API call and injects the custom plugin data retrieved from the API. It is reassembled from parts of the native WordPress plugin update code. See wp-includes/update.php line 121 for the original wp_update_plugins() function.
Parameters
- $transient_data : object
-
Plugin update object built by WordPress.
Return values
object —Modified transient data.
get_plugin_details()
Updates information on the "View version x.x details" page with custom data.
public
get_plugin_details(mixed $data[, string $action = '' ][, object $args = null ]) : object
Parameters
- $data : mixed
- $action : string = ''
- $args : object = null
Return values
object —$data
register()
Register this object with WordPress.
public
register() : void
Return values
void —update_available_notice()
public
update_available_notice(mixed $plugin_data, mixed $response) : mixed
Parameters
- $plugin_data : mixed
- $response : mixed
Return values
mixed —update_plugins_barn2_com()
A callback function to the `update_plugins_barn2.com` filter.
public
update_plugins_barn2_com(object|bool $update_plugin, array<string|int, mixed> $plugin_data, string $plugin_file) : object
Starting from version 5.8, WordPress allows handling plugins external to the SVN repository the same way it handles those in the SVN repository. Thanks to this new method it is not necessary anymore to filter the update_plugins transient.
Parameters
- $update_plugin : object|bool
-
Plugin update object for the current plugin.
- $plugin_data : array<string|int, mixed>
-
The associative array with the plugin properties
- $plugin_file : string
-
The basename of the current plugin
Return values
object —The modified update object with custom plugin data.
use_barn2_update_uri()
Determine whether the Update URI property in the plugin header can be used
public
use_barn2_update_uri() : bool
This check also verifies whether the WP version is 5.8 or later,
returning false
otherwise.
Return values
bool —Whether WP is 5.8 or later and the Update URI is defined and contains 'barn2.com'
format_version_info_for_plugin_details_modal()
private
format_version_info_for_plugin_details_modal(mixed $version_info) : mixed
Parameters
- $version_info : mixed
Return values
mixed —format_version_info_for_plugin_update()
Remove unrequired properties from EDD version info when storing in the 'update_plugins' transient.
private
format_version_info_for_plugin_update(object $version_info) : object
Parameters
- $version_info : object
-
The version info from EDD
Return values
object —The updated version info
get_cache_key()
private
get_cache_key() : mixed
Return values
mixed —get_cached_version_info()
private
get_cached_version_info() : mixed
Return values
mixed —get_latest_version()
Get the latest version data for this plugin.
private
get_latest_version() : false|object
If successful, the returned object will contain a number of properties, including: 'new_version', 'stable_version', 'name', 'slug', 'url', 'last_updated', 'homepage', 'package', 'download_link', 'sections', 'banners', and 'icons'.
Return values
false|object —The latest version, or false on failure.
is_beta_testing()
private
is_beta_testing() : mixed
Return values
mixed —maybe_disable_automatic_update()
private
maybe_disable_automatic_update(mixed $version_info) : mixed
Parameters
- $version_info : mixed
Return values
mixed —set_cached_version_info()
private
set_cached_version_info(mixed $version_info) : mixed
Parameters
- $version_info : mixed