Skip to content

Commit ff1a2b3

Browse files
committed
Merge branch 'develop'
2 parents c18b9a2 + cfaeea3 commit ff1a2b3

File tree

11 files changed

+63
-69
lines changed

11 files changed

+63
-69
lines changed

.github/workflows/generate-pot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@master
1616
- name: WordPress POT Generator
17-
uses: varunsridharan/action-wp-pot-generator@2.0
17+
uses: afragen/action-wp-pot-generator@main
1818
with:
1919
save_path: "./languages"
2020
item_slug: "${{ github.event.repository.name }}"

CHANGES.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#### [unreleased]
22

3+
#### 12.8.0 / 2024-12-21
4+
* update GitHub release asset parsing
5+
* update `REST_API` for Bitbucket update link
6+
* update `REST_API` for `update-api` route
7+
38
#### 12.7.2 / 2024-12-18
49
* update `freemius/wordpress-sdk`
510
* use `mcaskill/composer-exclude-files` to exclude autoloading `start.php` from Freemius, issues arise

git-updater.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin Name: Git Updater
1313
* Plugin URI: https://git-updater.com
1414
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
15-
* Version: 12.7.2
15+
* Version: 12.8.0
1616
* Author: Andy Fragen
1717
* License: MIT
1818
* Domain Path: /languages

src/Git_Updater/API/API.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ public function get_api_url( $endpoint, $download_link = false ) {
327327
*/
328328
$type = apply_filters( 'gu_api_url_type', $type, $this->type, $download_link, $endpoint );
329329

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

333336
return $base . $endpoint;

src/Git_Updater/API/GitHub_API.php

+24
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ public function construct_download_link( $branch_switch = false ) {
126126
if ( $this->use_release_asset( $branch_switch ) ) {
127127
$release_asset = $this->get_release_asset();
128128

129+
if ( empty( $this->response['release_asset_download'] ) ) {
130+
$response = $this->api( $release_asset );
131+
$this->parse_release_asset_response( $response );
132+
}
133+
if ( ! empty( $this->response['release_asset_download'] ) ) {
134+
return $this->response['release_asset_download'];
135+
}
136+
129137
return $this->get_release_asset_redirect( $release_asset, true );
130138
}
131139

@@ -310,6 +318,22 @@ public function parse_branch_response( $response ) {
310318
return $branches;
311319
}
312320

321+
/**
322+
* Parse release asset API response.
323+
*
324+
* @param \stdClass $response API response.
325+
*
326+
* @return void
327+
*/
328+
public function parse_release_asset_response( $response ) {
329+
if ( $this->validate_response( $response ) ) {
330+
return;
331+
}
332+
if ( property_exists( $response, 'browser_download_url' ) ) {
333+
$this->set_repo_cache( 'release_asset_download', $response->browser_download_url );
334+
}
335+
}
336+
313337
/**
314338
* Parse tags and create download links.
315339
*

src/Git_Updater/REST/REST_API.php

+25-37
Original file line numberDiff line numberDiff line change
@@ -100,41 +100,25 @@ public function register_endpoints() {
100100
]
101101
);
102102

103-
register_rest_route(
104-
self::$namespace,
105-
'plugins-api',
106-
[
107-
'show_in_index' => true,
108-
'methods' => \WP_REST_Server::READABLE,
109-
'callback' => [ $this, 'get_api_data' ],
110-
'permission_callback' => '__return_true',
111-
'args' => [
112-
'slug' => [
113-
'default' => false,
114-
'required' => true,
115-
'validate_callback' => 'sanitize_title_with_dashes',
116-
],
117-
],
118-
]
119-
);
120-
121-
register_rest_route(
122-
self::$namespace,
123-
'themes-api',
124-
[
125-
'show_in_index' => true,
126-
'methods' => \WP_REST_Server::READABLE,
127-
'callback' => [ $this, 'get_api_data' ],
128-
'permission_callback' => '__return_true',
129-
'args' => [
130-
'slug' => [
131-
'default' => false,
132-
'required' => true,
133-
'validate_callback' => 'sanitize_title_with_dashes',
103+
foreach ( [ 'plugins-api', 'themes-api', 'update-api' ] as $route ) {
104+
register_rest_route(
105+
self::$namespace,
106+
$route,
107+
[
108+
'show_in_index' => true,
109+
'methods' => \WP_REST_Server::READABLE,
110+
'callback' => [ $this, 'get_api_data' ],
111+
'permission_callback' => '__return_true',
112+
'args' => [
113+
'slug' => [
114+
'default' => false,
115+
'required' => true,
116+
'validate_callback' => 'sanitize_title_with_dashes',
117+
],
134118
],
135-
],
136-
]
137-
);
119+
]
120+
);
121+
}
138122

139123
$update_args = [
140124
'key' => [
@@ -404,16 +388,20 @@ public function get_api_data( \WP_REST_Request $request ) {
404388
];
405389

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

408-
if ( $repo_api_data['download_link'] && $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true )
393+
if ( $repo_api_data['download_link']
394+
&& ( $repo_api_data['is_private'] || in_array( $repo_api_data['git'], [ 'gitlab', 'gitea' ], true ) )
409395
) {
410396
$repo_api_data['auth_header'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->add_auth_header( [], $repo_api_data['download_link'] );
411397
$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'] );
412398
}
413399

414400
if ( $download && $repo_data->release_asset ) {
415-
if ( isset( $repo_cache['release_asset_redirect'] ) ) {
416-
$repo_api_data['download_link'] = $repo_cache['release_asset_redirect'];
401+
if ( isset( $repo_cache['release_asset_download'] )
402+
&& 'bitbucket' !== $repo_api_data['git']
403+
) {
404+
$repo_api_data['download_link'] = $repo_cache['release_asset_download'];
417405
} elseif ( $repo_cache['release_asset'] ) {
418406
$_REQUEST['override'] = true;
419407
$repo_api_data['download_link'] = Singleton::get_instance( 'Fragen\Git_Updater\API\API', $this )->get_release_asset_redirect( $repo_cache['release_asset'], true );

src/Git_Updater/Traits/API_Common.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ final public function get_api_release_asset( $git, $request ) {
342342
}
343343
}
344344

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

vendor/composer/autoload_files.php

-10
This file was deleted.

vendor/composer/autoload_real.php

-12
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ public static function getLoader()
3333

3434
$loader->register(true);
3535

36-
$filesToLoad = \Composer\Autoload\ComposerStaticInita27e6a3df8c435e2b136f961f0442be2::$files;
37-
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
38-
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
39-
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
40-
41-
require $file;
42-
}
43-
}, null, null);
44-
foreach ($filesToLoad as $fileIdentifier => $file) {
45-
$requireFile($fileIdentifier, $file);
46-
}
47-
4836
return $loader;
4937
}
5038
}

vendor/composer/autoload_static.php

-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
class ComposerStaticInita27e6a3df8c435e2b136f961f0442be2
88
{
9-
public static $files = array (
10-
'8d50dc88e56bace65e1e72f6017983ed' => __DIR__ . '/..' . '/freemius/wordpress-sdk/start.php',
11-
);
12-
139
public static $prefixLengthsPsr4 = array (
1410
'P' =>
1511
array (

vendor/composer/installed.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'afragen/git-updater',
44
'pretty_version' => 'dev-master',
55
'version' => 'dev-master',
6-
'reference' => '19c0943a1677aa478ba1fa0996d45a4269cee99c',
6+
'reference' => 'c18b9a2172809b787403f0aa29980a9cb5b1fd85',
77
'type' => 'wordpress-plugin',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -13,7 +13,7 @@
1313
'afragen/git-updater' => array(
1414
'pretty_version' => 'dev-master',
1515
'version' => 'dev-master',
16-
'reference' => '19c0943a1677aa478ba1fa0996d45a4269cee99c',
16+
'reference' => 'c18b9a2172809b787403f0aa29980a9cb5b1fd85',
1717
'type' => 'wordpress-plugin',
1818
'install_path' => __DIR__ . '/../../',
1919
'aliases' => array(),

0 commit comments

Comments
 (0)