PHP Class PluginUpdateChecker_1_3_1, bp-reply-by-email

Author: Janis Elsts
Afficher le fichier Open project: r-a-y/bp-reply-by-email

Méthodes publiques

Свойство Type Description
$checkPeriod Plugin slug.
$debugMode Where to store the update info.
$metadataUrl
$optionName How often to check for updates (in hours).
$pluginFile The URL of the plugin's metadata file.
$slug Plugin filename relative to the plugins directory.

Méthodes publiques

Méthode Description
__construct ( string $metadataUrl, string $pluginFile, string $slug = '', integer $checkPeriod = 12, string $optionName = '' ) Class constructor.
_addCustomSchedule ( array $schedules ) : array Add our custom schedule to the array of Cron schedules used by WP.
_removeUpdaterCron ( ) : void Remove the scheduled cron event that the library uses to check for updates.
addCheckForUpdatesLink ( array $pluginMeta, string $pluginFile, array | null $pluginData = null, string | null $status = null ) : array Add a "Check for updates" link to the plugin row in the "Plugins" page. By default, the new link will appear after the "Visit plugin site" link.
addFilter ( string $tag, callable $callback, integer $priority = 10, integer $acceptedArgs = 1 ) Register a callback for one of the update checker filters.
addHttpRequestArgFilter ( callable $callback ) : void Register a callback for filtering arguments passed to wp_remote_get().
addQueryArgFilter ( callable $callback ) : void Register a callback for filtering query arguments.
addResultFilter ( callable $callback ) : void Register a callback for filtering the plugin info retrieved from the external API.
checkForUpdates ( ) : PluginUpdate | null Check for plugin updates.
displayManualCheckResult ( ) Display the results of a manual update check.
getCronHookName ( ) : string Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
getInstalledVersion ( ) : string Get the currently installed version of the plugin.
getUpdate ( ) : PluginUpdate | null Get the details of the currently available update, if any.
getUpdateState ( ) : StdClass | null Load the update checker state from the DB.
handleManualCheck ( ) : void Check for updates when the user clicks the "Check for updates" link.
initDebugBarPanel ( ) Initialize the update checker Debug Bar plugin/add-on thingy.
injectInfo ( mixed $result, string $action = null, array | object $args = null ) : mixed Intercept plugins_api() calls that request information about our plugin and use the configured API endpoint to satisfy them.
injectUpdate ( StdClass $updates ) : StdClass Insert the latest update (if any) into the update list maintained by WP.
maybeCheckForUpdates ( ) : void Check for updates only if the configured check interval has already elapsed.
renameGithubDirectory ( string $source, string $remote_source ) : string Github .zip packages appends the branch name to the plugin's folder name.
requestInfo ( array $queryArgs = [] ) : PluginInfo Retrieve plugin info from the configured API endpoint.
requestUpdate ( ) : PluginUpdate Retrieve the latest update (if any) from the configured API endpoint.
resetUpdateState ( ) Reset update checker state - i.e. last check time, cached update data and so on.
sslVerify ( mixed $args, string $url ) : mixed Callback function for the 'http_request_args' filter.

Méthodes protégées

Méthode Description
installHooks ( ) : void Install the hooks required to run periodic update checks and inject update info into WP data structures.

Private Methods

Méthode Description
setUpdateState ( StdClass $state ) : void Persist the update checker state to the DB.

Method Details

__construct() public méthode

Class constructor.
public __construct ( string $metadataUrl, string $pluginFile, string $slug = '', integer $checkPeriod = 12, string $optionName = '' )
$metadataUrl string The URL of the plugin's metadata file.
$pluginFile string Fully qualified path to the main plugin file.
$slug string The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
$checkPeriod integer How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
$optionName string Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.

_addCustomSchedule() public méthode

Add our custom schedule to the array of Cron schedules used by WP.
public _addCustomSchedule ( array $schedules ) : array
$schedules array
Résultat array

_removeUpdaterCron() public méthode

Remove the scheduled cron event that the library uses to check for updates.
public _removeUpdaterCron ( ) : void
Résultat void

addFilter() public méthode

Identical to add_filter(), except it automatically adds the "puc_" prefix and the "-$plugin_slug" suffix to the filter name. For example, "request_info_result" becomes "puc_request_info_result-your_plugin_slug".
public addFilter ( string $tag, callable $callback, integer $priority = 10, integer $acceptedArgs = 1 )
$tag string
$callback callable
$priority integer
$acceptedArgs integer

addHttpRequestArgFilter() public méthode

The callback function should take one argument - an associative array of arguments - and return a modified array or arguments. See the WP documentation on wp_remote_get() for details on what arguments are available and how they work.
public addHttpRequestArgFilter ( callable $callback ) : void
$callback callable
Résultat void

addQueryArgFilter() public méthode

The callback function should take one argument - an associative array of query arguments. It should return a modified array of query arguments.
public addQueryArgFilter ( callable $callback ) : void
$callback callable
Résultat void

addResultFilter() public méthode

The callback function should take two arguments. If the plugin info was retrieved successfully, the first argument passed will be an instance of PluginInfo. Otherwise, it will be NULL. The second argument will be the corresponding return value of wp_remote_get (see WP docs for details). The callback function should return a new or modified instance of PluginInfo or NULL.
public addResultFilter ( callable $callback ) : void
$callback callable
Résultat void

checkForUpdates() public méthode

The results are stored in the DB option specified in $optionName.
public checkForUpdates ( ) : PluginUpdate | null
Résultat PluginUpdate | null

displayManualCheckResult() public méthode

Display the results of a manual update check.
See also: self::handleManualCheck() You can change the result message by using the "puc_manual_check_message-$slug" filter.

getCronHookName() public méthode

Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
public getCronHookName ( ) : string
Résultat string

getInstalledVersion() public méthode

Get the currently installed version of the plugin.
public getInstalledVersion ( ) : string
Résultat string Version number.

getUpdate() public méthode

If no updates are available, or if the last known update version is below or equal to the currently installed version, this method will return NULL. Uses cached update data. To retrieve update information straight from the metadata URL, call requestUpdate() instead.
public getUpdate ( ) : PluginUpdate | null
Résultat PluginUpdate | null

getUpdateState() public méthode

Load the update checker state from the DB.
public getUpdateState ( ) : StdClass | null
Résultat StdClass | null

handleManualCheck() public méthode

Check for updates when the user clicks the "Check for updates" link.
See also: self::addCheckForUpdatesLink()
public handleManualCheck ( ) : void
Résultat void

initDebugBarPanel() public méthode

Initialize the update checker Debug Bar plugin/add-on thingy.
public initDebugBarPanel ( )

injectInfo() public méthode

Intercept plugins_api() calls that request information about our plugin and use the configured API endpoint to satisfy them.
See also: plugins_api()
public injectInfo ( mixed $result, string $action = null, array | object $args = null ) : mixed
$result mixed
$action string
$args array | object
Résultat mixed

injectUpdate() public méthode

Insert the latest update (if any) into the update list maintained by WP.
public injectUpdate ( StdClass $updates ) : StdClass
$updates StdClass Update list.
Résultat StdClass Modified update list.

installHooks() protected méthode

Install the hooks required to run periodic update checks and inject update info into WP data structures.
protected installHooks ( ) : void
Résultat void

maybeCheckForUpdates() public méthode

Check for updates only if the configured check interval has already elapsed.
public maybeCheckForUpdates ( ) : void
Résultat void

renameGithubDirectory() public méthode

This isn't desirable. So we check to see if our plugin is hosted on Github. If so, we remove the branch name from the plugin's folder name to resemble WP convention.
public renameGithubDirectory ( string $source, string $remote_source ) : string
$source string Temporary location of the extracted folder. Contains the plugin folder name with the Github branch appended.
$remote_source string Temporary parent location. One level up from the extracted folder.
Résultat string Location of the extracted folder

requestInfo() public méthode

Retrieve plugin info from the configured API endpoint.
public requestInfo ( array $queryArgs = [] ) : PluginInfo
$queryArgs array Additional query arguments to append to the request. Optional.
Résultat PluginInfo

requestUpdate() public méthode

Retrieve the latest update (if any) from the configured API endpoint.
public requestUpdate ( ) : PluginUpdate
Résultat PluginUpdate An instance of PluginUpdate, or NULL when no updates are available.

resetUpdateState() public méthode

Call this when your plugin is being uninstalled, or if you want to clear the update cache.
public resetUpdateState ( )

sslVerify() public méthode

Check if download request is from Github. If so, set the 'sslverify' flag to false to allow the download to bypass SSL certificate verification.
public sslVerify ( mixed $args, string $url ) : mixed
$args mixed
$url string
Résultat mixed

Property Details

$checkPeriod public_oe property

Plugin slug.
public $checkPeriod

$debugMode public_oe property

Where to store the update info.
public $debugMode

$metadataUrl public_oe property

public $metadataUrl

$optionName public_oe property

How often to check for updates (in hours).
public $optionName

$pluginFile public_oe property

The URL of the plugin's metadata file.
public $pluginFile

$slug public_oe property

Plugin filename relative to the plugins directory.
public $slug