PHP 클래스 PluginUpdateChecker_1_3_1, bp-reply-by-email

저자: Janis Elsts
파일 보기 프로젝트 열기: r-a-y/bp-reply-by-email

공개 프로퍼티들

프로퍼티 타입 설명
$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