Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Dec 21, 2024
2 parents c18b9a2 + cfaeea3 commit ff1a2b3
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate-pot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: WordPress POT Generator
uses: varunsridharan/action-wp-pot-generator@2.0
uses: afragen/action-wp-pot-generator@main
with:
save_path: "./languages"
item_slug: "${{ github.event.repository.name }}"
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#### [unreleased]

#### 12.8.0 / 2024-12-21
* update GitHub release asset parsing
* update `REST_API` for Bitbucket update link
* update `REST_API` for `update-api` route

#### 12.7.2 / 2024-12-18
* update `freemius/wordpress-sdk`
* use `mcaskill/composer-exclude-files` to exclude autoloading `start.php` from Freemius, issues arise
Expand Down
2 changes: 1 addition & 1 deletion git-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Git Updater
* Plugin URI: https://git-updater.com
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
* Version: 12.7.2
* Version: 12.8.0
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down
5 changes: 4 additions & 1 deletion src/Git_Updater/API/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,10 @@ public function get_api_url( $endpoint, $download_link = false ) {
*/
$type = apply_filters( 'gu_api_url_type', $type, $this->type, $download_link, $endpoint );

$base = $download_link ? $type['base_download'] : $type['base_uri'];
$base = $download_link ? $type['base_download'] : $type['base_uri'];
if ( is_string( $base ) && str_starts_with( $endpoint, $base ) ) {
return $endpoint;
}
$endpoint = $repo_api->add_endpoints( $this, $endpoint );

return $base . $endpoint;
Expand Down
24 changes: 24 additions & 0 deletions src/Git_Updater/API/GitHub_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ public function construct_download_link( $branch_switch = false ) {
if ( $this->use_release_asset( $branch_switch ) ) {
$release_asset = $this->get_release_asset();

if ( empty( $this->response['release_asset_download'] ) ) {
$response = $this->api( $release_asset );
$this->parse_release_asset_response( $response );
}
if ( ! empty( $this->response['release_asset_download'] ) ) {
return $this->response['release_asset_download'];
}

return $this->get_release_asset_redirect( $release_asset, true );
}

Expand Down Expand Up @@ -310,6 +318,22 @@ public function parse_branch_response( $response ) {
return $branches;
}

/**
* Parse release asset API response.
*
* @param \stdClass $response API response.
*
* @return void
*/
public function parse_release_asset_response( $response ) {
if ( $this->validate_response( $response ) ) {
return;
}
if ( property_exists( $response, 'browser_download_url' ) ) {
$this->set_repo_cache( 'release_asset_download', $response->browser_download_url );
}
}

/**
* Parse tags and create download links.
*
Expand Down
62 changes: 25 additions & 37 deletions src/Git_Updater/REST/REST_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,25 @@ public function register_endpoints() {
]
);

register_rest_route(
self::$namespace,
'plugins-api',
[
'show_in_index' => true,
'methods' => \WP_REST_Server::READABLE,
'callback' => [ $this, 'get_api_data' ],
'permission_callback' => '__return_true',
'args' => [
'slug' => [
'default' => false,
'required' => true,
'validate_callback' => 'sanitize_title_with_dashes',
],
],
]
);

register_rest_route(
self::$namespace,
'themes-api',
[
'show_in_index' => true,
'methods' => \WP_REST_Server::READABLE,
'callback' => [ $this, 'get_api_data' ],
'permission_callback' => '__return_true',
'args' => [
'slug' => [
'default' => false,
'required' => true,
'validate_callback' => 'sanitize_title_with_dashes',
foreach ( [ 'plugins-api', 'themes-api', 'update-api' ] as $route ) {
register_rest_route(
self::$namespace,
$route,
[
'show_in_index' => true,
'methods' => \WP_REST_Server::READABLE,
'callback' => [ $this, 'get_api_data' ],
'permission_callback' => '__return_true',
'args' => [
'slug' => [
'default' => false,
'required' => true,
'validate_callback' => 'sanitize_title_with_dashes',
],
],
],
]
);
]
);
}

$update_args = [
'key' => [
Expand Down Expand Up @@ -404,16 +388,20 @@ public function get_api_data( \WP_REST_Request $request ) {
];

$repo_cache = $this->get_repo_cache( $slug );
Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->response = $repo_cache;

if ( $repo_api_data['download_link'] && $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true )
if ( $repo_api_data['download_link']
&& ( $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true ) )
) {
$repo_api_data['auth_header'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->add_auth_header( [], $repo_api_data['download_link'] );
$repo_api_data['auth_header'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->unset_release_asset_auth( $repo_api_data['auth_header'], $repo_api_data['download_link'] );
}

if ( $download && $repo_data->release_asset ) {
if ( isset( $repo_cache['release_asset_redirect'] ) ) {
$repo_api_data['download_link'] = $repo_cache['release_asset_redirect'];
if ( isset( $repo_cache['release_asset_download'] )
&& 'bitbucket' !== $repo_api_data['git']
) {
$repo_api_data['download_link'] = $repo_cache['release_asset_download'];
} elseif ( $repo_cache['release_asset'] ) {
$_REQUEST['override'] = true;
$repo_api_data['download_link'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->get_release_asset_redirect( $repo_cache['release_asset'], true );
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Traits/API_Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ final public function get_api_release_asset( $git, $request ) {
}
}

if ( $response && ( ! isset( $this->response['release_asset'] ) || ! $this->response['release_asset'] ) ) {
if ( $response && ! isset( $this->response['release_asset'] ) ) {
$this->set_repo_cache( 'release_asset', $response );
}

Expand Down
10 changes: 0 additions & 10 deletions vendor/composer/autoload_files.php

This file was deleted.

12 changes: 0 additions & 12 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ public static function getLoader()

$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInita27e6a3df8c435e2b136f961f0442be2::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}

return $loader;
}
}
4 changes: 0 additions & 4 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

class ComposerStaticInita27e6a3df8c435e2b136f961f0442be2
{
public static $files = array (
'8d50dc88e56bace65e1e72f6017983ed' => __DIR__ . '/..' . '/freemius/wordpress-sdk/start.php',
);

public static $prefixLengthsPsr4 = array (
'P' =>
array (
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'afragen/git-updater',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '19c0943a1677aa478ba1fa0996d45a4269cee99c',
'reference' => 'c18b9a2172809b787403f0aa29980a9cb5b1fd85',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'afragen/git-updater' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '19c0943a1677aa478ba1fa0996d45a4269cee99c',
'reference' => 'c18b9a2172809b787403f0aa29980a9cb5b1fd85',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down

0 comments on commit ff1a2b3

Please sign in to comment.