PHP Class Fragen\GitHub_Updater\Base

Class Base
Author: Andy Fragen
Author: Gary Jones
Afficher le fichier Open project: afragen/github-updater

Protected Properties

Свойство Type Description
$auth_required boolean Used by class Settings and class Messages.
$config object Store details of all repositories that are installed.
$error_code Holds HTTP error code from API call.
$extra_headers array Variable for holding extra theme and plugin headers.
$extra_repo_headers array Holds extra repo header types.
$git_servers array Holds git server types.
$hours integer Variable for setting update transient hours.
$languages Class Object for Language Packs.
$load_repo_meta boolean Checks user privileges and when to load.
$options array Holds the values to be used in the fields callbacks.
$options_remote mixed Holds the values for remote management settings.
$repo_api object Class Object for API.

Méthodes publiques

Méthode Description
__construct ( ) Constructor.
add_headers ( $extra_headers ) : array Add extra headers to get_plugins() or wp_get_themes().
admin_pages_update_transient ( ) Ensure update transient is update to date on admin pages.
ajax_update ( ) AJAX endpoint for REST updates.
background_update ( ) Piggyback on built-in update function to get metadata.
can_update ( $type ) : boolean Function to check if plugin or theme object is able to be updated.
delete_all_transients ( ) : boolean Delete all _ghu- transients from database table.
forced_meta_update_plugins ( boolean $true = false ) Performs actual plugin metadata fetching.
forced_meta_update_remote_management ( ) Calls $this->forced_meta_update_plugins() and $this->forced_meta_update_themes() for remote management services.
forced_meta_update_themes ( boolean $true = false ) Performs actual theme metadata fetching.
get_remote_repo_meta ( $repo ) : boolean Get remote repo meta data for plugins or themes.
init ( ) : boolean Instantiate Plugin, Theme, and Settings for proper user capabilities.
load_hooks ( ) Load relevant action/filter hooks.
remove_hooks ( ) Remove hooks after use.
set_options_filter ( ) Allows developers to use 'github_updater_set_options' hook to set access tokens or other settings.
set_rollback ( mixed $update_data ) : mixed Test if rollback and then run set_rollback_transient.
upgrader_post_install ( boolean $true, array $hook_extra, array $result ) : mixed Delete $source when updating from GitLab Release Asset.
upgrader_source_selection ( string $source, string $remote_source, object $upgrader, array $hook_extra = null ) : string Used for renaming of sources to ensure correct directory name.

Méthodes protégées

Méthode Description
add_meta_repo_object ( ) Add remote data to type object.
ensure_api_key_is_set ( ) Ensure api key is set.
exit_no_update ( $response, $branch = false ) : boolean Test to exit early if no update available, saves API calls.
get_changelog_filename ( $type ) : boolean | string Get filename of changelog and return.
get_file_headers ( $contents, $type ) : array Take remote file contents as string and parse headers.
get_local_info ( $repo, $file ) : null | string Get local file info if no update available. Save API calls.
get_repo_parts ( $repo, $type ) : mixed Create repo parts.
get_repo_slugs ( string $slug, object $upgrader_object = null ) : array Set array with normal and extended repo names.
get_update_url ( string $type, string $action, string $repo_name ) : string | void Generate update URL.
is_doing_ajax ( ) : boolean Checks to see if DOING_AJAX.
is_heartbeat ( ) : boolean Checks to see if a heartbeat is resulting in activity.
is_private ( object $repo ) : boolean Is this a private repo? Test for whether remote_version is set ( default = 0.0.0 ) or a repo option is set/not empty.
load_options ( ) Load site options.
make_branch_switch_row ( array $data ) : mixed Make branch switch row.
make_rating ( $repo_meta ) : integer Create some sort of rating from 0 to 100 for use in star ratings.
parse_header_uri ( $repo_header ) : array Parse URI param returning array of parts.
parse_tags ( $response, $repo_type ) : boolean Parse tags and set object data.
set_defaults ( $type ) Set default values for plugin/theme.
set_file_info ( $response ) Set repo object file info.
set_readme_info ( $response ) : boolean Set data from readme.txt.
update_row_enclosure ( $repo_name, $type, boolean $branch_switcher = false ) : array Return correct update row opening and closing tags for Shiny Updates.

Private Methods

Méthode Description
set_rollback_transient ( string $type, object $repo ) Update transient for rollback or branch switch.

Method Details

__construct() public méthode

Loads options to private static variable.
public __construct ( )

add_headers() public méthode

Add extra headers to get_plugins() or wp_get_themes().
public add_headers ( $extra_headers ) : array
$extra_headers
Résultat array

add_meta_repo_object() protected méthode

Add remote data to type object.
protected add_meta_repo_object ( )

admin_pages_update_transient() public méthode

Ensure update transient is update to date on admin pages.

ajax_update() public méthode

AJAX endpoint for REST updates.
public ajax_update ( )

background_update() public méthode

Piggyback on built-in update function to get metadata.
public background_update ( )

can_update() public méthode

Function to check if plugin or theme object is able to be updated.
public can_update ( $type ) : boolean
$type
Résultat boolean

delete_all_transients() public méthode

Delete all _ghu- transients from database table.
public delete_all_transients ( ) : boolean
Résultat boolean

ensure_api_key_is_set() protected méthode

Ensure api key is set.
protected ensure_api_key_is_set ( )

exit_no_update() protected méthode

Test to exit early if no update available, saves API calls.
protected exit_no_update ( $response, $branch = false ) : boolean
$response array|bool
$branch bool
Résultat boolean

forced_meta_update_plugins() public méthode

Performs actual plugin metadata fetching.
public forced_meta_update_plugins ( boolean $true = false )
$true boolean Only used from API::wp_update_response()

forced_meta_update_remote_management() public méthode

Calls $this->forced_meta_update_plugins() and $this->forced_meta_update_themes() for remote management services.

forced_meta_update_themes() public méthode

Performs actual theme metadata fetching.
public forced_meta_update_themes ( boolean $true = false )
$true boolean Only used from API::wp_update_response()

get_changelog_filename() protected méthode

Get filename of changelog and return.
protected get_changelog_filename ( $type ) : boolean | string
$type
Résultat boolean | string

get_file_headers() protected méthode

Take remote file contents as string and parse headers.
protected get_file_headers ( $contents, $type ) : array
$contents
$type
Résultat array

get_local_info() protected méthode

Get local file info if no update available. Save API calls.
protected get_local_info ( $repo, $file ) : null | string
$repo
$file
Résultat null | string

get_remote_repo_meta() public méthode

Calls remote APIs for data.
public get_remote_repo_meta ( $repo ) : boolean
$repo
Résultat boolean

get_repo_parts() protected méthode

Create repo parts.
protected get_repo_parts ( $repo, $type ) : mixed
$repo
$type
Résultat mixed

get_repo_slugs() protected méthode

Fix name even if installed without renaming originally.
protected get_repo_slugs ( string $slug, object $upgrader_object = null ) : array
$slug string
$upgrader_object object
Résultat array

get_update_url() protected méthode

Generate update URL.
protected get_update_url ( string $type, string $action, string $repo_name ) : string | void
$type string ( plugin or theme )
$action string
$repo_name string
Résultat string | void

init() public méthode

Instantiate Plugin, Theme, and Settings for proper user capabilities.
public init ( ) : boolean
Résultat boolean

is_doing_ajax() protected static méthode

Checks to see if DOING_AJAX.
protected static is_doing_ajax ( ) : boolean
Résultat boolean

is_heartbeat() protected static méthode

Checks to see if a heartbeat is resulting in activity.
protected static is_heartbeat ( ) : boolean
Résultat boolean

is_private() protected méthode

Is this a private repo? Test for whether remote_version is set ( default = 0.0.0 ) or a repo option is set/not empty.
protected is_private ( object $repo ) : boolean
$repo object
Résultat boolean

load_hooks() public méthode

Use 'init' hook for user capabilities.
public load_hooks ( )

load_options() protected méthode

Load site options.
protected load_options ( )

make_branch_switch_row() protected méthode

Make branch switch row.
protected make_branch_switch_row ( array $data ) : mixed
$data array Parameters for creating branch switching row.
Résultat mixed

make_rating() protected méthode

I'm really just making this up, more based upon popularity.
protected make_rating ( $repo_meta ) : integer
$repo_meta
Résultat integer

parse_header_uri() protected méthode

Parse URI param returning array of parts.
protected parse_header_uri ( $repo_header ) : array
$repo_header
Résultat array

parse_tags() protected méthode

Parse tags and set object data.
protected parse_tags ( $response, $repo_type ) : boolean
$response
$repo_type
Résultat boolean

remove_hooks() public méthode

Remove hooks after use.
public remove_hooks ( )

set_defaults() protected méthode

Set default values for plugin/theme.
protected set_defaults ( $type )
$type

set_file_info() protected méthode

Set repo object file info.
protected set_file_info ( $response )
$response

set_options_filter() public méthode

Saves results of filter hook to self::$options. Hook requires return of associative element array. $key === repo-name and $value === token e.g. array( 'repo-name' => 'access_token' );
public set_options_filter ( )

set_readme_info() protected méthode

Prefer changelog from CHANGES.md.
protected set_readme_info ( $response ) : boolean
$response
Résultat boolean

set_rollback() public méthode

Test if rollback and then run set_rollback_transient.
public set_rollback ( mixed $update_data ) : mixed
$update_data mixed
Résultat mixed $update_data

update_row_enclosure() protected méthode

Return correct update row opening and closing tags for Shiny Updates.
protected update_row_enclosure ( $repo_name, $type, boolean $branch_switcher = false ) : array
$repo_name
$type
$branch_switcher boolean
Résultat array

upgrader_post_install() public méthode

Delete $source when updating from GitLab Release Asset.
public upgrader_post_install ( boolean $true, array $hook_extra, array $result ) : mixed
$true boolean
$hook_extra array
$result array
Résultat mixed

upgrader_source_selection() public méthode

Used for renaming of sources to ensure correct directory name.
public upgrader_source_selection ( string $source, string $remote_source, object $upgrader, array $hook_extra = null ) : string
$source string
$remote_source string
$upgrader object
$hook_extra array
Résultat string

Property Details

$auth_required protected_oe static_oe property

Used by class Settings and class Messages.
protected static bool $auth_required
Résultat boolean

$config protected_oe property

Store details of all repositories that are installed.
protected object $config
Résultat object

$error_code protected_oe static_oe property

Holds HTTP error code from API call.
protected static $error_code

$extra_headers protected_oe static_oe property

Variable for holding extra theme and plugin headers.
protected static array $extra_headers
Résultat array

$extra_repo_headers protected_oe static_oe property

Holds extra repo header types.
protected static array $extra_repo_headers
Résultat array

$git_servers protected_oe static_oe property

Holds git server types.
protected static array $git_servers
Résultat array

$hours protected_oe static_oe property

Variable for setting update transient hours.
protected static int $hours
Résultat integer

$languages protected_oe property

Class Object for Language Packs.
protected $languages

$load_repo_meta protected_oe static_oe property

Checks user privileges and when to load.
protected static bool $load_repo_meta
Résultat boolean

$options protected_oe static_oe property

Holds the values to be used in the fields callbacks.
protected static array $options
Résultat array

$options_remote protected_oe static_oe property

Holds the values for remote management settings.
protected static mixed $options_remote
Résultat mixed

$repo_api protected_oe property

Class Object for API.
protected object $repo_api
Résultat object