Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/packages/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ function delete_cached_did_for_install(): void {
*
* This is commonly required for packages from Git hosts.
*
* @param string $source Path of $source.
* @param string|WP_Error $source Path of $source, or a WP_Error object.
* @param string $remote_source Path of $remote_source.
* @param WP_Upgrader $upgrader An Upgrader object.
* @param array $hook_extra Array of hook data.
Expand Down
30 changes: 20 additions & 10 deletions inc/updater/class-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ public function run() {
);
$response = get_site_transient( "git-updater-lite_{$this->file}" );
if ( ! $response ) {
/* Apply filter to API URL.
* Add `channel=development` query arg to URL to get pre-release versions.
*
* @param string $url The API URL.
* @param string $slug The plugin/theme slug
*/
$url = apply_filters( 'git_updater_lite_api_url', $url, $this->slug );
$response = wp_remote_get( $url );
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) === 404 ) {
return $response;
Expand All @@ -136,11 +143,9 @@ public function run() {
}
$this->api_data->file = $this->file;

/*
* Set transient for 5 minutes as AWS sets 5 minute timeout
* for release asset redirect.
*/
set_site_transient( "git-updater-lite_{$this->file}", $this->api_data, 5 * \MINUTE_IN_SECONDS );
// Set timeout for transient via filter.
$timeout = apply_filters( 'git_updater_lite_transient_timeout', 6 * HOUR_IN_SECONDS, $this->file );
set_site_transient( "git-updater-lite_{$this->file}", $this->api_data, $timeout );
} else {
if ( property_exists( $response, 'error' ) ) {
return new WP_Error( 'repo-no-exist', 'Specified repo does not exist' );
Expand Down Expand Up @@ -178,18 +183,23 @@ function () {
/**
* Correctly rename dependency for activation.
*
* @param string $source Path of $source.
* @param string $remote_source Path of $remote_source.
* @param WP_Upgrader $upgrader An Upgrader object.
* @param array $hook_extra Array of hook data.
* @param string|WP_Error $source Path of $source, or a WP_Error object.
* @param string $remote_source Path of $remote_source.
* @param WP_Upgrader $upgrader An Upgrader object.
* @param array $hook_extra Array of hook data.
*
* @throws TypeError If the type of $upgrader is not correct.
*
* @return string|WP_Error
*/
public function upgrader_source_selection( string $source, string $remote_source, WP_Upgrader $upgrader, $hook_extra = null ) {
public function upgrader_source_selection( $source, string $remote_source, WP_Upgrader $upgrader, $hook_extra = null ) {
global $wp_filesystem;

// Exit early for errors.
if ( is_wp_error( $source ) ) {
return $source;
}

$new_source = $source;

// Exit if installing.
Expand Down
10 changes: 8 additions & 2 deletions inc/updater/class-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use stdClass;
use Theme_Upgrader;
use TypeError;
use WP_Error;
use WP_Upgrader;

/**
Expand Down Expand Up @@ -149,7 +150,7 @@ public function load_hooks() {
/**
* Correctly rename dependency for activation.
*
* @param string $source Path of $source.
* @param string|WP_Error $source Path of $source, or a WP_Error object.
* @param string $remote_source Path of $remote_source.
* @param WP_Upgrader $upgrader An Upgrader object.
* @param array $hook_extra Array of hook data.
Expand All @@ -158,9 +159,14 @@ public function load_hooks() {
*
* @return string|WP_Error
*/
public function upgrader_source_selection( string $source, string $remote_source, WP_Upgrader $upgrader, $hook_extra = null ) {
public function upgrader_source_selection( $source, string $remote_source, WP_Upgrader $upgrader, $hook_extra = null ) {
global $wp_filesystem;

// Exit early for errors.
if ( is_wp_error( $source ) ) {
return $source;
}

$new_source = $source;

// Exit if installing.
Expand Down