PHP Class Fragen\GitHub_Updater\Base

Class Base
Author: Andy Fragen
Author: Gary Jones
Datei anzeigen Open project: afragen/github-updater

Protected Properties

Property 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.

Public Methods

Method 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.

Protected Methods

Method 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

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

Method Details

__construct() public method

Loads options to private static variable.
public __construct ( )

add_headers() public method

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

add_meta_repo_object() protected method

Add remote data to type object.
protected add_meta_repo_object ( )

admin_pages_update_transient() public method

Ensure update transient is update to date on admin pages.

ajax_update() public method

AJAX endpoint for REST updates.
public ajax_update ( )

background_update() public method

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

can_update() public method

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

delete_all_transients() public method

Delete all _ghu- transients from database table.
public delete_all_transients ( ) : boolean
return boolean

ensure_api_key_is_set() protected method

Ensure api key is set.
protected ensure_api_key_is_set ( )

exit_no_update() protected method

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

forced_meta_update_plugins() public method

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 method

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

forced_meta_update_themes() public method

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 method

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

get_file_headers() protected method

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

get_local_info() protected method

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

get_remote_repo_meta() public method

Calls remote APIs for data.
public get_remote_repo_meta ( $repo ) : boolean
$repo
return boolean

get_repo_parts() protected method

Create repo parts.
protected get_repo_parts ( $repo, $type ) : mixed
$repo
$type
return mixed

get_repo_slugs() protected method

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

get_update_url() protected method

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
return string | void

init() public method

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

is_doing_ajax() protected static method

Checks to see if DOING_AJAX.
protected static is_doing_ajax ( ) : boolean
return boolean

is_heartbeat() protected static method

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

is_private() protected method

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
return boolean

load_hooks() public method

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

load_options() protected method

Load site options.
protected load_options ( )

make_branch_switch_row() protected method

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

make_rating() protected method

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

parse_header_uri() protected method

Parse URI param returning array of parts.
protected parse_header_uri ( $repo_header ) : array
$repo_header
return array

parse_tags() protected method

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

remove_hooks() public method

Remove hooks after use.
public remove_hooks ( )

set_defaults() protected method

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

set_file_info() protected method

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

set_options_filter() public method

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 method

Prefer changelog from CHANGES.md.
protected set_readme_info ( $response ) : boolean
$response
return boolean

set_rollback() public method

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

update_row_enclosure() protected method

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
return array

upgrader_post_install() public method

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
return mixed

upgrader_source_selection() public method

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
return string

Property Details

$auth_required protected_oe static_oe property

Used by class Settings and class Messages.
protected static bool $auth_required
return boolean

$config protected_oe property

Store details of all repositories that are installed.
protected object $config
return 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
return array

$extra_repo_headers protected_oe static_oe property

Holds extra repo header types.
protected static array $extra_repo_headers
return array

$git_servers protected_oe static_oe property

Holds git server types.
protected static array $git_servers
return array

$hours protected_oe static_oe property

Variable for setting update transient hours.
protected static int $hours
return 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
return boolean

$options protected_oe static_oe property

Holds the values to be used in the fields callbacks.
protected static array $options
return array

$options_remote protected_oe static_oe property

Holds the values for remote management settings.
protected static mixed $options_remote
return mixed

$repo_api protected_oe property

Class Object for API.
protected object $repo_api
return object