PHP Класс PluginUpdateChecker_1_3_1, bp-reply-by-email

Автор: Janis Elsts
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$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.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
installHooks ( ) : void Install the hooks required to run periodic update checks and inject update info into WP data structures.

Приватные методы

Метод Описание
setUpdateState ( StdClass $state ) : void Persist the update checker state to the DB.

Описание методов

__construct() публичный Метод

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() публичный Метод

Add our custom schedule to the array of Cron schedules used by WP.
public _addCustomSchedule ( array $schedules ) : array
$schedules array
Результат array

_removeUpdaterCron() публичный Метод

Remove the scheduled cron event that the library uses to check for updates.
public _removeUpdaterCron ( ) : void
Результат void

addFilter() публичный Метод

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() публичный Метод

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
Результат void

addQueryArgFilter() публичный Метод

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
Результат void

addResultFilter() публичный Метод

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
Результат void

checkForUpdates() публичный Метод

The results are stored in the DB option specified in $optionName.
public checkForUpdates ( ) : PluginUpdate | null
Результат PluginUpdate | null

displayManualCheckResult() публичный Метод

Display the results of a manual update check.
См. также: self::handleManualCheck() You can change the result message by using the "puc_manual_check_message-$slug" filter.

getCronHookName() публичный Метод

Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
public getCronHookName ( ) : string
Результат string

getInstalledVersion() публичный Метод

Get the currently installed version of the plugin.
public getInstalledVersion ( ) : string
Результат string Version number.

getUpdate() публичный Метод

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
Результат PluginUpdate | null

getUpdateState() публичный Метод

Load the update checker state from the DB.
public getUpdateState ( ) : StdClass | null
Результат StdClass | null

handleManualCheck() публичный Метод

Check for updates when the user clicks the "Check for updates" link.
См. также: self::addCheckForUpdatesLink()
public handleManualCheck ( ) : void
Результат void

initDebugBarPanel() публичный Метод

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

injectInfo() публичный Метод

Intercept plugins_api() calls that request information about our plugin and use the configured API endpoint to satisfy them.
См. также: plugins_api()
public injectInfo ( mixed $result, string $action = null, array | object $args = null ) : mixed
$result mixed
$action string
$args array | object
Результат mixed

injectUpdate() публичный Метод

Insert the latest update (if any) into the update list maintained by WP.
public injectUpdate ( StdClass $updates ) : StdClass
$updates StdClass Update list.
Результат StdClass Modified update list.

installHooks() защищенный Метод

Install the hooks required to run periodic update checks and inject update info into WP data structures.
protected installHooks ( ) : void
Результат void

maybeCheckForUpdates() публичный Метод

Check for updates only if the configured check interval has already elapsed.
public maybeCheckForUpdates ( ) : void
Результат void

renameGithubDirectory() публичный Метод

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.
Результат string Location of the extracted folder

requestInfo() публичный Метод

Retrieve plugin info from the configured API endpoint.
public requestInfo ( array $queryArgs = [] ) : PluginInfo
$queryArgs array Additional query arguments to append to the request. Optional.
Результат PluginInfo

requestUpdate() публичный Метод

Retrieve the latest update (if any) from the configured API endpoint.
public requestUpdate ( ) : PluginUpdate
Результат PluginUpdate An instance of PluginUpdate, or NULL when no updates are available.

resetUpdateState() публичный Метод

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

sslVerify() публичный Метод

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
Результат mixed

Описание свойств

$checkPeriod публичное свойство

Plugin slug.
public $checkPeriod

$debugMode публичное свойство

Where to store the update info.
public $debugMode

$metadataUrl публичное свойство

public $metadataUrl

$optionName публичное свойство

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

$pluginFile публичное свойство

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

$slug публичное свойство

Plugin filename relative to the plugins directory.
public $slug